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 30096

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

3 votes

Shortest Longest Increasing Subsequence Code

Clojure, 94 characters Using @Ray's approach of updating results in a 1000-item vector: (defn g[s](apply max(reduce #(assoc % %2(inc(apply max(take %2 %))))(into[](repeat 1e3 0))s))) Per request, wit …
YosemiteMark's user avatar
1 vote

Rank a list of scores with "skips"

Clojure, 35 With some Java interop mixed in: (fn[l](map #(+ 1(.indexOf l %)) l)) REPL session: golf> ((fn[l](map #(+ 1(.indexOf l %)) l)) [10 10 6 6 4 0]) (1 1 3 3 5 6) golf> ((fn[l](map #(+ …
YosemiteMark's user avatar
3 votes

Convert a string of binary characters to the ASCII equivalents

Clojure 63 (or 57) The all-Clojure impl: (apply str(map #(char(read-string(str"2r"%)))(re-seq #"\d+"s))) With Java interop: (apply str(map #(char(Long/parseLong % 2))(.split s" "))) REPL sessio …
YosemiteMark's user avatar
3 votes

Find the closest palindromic number

Clojure, 92 Takes the first from a lazy for-sequence that works from 0 out and only includes values that make palindromes: (defn p[x](first(for[i(range)j[1 -1]k[(* i j)]s[(str(+ x k))]:when(=(seq s) …
YosemiteMark's user avatar
1 vote

Print the alphabet without using each vowel

Clojure: 81 over 2 statements No i, o, or u: 35 chars (apply str(map char(range 97 123))) No a or e: 46 chars (str \u0061"bcd"\u0065"fghijklmnopqrstuvwxyz") REPL (RPL?) session: cd-glf-s-hrd> …
YosemiteMark's user avatar
1 vote

Decompose a permutation into cycles

Clojure, 145 (let[v(vec(repeatedly(read)read))](loop[a(set v)b 0](cond(a(v b))(do(print" "b)(recur(disj a(v b))(v b)))(seq a)(do(prn)(recur a(first a)))1""))) Somewhat ungolfed, and broken out into …
YosemiteMark's user avatar