Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 109980

Code-golf is a competition to solve a particular problem in the fewest bytes of source code.

5 votes

Nesting list with a value repeated `n` amount of times

Racket, 49 bytes (define(f x n)(if(= n 1)`(,x)`(,x,(f x(- n 1))))) Try it online!
kirjosieppo's user avatar
3 votes

Group elements by their displacement

Haskell, 83 bytes g a=(\l->map(\k->[fst m|m<-zip a$map(\n->abs$1+n-a!!n)l,snd m==k])l)[0..length a-1] Try it online!
kirjosieppo's user avatar
1 vote

Total cost of The 12 Days of Christmas

Haskell, 69 bytes f x=sum$map sum[(map$uncurry(*))$zip x[1..n]|n<-[1..genericLength x]] Try it online!
kirjosieppo's user avatar