Created
April 9, 2014 08:39
-
-
Save justecorruptio/10242450 to your computer and use it in GitHub Desktop.
Even smaller 2048 in Perl !!!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub Y{$p=$_;for$i(1..4){$p=join'',map{substr+($k&&$k-$i?$p:join'',map{s/@//g;s | |
/(.)\1/++($a=$1)/eg;$_|'@'x4}$p=~/.{4}/g),3+$_%4*4-($_/4|0),1}0..15}$p}$_='@'x | |
16;for(`stty cbreak`;print"\e[2J\e[H";$_=Y map{$k=index+JDACB,getc}0..2){$k=0; | |
1until$r=0|rand 16,!/@/||s/(?<=^.{$r})@/rand>.1?A:B/e;printf'%4s|%s',/\w/&&1<< | |
(ord)-64,++$g%4?'':$/for/./g;last if$e=WIN x/K/||Y!~/@/&&LOSE}print$e # [2048] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
d