Search
JavaScript (Node.js), 38 32 bytes -6 bytes thanks to Shaggy! a=>a.map(v=>d[v]=-~d[v],d={})&&d Try it online! Basically just this but returning the result
APL(Dyalog Unicode), 4 bytes SBCS Anonymous tacit prefix function. ,∘≢⌸ Try it on APLgolf! …⌸ between each unique element and its indices, apply: ,∘≢ concatenate the unique element to the ta...
C (gcc), 45, 42 bytes t[9999];f(s,a)int*a;{for(;s;)t[a[--s]]++;} Try it online! Assumptions: Passing the array size to a function can be used as a means to deal with empty arrays (not s...
Lua, 98 bytes function(t)r={}for k,v in pairs(t)do r[v]=0 end for k,v in pairs(t)do r[v]=r[v]+1 end return r end Attempt This Online!
J, 24 char ([: +/ [: (* +/\ )"1 ~. ="0 1 ]) Sample Runs ([:+/[:(*+/\)"1~.="0 1]) 1 1 2 2 2 1 1 1 3 3 1 2 1 2 3 3 4 5 1 2 ([:+/[:(*+/\)"1~.="0 1]) 3 7 5 4 9 2 3 2 6 6 1 1 1 1 1 1 2 ...
J, 9 bytes 1#.]=&><\ This is the 7 byte APL solve but makes use of #. in place of +/"1. I came up with 1#.]=[\ first, but bubbler pointed out it breaks when non zeros are present. At...
Python 3.8 (pre-release), 69 bytes def f(x,y={},z=[]): for i in x:y[i]=y.get(i,0)+1;z+=[y[i]] return z Try it online! Bonus: theoretical answer if python allowed named assignment with su...
Python 3, 74 bytes def f(a): d={x:0 for x in a};r=[] for x in a:d[x]+=1;r+=[d[x]] return r Try it online!
Myby, 2 bytes %2 Input is taken from the command line implicitly. 0 for even, 1 for odd. Since Myby is still in its early stages, there is no online sandbox. Some test cases can be seen here.
ESCR, 17 bytes show [and [in] 1] ESCR has no way to read from standard input (currently), so I assumed the existence of the function IN which magically returns the user input. Since the user i...
Vyxal, 1 byte Ċ Try it Online! Yes, there really is a built-in for this.
Vyxal, 4 bytes KƛtO Try it Online! Explained KƛtO Kƛ # For each prefix of the input tO # How many times does the tail occur in the prefix?
Factor, 108 bytes USING: assocs kernel math math.primes.factors ; IN: s : ? ( n -- ? ) group-factors [ nip 2 < ] assoc-all? ;
Factor, 122 bytes USING: kernel sequences sequences.windowed ; IN: c : c ( s -- s ) dup length [ dup last [ = ] curry count ] rolling-map ;
Goruby, 38 bytes ->n{dw{$.+=1;$..mp{1.0/-~_1}.su<n};$.} This was not as much fun as I thought it would be, but it was fun enough to use once.
Python 3, 70 bytes def f(a): d={};r=[] for x in a:d[x]=d.get(x,0)+1;r+=[d[x]] return r Try it online!
Both tags and [FINALIZED] are problematic Problem with tags Having been shown the related meta post Separate the tags away from the Sandbox or delete the [finalized] tag I can now see that having...
Z80 Assembler, 50 bytes org 256 ld de,m ld c,9 jp 5 m:db"Hello, world!\r$" With assembler there's usually the problem which machine or operating system the program is for. I've chosen CP/M ...
C (gcc), 117 bytes b,r;f(char*s){char*p=s;for(;*p;p++)*p-=47+7*(*p>57),b=b<*p?*p:b;if(b<2)return p-s;for(;*s;s++)r*=b,r+=*s-1;return r;} Try it online!