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 15121

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

3 votes

Alphabet cannon

Clojure, 417 319 bytes (defn cannon[n](let[a(map #(char(+ 65 %))(iterate #(if(> % 24)0(inc %))0))m1(reverse(reduce #(concat %(repeat %2(- n %2)))[](range 0(inc n))))p1(map-indexed #(str(apply str(rep …
Joshua's user avatar
  • 241
2 votes

Create a binary wall

Clojure, 185 bytes (fn[i](let[b(map #(Long/toBinaryString %)i)](map #(clojure.string/replace(clojure.string/replace(format(str"%0"(reduce(fn[l i](max l(count i)))0 b)"d")(read-string %))"1""#")"0"" " …
Joshua's user avatar
  • 241
2 votes

Code Golf: Your own pet ASCII snake

Clojure, 88 77 bytes Always happy to provide a Clojure answer. Always sad, it's quite long. (loop[x 30 p x](when(> x 0)(printf(str "%"p"d\n")1)(recur(dec x)(+(-(rand-int 3)1)p)))) Ungolfed: (loop …
Joshua's user avatar
  • 241
1 vote

Find the Missing Letter

Clojure, 102 89 bytes #(nth(filter(fn[a](not(some #{a}%)))(map char(range(int(first %))(inc(int(last %)))))) 0) Anonymous function, takes a string as parameter and returns the first missing charact …
Joshua's user avatar
  • 241
1 vote

Reliably Broken Sort

Clojure, 36 bytes #(let[s %](cons(last s)(butlast s))) Stole the solution to sort it and push the last element to the start of the list.
Joshua's user avatar
  • 241
1 vote

There, I fixed it (with tape)

Clojure, 139 119 bytes #(reduce-kv(fn[r x c](let[a(cycle "TAPE")i int d(-(i(nth(cycle %)(inc x)))(i c))](str r(if(> d 1)(apply str c(take(dec d)a))c))))""(vec %)) Anonymous function which take the …
Joshua's user avatar
  • 241
1 vote

Rebuild a rectangular array from a corner

Clojure, 56 bytes (fn[i](map #(concat %(reverse %))(concat i(reverse i)))) Creates an anonymous function which takes the two dimensional list and returns the fixed rectangle as two dimensional lis …
Joshua's user avatar
  • 241
1 vote

Add Rainbow Pairs

Clojure, 124 bytes #(loop[l(map bigint(.split %" "))](println(+(first l)(or(last(rest l))0)))(if(>(count l)2)(recur(concat(butlast(rest l)))))) Try it online! Ungolfed: #(loop [l (map bigint (. …
Joshua's user avatar
  • 241
1 vote

"DDoouubbllee ssppeeaakk!!"

Clojure, 25 bytes (fn[s](apply str(map #(str % %)s)))
Joshua's user avatar
  • 241
1 vote

Implement a bag without replacement

Clojure, 56 bytes (run! #(run! println %)(repeatedly #(shuffle(range 7)))) Creates an infinite list containing random permutations of 0 to 6 and prints each number. Try it online!
Joshua's user avatar
  • 241
0 votes

The redundant boolean

Clojure, 28 bytes #(format "%031d" (if % 1 0)) Truthy is everything but nil and false
Joshua's user avatar
  • 241
0 votes

Sum of all integers from 1 to n

Clojure, 28 bytes #(apply + (range 1 (inc %)))
Joshua's user avatar
  • 241
0 votes

Produce the number 2014 without any numbers in your source code

Clojure - 35 characters ASCII only (print(-(*(int\#)(int\<))(int\V))) Based on True Soft's answer
Joshua's user avatar
  • 241
0 votes

Do the circles overlap?

Clojure, 68 bytes #(<(+(*(- %4 %)(- %4 %))(*(- %5 %2)(- %5 %2)))(*(+ %6 %3)(+ %6 %3))) Takes six arguments: x1, y1, r1, x2, y2, r2. Returns true or false. Sadly, Clojure does not have a pow functi …
Joshua's user avatar
  • 241
0 votes

Matrix in Range

Clojure, 153 135 bytes List of lists? Yay, Lisp (fn[n](loop[r[] i 0 d (* 2 n)](if(= i n)(conj r(conj(repeat n d)d))(recur(conj r(conj(vec(map #(+ i %)(range 1(inc n))))d))(inc i)d)))) Ungolfed: ( …
Joshua's user avatar
  • 241

15 30 50 per page