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 3396

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

1 vote

Phone Multi-tap Spelling

CoffeeScript - 202 (210 - 8) t9=(s)-> t=[3,3,3,3,3,4,3,4];l=-1;r="" for c in s n="";d=c.charCodeAt(0)-96 if c is ' ' n=0 else((n+=k+2 for x in[0...d];break …
TimWolla's user avatar
  • 1,950
5 votes

Do We Sink or Swim?

CoffeeScript - 128 113 A function that takes the string as the only argument: s=(l)->l=l.split /\n/;[n,m,p]=l[x=0].split /\s/;x+=c|0 for c in r.split /\s/ for r in l[1..n];`p>x?"Sink":"Swim"`
TimWolla's user avatar
  • 1,950
0 votes

Sort characters by darkness

PHP - 485 Demo: $ php pcg-23362.php "@+.0" .+0@ Code: <?php $f='x.ttf';$d=array();foreach(str_split($argv[1]) as$_){$B=imagettfbbox(50,0,$f,$_);$w=abs($B[4]-$B[0]);$h=abs($B[5]-$B[1]);$im=imagecr …
TimWolla's user avatar
  • 1,950
1 vote

Minify Brainfuck

CoffeeScript - 403 397 i=prompt().replace /[^\]\[,.+-><]/g,'' x=(c)-> t={};p=n=0 for d in c t[p]?=0;switch d when'+'then n=1;t[p]++;when'-'then n=1;t[p]--;when'<'then p--;when'>'then p++ (n=0 …
TimWolla's user avatar
  • 1,950
1 vote

How long does it take to paint a stick?

CoffeeScript - 183 247 224 215 207 x=(s,c='')->return 0if !s[0]?;return x s[1..],c if s[0]is c;l=s.length;return x s[1...l],c if s[l-1]is c;i=s.lastIndexOf s[0];1+(x s[1...i],s[0])+x s[i+1..],c y=(z) …
TimWolla's user avatar
  • 1,950
3 votes
Accepted

Brainf**k Debugger

PHP - 1008 <?php $_=trim(fread(STDIN,1e5));$z=$p=0;$t=$l=[];$q='';function s(){global$p,$t,$l,$_,$q,$z;switch($_[$z++]){case'>':$p++;break;case'<':$p--;break;case'+':@$t[$p]++;break;case'-':@$t[$p]-- …
TimWolla's user avatar
  • 1,950
0 votes

Write a Playfair encryption program

CoffeeScript - 610 Demo: [timwolla@/data/workspace/js/PCG]coffee pcg-23276.coffee "Stack Overflow" "The cat crept into the crypt, crapped, and crept out again." SIRACARDFMVUICVSMORDZNAKECMZMFBCYNRDF …
TimWolla's user avatar
  • 1,950
2 votes

Write a Playfair encryption program

Haskell - 711 Demo: [timwolla@/data/workspace/haskell/PCG]ghc pcg-23276.hs [1 of 1] Compiling Main ( pcg-23276.hs, pcg-23276.o ) Linking pcg-23276 ... [timwolla@/data/workspace/haskell/P …
TimWolla's user avatar
  • 1,950
6 votes

Taking the dog for a walk

CoffeeScript - 324 + function call Demo (Using Leash 10): H(0,0) D(0,0) H(0,-1) D(0,3) H(-1,-1) D(0,3) H(-1,-2) D(-1,3) H(-1,-3) D(-4,3) H(-1,-2) D(-4,4) H(-1,-3) D(-5,4) H(-1,-2) D(-2,4) H(-1,-3) D …
TimWolla's user avatar
  • 1,950
3 votes

Write the shortest game of alak

PHP - 505 <?php $s="xxxx___ooo".$y=o;$x=x;$c=function($m)use(&$x){return$x.str_repeat('_',strlen($m[1])).$x;};$e='$s=preg_replace_callback("~$x($y+)$x~",$c,$s);';$_=substr_count;while(true){echo$s;if …
TimWolla's user avatar
  • 1,950
1 vote
Accepted

Create self-extractor script (relaxed rules)

PHP - 141.047.262 45.922.273 13.895.520 13.779.516 My code applies a handcrafted huffmann encoding to the input, see below for an uncompressed and commented version. O: 1145 A: 1901 (42 bytes small …
TimWolla's user avatar
  • 1,950
1 vote

Create a sudoku solution CHECKER

Haskell - 175 import Data.List c=concat m=map q=[1..9] w=length.c.m (\x->(x\\q)++(q\\x)) b x=c.m(take 3.drop(3*mod x 3)).take 3.drop(3*div x 3) v i=sum$m(w)[i,transpose i,[b x i|x<-[0..8]]] The fun …
TimWolla's user avatar
  • 1,950
3 votes

Determine if a number is prime without using arithmetic

PHP - 208 <?php function i($n){if($n==strlen(" "))return!!"";foreach(range(strlen(" "),$n) as$_){if($_!=$n){$a=array_fill(!!"",$n,"");while(count($a)>=$_)array_splice($a,!!"",$_);if(!count($a))retur …
TimWolla's user avatar
  • 1,950
25 votes
3 answers
2k views

Hiding information in Cats

You are a secret agent trying to communicate with your fatherland. Of course the information needs to be hidden so no one eaves drops your message. What would be better suited than a cat? Everyone lov …
TimWolla's user avatar
  • 1,950
35 votes
1 answer
3k views

Minesweeper Solver

We already generated Minesweeper fields, but someone really has to sweep those generated mines before PCG blows up! Your task is to write a Minesweeper Solver that is compatible with a slightly modif …
TimWolla's user avatar
  • 1,950

15 30 50 per page