Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »

Activity for Zakk‭

Type On... Excerpt Status Date
Answer A: Make a frequency table (histogram)
Lua, 98 bytes ``` lua 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!
(more)
almost 2 years ago
Answer A: Word Count Tool
JavaScript (Node.js), 60 bytes ``` javascript s=>[/\w+/g,/./g,/[\S\t]/g].map(p=>(v=s.match(p))?v.length:0) ``` Attempt This Online!
(more)
about 2 years ago
Answer A: Word Count Tool
Lua 5.4, 62 bytes ``` lua ,w=s:gsub('%w+',0),c=s:gsub('[^\n]',0),n=s:gsub('[%g\t]',0) ``` Attempt This Online! Another version, 65 bytes: ``` lua p={'%w+','[^\n]','[%g\t]'}for i=1,#p do ,r[i]=s:gsub(p[i],'')end ``` Attempt This Online!
(more)
about 2 years ago
Answer A: Collatz conjecture; Count the tries to reach $1$
Lua 5.4, 67 60 bytes ``` lua function(x)return x==1 and 0 or 1+f(({x/2,3x+1})[x%2+1])end ``` Attempt This Online! Credits to @Moshi for more shortening.
(more)
about 2 years ago
Answer A: Collatz conjecture; Count the tries to reach $1$
C (gcc), 43 38 bytes ``` C f(i){return i>1?f(i%2?3i+1:i/2)+1:0;} ``` Attempt This Online! Credits to @Moshi for shortening the code.
(more)
about 2 years ago
Answer A: Make $2 + 2 = 5$
C (gcc), 41 bytes ```c f(x,y){int r=xy;return r&&r==x+y?5:x+y;} ``` Attempt This Online!
(more)
about 2 years ago
Answer A: Create a range grid
C (gcc), 59 bytes ``` C i;f(m,n){while(i<mn){putchar(i%n?32:13);putchar(48+i++);}} ``` Attempt This Online! `m` is the number of rows. `n` is the number of columns.
(more)
about 2 years ago
Answer A: Create a range grid
Lua 5.4, 76 bytes ``` lua function(m,n)for i=0,mn-1 do =(i%n==0)and print()or io.write(i,' ')end end ``` Try it online!
(more)
about 2 years ago
Answer A: It's Hip to be Square
C (gcc), 37 bytes ``` C f(n,p){while(++pp<n);return pp==n;} ``` Try it online! The solution is based on the simple fact that: $$\forall n \in \mathbb{N}, n \text{ is a perfect square} \Longleftrightarrow \exists p \in \mathbb{N}, p \le n \text{ / } p^2=n$$
(more)
about 2 years ago
Answer A: It's Hip to be Square
Lua 5.4, 9 bytes ``` lua n^.5%1==0 ``` Try it online! The entire compressed code is 33 bytes: ``` lua function f(n)return n^.5%1==0 end ``` Try it here. It's not clear whether the rules allow the first form (i.e. only the relevant expression) or the second form (i.e. the ent...
(more)
about 2 years ago
Answer A: It's Hip to be Square
JavaScript (V8), 13 bytes ``` javascript x=>x.5%1==0 ``` Try it online!
(more)
about 2 years ago
Answer A: Can you give me half?
Lua 5.4, 3 unique characters ``` lua #'#'/#'##' ``` Try it online! > [...] scoring is done in terms of number of unique characters used in the submission. 1. Hashtag # 2. Single quote ' 3. Slash /
(more)
about 2 years ago
Answer A: The Pell Numbers
C (gcc), 35 bytes ``` C f(n){return n<2?n:f(n-1)2+f(n-2);} ``` Try it online!
(more)
about 2 years ago
Answer A: The Pell Numbers
Lua 5.4.4, 51 bytes ``` lua function f(n)return n<2 and n or f(n-1)2+f(n-2)end ``` Try it online!
(more)
about 2 years ago
Answer A: Write a Deadfish Interpreter
JavaScript (V8), 78 bytes ``` javascript f=s=>s.map(c=>(==256||<0?=0:0)||c=='i'?++:c=='d'?--:c=='s'?=:v+=+' ') ``` Try it online!
(more)
about 2 years ago
Answer A: Write a Deadfish Interpreter
C (gcc), 98 bytes ``` c =0;f(chars){for(;s;++s)==256||<0?=0:1,s=='i'?++:s=='d'?--:s=='s'?=:printf("%d ",);} ``` Try it online!
(more)
about 2 years ago
Answer A: Write a Deadfish Interpreter
Lua 5.4.4, 99 bytes ``` =0s:gsub('.',function(c)=({d=-1,i=+1;s=})[c]or print()or =({[256]=0,[-1]=0})[]or end) ``` Try it online! Thanks to @orthoplex for more shortening.
(more)
about 2 years ago
Answer A: Keyword golfing
Lua 5.4.4, 147 bytes ``` local function f()goto l::l::return end for in f do end if true and false then elseif""then else end repeat until""or not nil while""do break end ``` Try it online! Check the list of keywords. Thanks to @orthoplex for more shortening.
(more)
about 2 years ago
Answer A: Looping counter
Lua, 31 bytes ``` =''::::=..''print()goto ``` Try it online!
(more)
about 2 years ago