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 159

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

7 votes
Accepted

Find one-handed words

sed, 78 bytes 1{x;s/^/! /;x};/^['h-puy]*$/IH;/^[a-gq-tv-xz]*$/I{G;x};${x;y/\n/ /;s/! */\n/p} requires GNU sed, run with sed -n -f words.sed < /usr/share/dict/words
Hasturkun's user avatar
  • 1,254
2 votes

Find one-handed words

Perl, 72 bytes $a{/^['h-puy]+$/i-/^[a-gq-tv-xz]+$/i}.=y/\n/ /rfor<>;print@a{1,-1,$,=$/} run with perl words.pl /usr/share/dict/words
Hasturkun's user avatar
  • 1,254
1 vote

Match up to 10 in an array

SED, 112 chars Probably somewhat simpler than the other solutions s/.*/@&;12345678987654321/ : s/\(@.*\)\(.\)\(.*\)\(.\)\(.*;.*\2.\{7\}\4\)/(\2,\4),\1\3\5/ t s/^\(.*\),@.*/(\1)/
Hasturkun's user avatar
  • 1,254
1 vote

Match up to 10 in an array

Perl, 72 with the -p flag perl -p -e 's/^/@/;1while s/(@.*)(.)(.*)((??{10-$2}))/($2,$4)$1$3/;s/(.*)@.*/($1)/'
Hasturkun's user avatar
  • 1,254
2 votes

Circular shift an arbitrary byte-array bitwise

Sed, 35 bytes :a s/1-\(.\)\(.*\)/-\2\1/ ta s/.// Takes input on stdin, as number of bits to shift by in unary, followed by -, followed by the binary stream, without spaces. e.g. echo 11111-0110000 …
Hasturkun's user avatar
  • 1,254
2 votes

Circular shift an arbitrary byte-array bitwise

Perl, 33 (32 + 1 for -p) 1while(s/1-(.)(.*)/-$2$1/);s/.// Takes input on stdin, as number of bits to shift by in unary, followed by -, followed by the binary stream, without spaces. e.g. echo 1111 …
Hasturkun's user avatar
  • 1,254
2 votes

TUT language translator

GNU Sed, 514 s/$/\n@a!e@b!bub@c!kut@d!dud@e!i@f!fuf@g!jug@h!hash@i!ay@k!kak@l!lul@m!mum@n!nun@o!o@p!pup@q!kwak@r!rud@r!rut@s!sus@t!tut@u!yu@v!vuv@w!waks@x!eks@y!yak@z!zuz/ s/.*\n\(.*\)/&\U\1@/ ta :a s …
Hasturkun's user avatar
  • 1,254
2 votes

Type uniqchars!

SED, 61 bytes s/^/\a/ : s/\a\(\(.\).*\)\2/\a\1/ t s/\a\(.\)/\1\a/ t s/\a//
Hasturkun's user avatar
  • 1,254
3 votes

Langton's ant ASCII art.

sed, 481 chars #n 1{s/.*/_________________/;h;H;H;H;G;G;G;G;s/^\(.\{152\}\)_/\1@/;s/$/;r/;ta;};x;:a;/;r/br;/;d/bd;/;l/bl;/;u/bu;:w;y/rdlu/dlur/;bz;:b;y/rdlu/urdl/;bz;:r;s/@\(.\{17\}\)_/#\1@/;tw;s/@\( …
Hasturkun's user avatar
  • 1,254
16 votes

Shortest code that raises a SIGSEGV

C, 18 main(){raise(11);}
Hasturkun's user avatar
  • 1,254
12 votes
Accepted

string length comparer

SED, 45 (43 + 2 for the -n flag) s/./a/g h n s/./b/g G :a s/b\(.*\)a/\1/ ta Expects input as two separate lines, outputs the difference in unary, using "a" or "b" to indicate the longer string. run …
Hasturkun's user avatar
  • 1,254
4 votes

Sorting a list of strings without using any built-in sort method

SED, 135 s/.*/,&,!,abcdefghijklmnopqrstuvwxyz/;:;s/\(,\([^,]*\)\(.\)[^,]*\)\(.*\)\(,\2\(.\)[^,]*\)\(.*!.*\6.*\3\)/\5\1\4\7/;t;s/^,\(.*\),!.*/\1/ Based on my previous sorting entry
Hasturkun's user avatar
  • 1,254
2 votes

Run Length Decoding

GNU SED, 122 + 2 (-r) #n s/.*/\n&\a987654321\v\v\v\v\v\v\v\v\v/ :a s/\n(.)(.)(.*\a.*\2.{9}(.*))/\1\n\4\3/ tb bc :b s/(.)\n\v/\1\1\n/ tb ba :c P Needs to be run with the -r flag May be reduced to 11 …
Hasturkun's user avatar
  • 1,254
5 votes

Implement Oplop

Shell - 116 echo -n $1$2|md5sum|xxd -r -p|base64|sed -re'y!+/!-_!;/^.{0,7}[0-9]/!{s/^([^0-9]*)([0-9]+)/\2\1/;t;s/^/1/}'|cut -c-8 Depends on cut, md5sum and base64 from coreutils, xxd and GNU sed.
Hasturkun's user avatar
  • 1,254
3 votes

Adding, the old-fashioned way

GNU Sed, 131 chars :;s/M/DD/;s/D/CCCCC/;s/C/LL/;s/L/XXXXX/;s/X/VV/;s/V/IIIII/;t;s/\W//g;:b;s/IIIII/V/;s/VV/X/;s/XXXXX/L/;s/LL/C/;s/CCCCC/D/;s/DD/M/;tb
Hasturkun's user avatar
  • 1,254

15 30 50 per page