Search Results
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 |
Code-golf is a competition to solve a particular problem in the fewest bytes of source code.
0
votes
The redundant boolean
Clojure, 28 bytes
#(format "%031d" (if % 1 0))
Truthy is everything but nil and false
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
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 …
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 …
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 (. …
1
vote
"DDoouubbllee ssppeeaakk!!"
Clojure, 25 bytes
(fn[s](apply str(map #(str % %)s)))
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 …
0
votes
Sum of all integers from 1 to n
Clojure, 28 bytes
#(apply + (range 1 (inc %)))
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"" " …
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:
( …
0
votes
Randomly select from an array
Clojure, 64 bytes
(defn a[i](rand-nth(reduce #(concat %(take %2(repeat %2)))[]i)))
Appends each item item number of times to a new list, then takes a random element.
Finally a clojure answer that' …
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 …
0
votes
Code Golf: Your own horizontal pet ASCII snake
Clojure, 123 bytes
Here come the parens:
(let[l(take 30(iterate #(max(min(+(-(rand-int 3)1)%)4)0)3))](doseq[y(range 5)](doseq[x l](print(if(= y x)0" ")))(println)))
Ungolfed version:
(let [l (tak …
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 …
0
votes
Read color in my way
Clojure 1.8, 156 bytes
(fn[c o t](reduce #(str %(val %2))""(sort-by key(reduce-kv #(let[s(clojure.string/index-of t(nth o %2))](assoc %(if(contains? % s)(inc s)s)%3)){}(vec c)))))
Ungolfed
(fn [ …