├── cg ├── pi1.input ├── bf4.input ├── bf4.output ├── cal1.input ├── cal2.input ├── cal3.input ├── cal4.input ├── grid1.output ├── grid2.output ├── grid3.output ├── grid4.output ├── poly3.output ├── poly6.output ├── queen1.output ├── queen2.output ├── queen3.output ├── queen4.output ├── roman3.input ├── roman5.input ├── sha3.input ├── poly1.output ├── primefactor1.input ├── primefactor2.input ├── range1.output ├── roman1.input ├── roman1.output ├── roman2.input ├── roman2.output ├── roman3.output ├── roman4.input ├── roman4.output ├── roman5.output ├── roman6.output ├── roman7.input ├── roman7.output ├── roman8.input ├── roman8.output ├── roman9.output ├── spiral1.input ├── spiral2.input ├── spiral3.input ├── spiral4.input ├── spiral5.input ├── spiral6.input ├── total1.output ├── bf1.output ├── life1.output ├── poly2.output ├── poly4.output ├── poly5.output ├── primefactor3.input ├── range1.input ├── roman6.input ├── roman9.input ├── seven1.input ├── seven2.input ├── switch1.output ├── switch2.output ├── switch3.output ├── switch4.output ├── poly10.output ├── poly8.output ├── primefactor1.output ├── primefactor2.output ├── primefactor3.output ├── primefactor4.input ├── picross1.output ├── poly9.output ├── bf2.output ├── poly7.output ├── bf7.output ├── cross1.input ├── cross2.input ├── life7.input ├── bf6.output ├── cipher1.output ├── crossword1.input ├── crossword2.input ├── poly6.input ├── primefactor4.output ├── picross1.input ├── poly3.input ├── poly5.input ├── cipher1.input ├── life4.input ├── sha4.input ├── bf5.input ├── poly1.input ├── sha1.output ├── sha2.output ├── sha3.output ├── sha4.output ├── poly10.input ├── life5.output ├── life5.input ├── life6.input ├── poly2.input ├── poly4.input ├── switch1.input ├── life7.output ├── cross3.input ├── queen1.input ├── queen2.input ├── queen3.input ├── queen4.input ├── crossword4.input ├── spiral1.output ├── poly8.input ├── switch2.input ├── life1.input ├── life2.output ├── life3.output ├── picross3.output ├── aa3.output ├── poly7.input ├── poly9.input ├── life3.input ├── bf1.input ├── bf2.input ├── picross3.input ├── switch3.input ├── bf3.input ├── picross4.output ├── life6.output ├── life4.output ├── switch4.input ├── cross4.input ├── picross2.output ├── crossword3.input ├── aa4.output ├── life2.input ├── picross4.input ├── cross1.output ├── cross2.output ├── grid1.input ├── grid2.input ├── grid3.input ├── grid4.input ├── picross2.input ├── crossword1.output ├── crossword2.output ├── spiral5.output ├── spiral3.output ├── spiral4.output ├── aa2.output ├── spiral2.output ├── aa3.input ├── aa1.output ├── seven2.output ├── seven1.output ├── bf7.input ├── bf6.input ├── cross3.output ├── crossword4.output ├── range2.output ├── bf5.output ├── sha1.input ├── pi1.output ├── sha2.input ├── bf3.output ├── range2.input ├── aa4.input ├── aa2.input ├── cal3.output ├── cal2.output ├── cal1.output ├── cal4.output ├── aa1.input ├── spiral6.output ├── pascal1.output ├── cross4.output ├── crossword3.output ├── total1.input └── bottle1.output ├── executors ├── _curry ├── a+ ├── bf ├── js ├── l ├── lua ├── m4 ├── rb ├── sh ├── st ├── _c ├── _cpp ├── _m ├── _pas ├── _s ├── awk ├── bas ├── bash ├── clj ├── cr ├── exe ├── fal ├── io ├── lazy ├── ly ├── mk ├── ml ├── ms ├── pef ├── php ├── py ├── py3 ├── scm ├── sed ├── tcl ├── unl ├── wr ├── ws ├── z8b ├── _f95 ├── _hs ├── _rs ├── cs ├── for ├── grb ├── groovy ├── mind ├── xgawk ├── xtal ├── _d ├── pro ├── gs ├── pl ├── r ├── rs ├── scala ├── vhdl ├── _adb ├── _cob ├── _cs ├── bc ├── dc ├── pl6 ├── _erl ├── ps ├── _mind ├── vsm ├── _vhdl ├── c ├── d ├── m ├── s ├── adb ├── cob ├── cpp ├── curry ├── di ├── f95 ├── go ├── java ├── pas ├── vi ├── _java ├── bef ├── out ├── hs ├── ijs ├── erl ├── _go └── run_mncore2.rb ├── squeezer ├── bf.rb ├── bc.rb ├── dc.rb ├── py.rb ├── py3.rb ├── hs.rb ├── gs.rb ├── scala.rb ├── sed.rb ├── sh.rb ├── ml.rb ├── cpp.rb ├── cs.rb ├── d.rb ├── wake.rb ├── grb.rb ├── go.rb ├── c.rb ├── cc.rb ├── js.rb ├── rs.rb ├── pl.rb ├── rb.rb └── rb2.rb ├── sample ├── cipher.test ├── primefactor.test ├── roman.test ├── queen.test ├── switch.test ├── pi.test ├── seven.test ├── poly.test ├── grid.test ├── picross.test ├── range.test ├── life.test ├── sha.test ├── pascal.test ├── total.test ├── bf.test ├── spiral.test ├── cross.test ├── crossword.test ├── cal.test └── aa.test ├── mkpack ├── conv_cg.rb ├── config.rb ├── update_executors.sh ├── ed.rb ├── install_apt.rb ├── net └── http │ └── multipart.rb ├── cases.rb ├── squeeze.rb ├── execute.rb ├── db.rb ├── README ├── submit.rb └── caddy.rb /cg/pi1.input: -------------------------------------------------------------------------------- 1 | _ 2 | -------------------------------------------------------------------------------- /cg/bf4.input: -------------------------------------------------------------------------------- 1 | ,.!a 2 | -------------------------------------------------------------------------------- /cg/bf4.output: -------------------------------------------------------------------------------- 1 | a 2 | -------------------------------------------------------------------------------- /cg/cal1.input: -------------------------------------------------------------------------------- 1 | 1900 2 | -------------------------------------------------------------------------------- /cg/cal2.input: -------------------------------------------------------------------------------- 1 | 2000 2 | -------------------------------------------------------------------------------- /cg/cal3.input: -------------------------------------------------------------------------------- 1 | 2399 2 | -------------------------------------------------------------------------------- /cg/cal4.input: -------------------------------------------------------------------------------- 1 | 1753 2 | -------------------------------------------------------------------------------- /cg/grid1.output: -------------------------------------------------------------------------------- 1 | 615 2 | -------------------------------------------------------------------------------- /cg/grid2.output: -------------------------------------------------------------------------------- 1 | 644 2 | -------------------------------------------------------------------------------- /cg/grid3.output: -------------------------------------------------------------------------------- 1 | 647 2 | -------------------------------------------------------------------------------- /cg/grid4.output: -------------------------------------------------------------------------------- 1 | 625 2 | -------------------------------------------------------------------------------- /cg/poly3.output: -------------------------------------------------------------------------------- 1 | x+1 2 | -------------------------------------------------------------------------------- /cg/poly6.output: -------------------------------------------------------------------------------- 1 | -7 2 | -------------------------------------------------------------------------------- /cg/queen1.output: -------------------------------------------------------------------------------- 1 | 21 2 | -------------------------------------------------------------------------------- /cg/queen2.output: -------------------------------------------------------------------------------- 1 | 40 2 | -------------------------------------------------------------------------------- /cg/queen3.output: -------------------------------------------------------------------------------- 1 | 69 2 | -------------------------------------------------------------------------------- /cg/queen4.output: -------------------------------------------------------------------------------- 1 | 97 2 | -------------------------------------------------------------------------------- /cg/roman3.input: -------------------------------------------------------------------------------- 1 | M 2 | -------------------------------------------------------------------------------- /cg/roman5.input: -------------------------------------------------------------------------------- 1 | MMD 2 | -------------------------------------------------------------------------------- /cg/sha3.input: -------------------------------------------------------------------------------- 1 | abc 2 | -------------------------------------------------------------------------------- /cg/poly1.output: -------------------------------------------------------------------------------- 1 | -x^3-x-2 2 | -------------------------------------------------------------------------------- /cg/primefactor1.input: -------------------------------------------------------------------------------- 1 | 64 2 | -------------------------------------------------------------------------------- /cg/primefactor2.input: -------------------------------------------------------------------------------- 1 | 39 2 | -------------------------------------------------------------------------------- /cg/range1.output: -------------------------------------------------------------------------------- 1 | 1-7. 2 | -------------------------------------------------------------------------------- /cg/roman1.input: -------------------------------------------------------------------------------- 1 | MMMCCXC 2 | -------------------------------------------------------------------------------- /cg/roman1.output: -------------------------------------------------------------------------------- 1 | 3290 2 | -------------------------------------------------------------------------------- /cg/roman2.input: -------------------------------------------------------------------------------- 1 | MCMVII 2 | -------------------------------------------------------------------------------- /cg/roman2.output: -------------------------------------------------------------------------------- 1 | 1907 2 | -------------------------------------------------------------------------------- /cg/roman3.output: -------------------------------------------------------------------------------- 1 | 1000 2 | -------------------------------------------------------------------------------- /cg/roman4.input: -------------------------------------------------------------------------------- 1 | DCLI 2 | -------------------------------------------------------------------------------- /cg/roman4.output: -------------------------------------------------------------------------------- 1 | 651 2 | -------------------------------------------------------------------------------- /cg/roman5.output: -------------------------------------------------------------------------------- 1 | 2500 2 | -------------------------------------------------------------------------------- /cg/roman6.output: -------------------------------------------------------------------------------- 1 | 2984 2 | -------------------------------------------------------------------------------- /cg/roman7.input: -------------------------------------------------------------------------------- 1 | MCMIV 2 | -------------------------------------------------------------------------------- /cg/roman7.output: -------------------------------------------------------------------------------- 1 | 1904 2 | -------------------------------------------------------------------------------- /cg/roman8.input: -------------------------------------------------------------------------------- 1 | MMDLXXIX 2 | -------------------------------------------------------------------------------- /cg/roman8.output: -------------------------------------------------------------------------------- 1 | 2579 2 | -------------------------------------------------------------------------------- /cg/roman9.output: -------------------------------------------------------------------------------- 1 | 2799 2 | -------------------------------------------------------------------------------- /cg/spiral1.input: -------------------------------------------------------------------------------- 1 | 11 3 2 | -------------------------------------------------------------------------------- /cg/spiral2.input: -------------------------------------------------------------------------------- 1 | 11 10 2 | -------------------------------------------------------------------------------- /cg/spiral3.input: -------------------------------------------------------------------------------- 1 | 10 9 2 | -------------------------------------------------------------------------------- /cg/spiral4.input: -------------------------------------------------------------------------------- 1 | 10 10 2 | -------------------------------------------------------------------------------- /cg/spiral5.input: -------------------------------------------------------------------------------- 1 | 10 8 2 | -------------------------------------------------------------------------------- /cg/spiral6.input: -------------------------------------------------------------------------------- 1 | 29 23 2 | -------------------------------------------------------------------------------- /cg/total1.output: -------------------------------------------------------------------------------- 1 | 3682 2 | -------------------------------------------------------------------------------- /cg/bf1.output: -------------------------------------------------------------------------------- 1 | Hello world! 2 | -------------------------------------------------------------------------------- /cg/life1.output: -------------------------------------------------------------------------------- 1 | o 2 | o 3 | o 4 | -------------------------------------------------------------------------------- /cg/poly2.output: -------------------------------------------------------------------------------- 1 | -3*x^2+2*x-1 2 | -------------------------------------------------------------------------------- /cg/poly4.output: -------------------------------------------------------------------------------- 1 | x^2-2*x+3 2 | -------------------------------------------------------------------------------- /cg/poly5.output: -------------------------------------------------------------------------------- 1 | x^2-9*x-27 2 | -------------------------------------------------------------------------------- /cg/primefactor3.input: -------------------------------------------------------------------------------- 1 | 313 2 | -------------------------------------------------------------------------------- /cg/range1.input: -------------------------------------------------------------------------------- 1 | 1 2 3 4 5 6 7 2 | -------------------------------------------------------------------------------- /cg/roman6.input: -------------------------------------------------------------------------------- 1 | MMCMLXXXIV 2 | -------------------------------------------------------------------------------- /cg/roman9.input: -------------------------------------------------------------------------------- 1 | MMDCCXCIX 2 | -------------------------------------------------------------------------------- /cg/seven1.input: -------------------------------------------------------------------------------- 1 | 0123456789 2 | -------------------------------------------------------------------------------- /cg/seven2.input: -------------------------------------------------------------------------------- 1 | 841873420 2 | -------------------------------------------------------------------------------- /cg/switch1.output: -------------------------------------------------------------------------------- 1 | B D A C 2 | -------------------------------------------------------------------------------- /cg/switch2.output: -------------------------------------------------------------------------------- 1 | D A C F B E 2 | -------------------------------------------------------------------------------- /cg/switch3.output: -------------------------------------------------------------------------------- 1 | B D C A E 2 | -------------------------------------------------------------------------------- /cg/switch4.output: -------------------------------------------------------------------------------- 1 | E C B D A 2 | -------------------------------------------------------------------------------- /cg/poly10.output: -------------------------------------------------------------------------------- 1 | 3*x^3+x^2-9*x-27 2 | -------------------------------------------------------------------------------- /cg/poly8.output: -------------------------------------------------------------------------------- 1 | -4*x^47+9*x^26 2 | -------------------------------------------------------------------------------- /cg/primefactor1.output: -------------------------------------------------------------------------------- 1 | 64: 2^6 2 | -------------------------------------------------------------------------------- /cg/primefactor2.output: -------------------------------------------------------------------------------- 1 | 39: 3 13 2 | -------------------------------------------------------------------------------- /cg/primefactor3.output: -------------------------------------------------------------------------------- 1 | 313: 313 2 | -------------------------------------------------------------------------------- /cg/primefactor4.input: -------------------------------------------------------------------------------- 1 | 4294967295 2 | -------------------------------------------------------------------------------- /cg/picross1.output: -------------------------------------------------------------------------------- 1 | X 2 | X 3 | XXX 4 | -------------------------------------------------------------------------------- /cg/poly9.output: -------------------------------------------------------------------------------- 1 | 11*x^50+12*x^34-3*x^16 2 | -------------------------------------------------------------------------------- /executors/_curry: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cyc $1 3 | -------------------------------------------------------------------------------- /executors/a+: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | a+ -q $1 3 | -------------------------------------------------------------------------------- /executors/bf: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec beef $1 3 | -------------------------------------------------------------------------------- /executors/js: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec smjs $1 3 | -------------------------------------------------------------------------------- /executors/l: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec clisp $1 3 | -------------------------------------------------------------------------------- /executors/lua: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec lua $1 3 | -------------------------------------------------------------------------------- /executors/m4: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec m4 $1 3 | -------------------------------------------------------------------------------- /executors/rb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec ruby $1 3 | -------------------------------------------------------------------------------- /executors/sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec bash $1 3 | -------------------------------------------------------------------------------- /executors/st: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec gst $1 3 | -------------------------------------------------------------------------------- /cg/bf2.output: -------------------------------------------------------------------------------- 1 | Just another brainfuck hacker. 2 | -------------------------------------------------------------------------------- /cg/poly7.output: -------------------------------------------------------------------------------- 1 | -11*x^15+17*x^13+10*x^12 2 | -------------------------------------------------------------------------------- /executors/_c: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | gcc -g -O -lm $1 3 | -------------------------------------------------------------------------------- /executors/_cpp: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | g++ -g -O $1 3 | -------------------------------------------------------------------------------- /executors/_m: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | gcc -g -O -lm $1 3 | -------------------------------------------------------------------------------- /executors/_pas: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | gpc -g -O $1 3 | -------------------------------------------------------------------------------- /executors/_s: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | gcc -g -lm $1 3 | -------------------------------------------------------------------------------- /executors/awk: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec mawk -f $1 3 | -------------------------------------------------------------------------------- /executors/bas: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec yabasic $1 3 | -------------------------------------------------------------------------------- /executors/bash: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec bash $1 3 | -------------------------------------------------------------------------------- /executors/clj: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec clojure $1 3 | -------------------------------------------------------------------------------- /executors/cr: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec crystal $1 3 | -------------------------------------------------------------------------------- /executors/exe: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec wine ./$1 3 | -------------------------------------------------------------------------------- /executors/fal: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec falcon $1 3 | -------------------------------------------------------------------------------- /executors/io: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec io_static $1 3 | -------------------------------------------------------------------------------- /executors/lazy: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec lazyk $1 3 | -------------------------------------------------------------------------------- /executors/ly: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec lilypond $1 3 | -------------------------------------------------------------------------------- /executors/mk: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec make -f $1 3 | -------------------------------------------------------------------------------- /executors/ml: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec ocaml $1 3 | -------------------------------------------------------------------------------- /executors/ms: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec minus $1 3 | -------------------------------------------------------------------------------- /executors/pef: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec 2dpi.rb $1 3 | -------------------------------------------------------------------------------- /executors/php: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec php5 $1 3 | -------------------------------------------------------------------------------- /executors/py: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec python $1 3 | -------------------------------------------------------------------------------- /executors/py3: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec python3 $1 3 | -------------------------------------------------------------------------------- /executors/scm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec gosh $1 3 | -------------------------------------------------------------------------------- /executors/sed: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec sed -f $1 3 | -------------------------------------------------------------------------------- /executors/tcl: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec tclsh $1 3 | -------------------------------------------------------------------------------- /executors/unl: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec unlambda $1 3 | -------------------------------------------------------------------------------- /executors/wr: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec whirl $1 3 | -------------------------------------------------------------------------------- /executors/ws: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec wspace $1 3 | -------------------------------------------------------------------------------- /executors/z8b: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec z80golf $1 3 | -------------------------------------------------------------------------------- /cg/bf7.output: -------------------------------------------------------------------------------- 1 | xrggyrklybcubarebnfgfebnfgfebnfgf 2 | -------------------------------------------------------------------------------- /cg/cross1.input: -------------------------------------------------------------------------------- 1 | ____ 2 | ____ 3 | ____ 4 | ____ 5 | -------------------------------------------------------------------------------- /cg/cross2.input: -------------------------------------------------------------------------------- 1 | ____ 2 | _XX_ 3 | _XX_ 4 | ____ 5 | -------------------------------------------------------------------------------- /cg/life7.input: -------------------------------------------------------------------------------- 1 | 99 2 | o 3 | oo 4 | o ooo 5 | -------------------------------------------------------------------------------- /executors/_f95: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | gfortran -g -O $1 3 | -------------------------------------------------------------------------------- /executors/_hs: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ghc -O -o a.out $1 3 | -------------------------------------------------------------------------------- /executors/_rs: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | rustc $1 -o a.out 3 | -------------------------------------------------------------------------------- /executors/cs: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec mono a.out 3 | 4 | -------------------------------------------------------------------------------- /executors/for: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec gforth $1 -e bye 3 | -------------------------------------------------------------------------------- /executors/grb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec goruby1.9 $1 3 | -------------------------------------------------------------------------------- /executors/groovy: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec groovy $1 3 | -------------------------------------------------------------------------------- /executors/mind: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec kernel test 3 | -------------------------------------------------------------------------------- /executors/xgawk: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec xgawk -f $1 3 | -------------------------------------------------------------------------------- /executors/xtal: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec xtal.exe $1 3 | -------------------------------------------------------------------------------- /squeezer/bf.rb: -------------------------------------------------------------------------------- 1 | @src.gsub!(/[^\-+,\.\[\]<>]/,'') 2 | -------------------------------------------------------------------------------- /cg/bf6.output: -------------------------------------------------------------------------------- 1 | qvaareabirzoreybphfgfryrcunagwnahnel 2 | -------------------------------------------------------------------------------- /cg/cipher1.output: -------------------------------------------------------------------------------- 1 | VNVUSEHXVXZYMMPITGMLPIBHHVGSVRHQR 2 | -------------------------------------------------------------------------------- /cg/crossword1.input: -------------------------------------------------------------------------------- 1 | ____ 2 | ____ 3 | ____ 4 | ____ 5 | -------------------------------------------------------------------------------- /cg/crossword2.input: -------------------------------------------------------------------------------- 1 | ___ 2 | _XX_ 3 | _XX_ 4 | ____ 5 | -------------------------------------------------------------------------------- /cg/poly6.input: -------------------------------------------------------------------------------- 1 | -35*x^2-7 2 | --------- 3 | 5*x^2+1 4 | -------------------------------------------------------------------------------- /cg/primefactor4.output: -------------------------------------------------------------------------------- 1 | 4294967295: 3 5 17 257 65537 2 | -------------------------------------------------------------------------------- /executors/_d: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | dmd -g -O -ofa.out $1 3 | 4 | -------------------------------------------------------------------------------- /executors/pro: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec swipl -t m -q -s $1 3 | -------------------------------------------------------------------------------- /cg/picross1.input: -------------------------------------------------------------------------------- 1 | 1 2 | 1 3 | 3 4 | - 5 | 1 6 | 1.1 7 | 2 8 | -------------------------------------------------------------------------------- /cg/poly3.input: -------------------------------------------------------------------------------- 1 | x^4-1 2 | ----------- 3 | x^3-x^2+x-1 4 | -------------------------------------------------------------------------------- /cg/poly5.input: -------------------------------------------------------------------------------- 1 | x^3-12*x^2+81 2 | ------------- 3 | x-3 4 | -------------------------------------------------------------------------------- /executors/gs: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec ruby1.9 golfscript.rb $1 3 | -------------------------------------------------------------------------------- /executors/pl: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # export LANG=C 3 | exec perl $1 4 | -------------------------------------------------------------------------------- /executors/r: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec Rscript --vanilla --slave $1 3 | -------------------------------------------------------------------------------- /executors/rs: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | export LANG=C 3 | exec ./a.out 4 | -------------------------------------------------------------------------------- /executors/scala: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec scala -nocompdaemon $1 3 | -------------------------------------------------------------------------------- /executors/vhdl: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ./`basename $2 .vhdl` 3 | 4 | -------------------------------------------------------------------------------- /squeezer/bc.rb: -------------------------------------------------------------------------------- 1 | sharp 2 | blank 3 | trailing_ws 4 | last_ws 5 | -------------------------------------------------------------------------------- /squeezer/dc.rb: -------------------------------------------------------------------------------- 1 | sharp 2 | blank 3 | trailing_ws 4 | last_ws 5 | -------------------------------------------------------------------------------- /squeezer/py.rb: -------------------------------------------------------------------------------- 1 | sharp 2 | blank 3 | trailing_ws 4 | last_ws 5 | -------------------------------------------------------------------------------- /squeezer/py3.rb: -------------------------------------------------------------------------------- 1 | sharp 2 | blank 3 | trailing_ws 4 | last_ws 5 | -------------------------------------------------------------------------------- /cg/cipher1.input: -------------------------------------------------------------------------------- 1 | PNEUMATIC 2 | GARAGEOPTIMUSAPPLEXYLOPHONEDINNER 3 | -------------------------------------------------------------------------------- /cg/life4.input: -------------------------------------------------------------------------------- 1 | 30 2 | ooo o 3 | o 4 | oo 5 | oo o 6 | o o o 7 | -------------------------------------------------------------------------------- /executors/_adb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | gnat make -gnat05 -g -O $1 -o a.out 3 | -------------------------------------------------------------------------------- /executors/_cob: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cobc -x -g -debug -free $1 -o a.out 3 | -------------------------------------------------------------------------------- /executors/_cs: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | mcs $1 -out:a.out -optimize 3 | 4 | -------------------------------------------------------------------------------- /executors/bc: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | BC_LINE_LENGTH=9999 exec bc -lq $1 3 | -------------------------------------------------------------------------------- /executors/dc: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | DC_LINE_LENGTH=9999 exec dc -f $1 3 | -------------------------------------------------------------------------------- /executors/pl6: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # export LANG=C 3 | exec perl6 $1 4 | -------------------------------------------------------------------------------- /squeezer/hs.rb: -------------------------------------------------------------------------------- 1 | hs 2 | leading_ws 3 | trailing_ws 4 | last_ws 5 | -------------------------------------------------------------------------------- /cg/sha4.input: -------------------------------------------------------------------------------- 1 | abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq 2 | -------------------------------------------------------------------------------- /executors/_erl: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # export HOME=/home/golf 3 | erl -compile $1 4 | -------------------------------------------------------------------------------- /executors/ps: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec gs -q -dNODISPLAY -dBATCH -dNOPAUSE $1 3 | -------------------------------------------------------------------------------- /squeezer/gs.rb: -------------------------------------------------------------------------------- 1 | sharp 2 | blank 3 | leading_ws 4 | trailing_ws 5 | last_ws 6 | -------------------------------------------------------------------------------- /squeezer/scala.rb: -------------------------------------------------------------------------------- 1 | c99 2 | blank 3 | leading_ws 4 | trailing_ws 5 | last_ws 6 | -------------------------------------------------------------------------------- /squeezer/sed.rb: -------------------------------------------------------------------------------- 1 | sharp 2 | blank 3 | leading_ws 4 | trailing_ws 5 | last_ws 6 | -------------------------------------------------------------------------------- /squeezer/sh.rb: -------------------------------------------------------------------------------- 1 | sharp 2 | blank 3 | leading_ws 4 | trailing_ws 5 | last_ws 6 | -------------------------------------------------------------------------------- /cg/bf5.input: -------------------------------------------------------------------------------- 1 | ,[>>++++++[-<+++++++>]<+<[->.<]>+++.<++++[->++++<]>.>,]!optimus 2 | -------------------------------------------------------------------------------- /cg/poly1.input: -------------------------------------------------------------------------------- 1 | -x^5+x^4-3*x^3-x^2-4 2 | -------------------- 3 | x^2-x+2 4 | -------------------------------------------------------------------------------- /cg/sha1.output: -------------------------------------------------------------------------------- 1 | 6ab072e182a2cd21d0d2f644ce19219f47a021802abef342a3cf126c812086e7 2 | -------------------------------------------------------------------------------- /cg/sha2.output: -------------------------------------------------------------------------------- 1 | dabe4ad2e8e13263662b3f9ac30ade7f176ff7cf1efe1afc1fa4d9a21a9976fa 2 | -------------------------------------------------------------------------------- /cg/sha3.output: -------------------------------------------------------------------------------- 1 | ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad 2 | -------------------------------------------------------------------------------- /cg/sha4.output: -------------------------------------------------------------------------------- 1 | 248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1 2 | -------------------------------------------------------------------------------- /executors/_mind: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | nkf -e $1 > test.src 3 | mind test file | nkf 4 | -------------------------------------------------------------------------------- /cg/poly10.input: -------------------------------------------------------------------------------- 1 | 3*x^4-8*x^3-12*x^2+81 2 | --------------------- 3 | x-3 4 | -------------------------------------------------------------------------------- /executors/vsm: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "$0")" 4 | exec ./run_mncore2.rb $1 5 | -------------------------------------------------------------------------------- /cg/life5.output: -------------------------------------------------------------------------------- 1 | o 2 | oo 3 | o o 4 | 5 | 6 | 7 | ooo 8 | o 9 | o 10 | -------------------------------------------------------------------------------- /cg/life5.input: -------------------------------------------------------------------------------- 1 | 201 2 | ooo 3 | o 4 | o 5 | 6 | 7 | oo 8 | oo 9 | o 10 | -------------------------------------------------------------------------------- /cg/life6.input: -------------------------------------------------------------------------------- 1 | 100 2 | oooo 3 | o o 4 | o 5 | o o 6 | 7 | 8 | oo 9 | oo 10 | -------------------------------------------------------------------------------- /cg/poly2.input: -------------------------------------------------------------------------------- 1 | -6*x^4-8*x^3+3*x^2-2*x-1 2 | ------------------------ 3 | 2*x^2+4*x+1 4 | -------------------------------------------------------------------------------- /executors/_vhdl: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | mv $1 $2 3 | ghdl -a $2 4 | ghdl -e `basename $2 .vhdl` 5 | 6 | -------------------------------------------------------------------------------- /executors/c: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # export LD_PRELOAD=$LD_PRELOAD:/lib/libSegFault.so 3 | exec ./a.out 4 | -------------------------------------------------------------------------------- /executors/d: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # export LD_PRELOAD=$LD_PRELOAD:/lib/libSegFault.so 3 | exec ./a.out 4 | -------------------------------------------------------------------------------- /executors/m: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # export LD_PRELOAD=$LD_PRELOAD:/lib/libSegFault.so 3 | exec ./a.out 4 | -------------------------------------------------------------------------------- /executors/s: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # export LD_PRELOAD=$LD_PRELOAD:/lib/libSegFault.so 3 | exec ./a.out 4 | -------------------------------------------------------------------------------- /squeezer/ml.rb: -------------------------------------------------------------------------------- 1 | caml 2 | blank 3 | leading_ws 4 | trailing_ws 5 | last_ws 6 | any_ret(';;') 7 | -------------------------------------------------------------------------------- /cg/poly4.input: -------------------------------------------------------------------------------- 1 | -x^5+5*x^4-11*x^3+10*x^2-9 2 | -------------------------- 3 | -x^3+3*x^2-2*x-3 4 | -------------------------------------------------------------------------------- /cg/switch1.input: -------------------------------------------------------------------------------- 1 | A B C D 2 | | | | | 3 | X | | 4 | | | X 5 | | | | | 6 | | X | 7 | | | | | 8 | -------------------------------------------------------------------------------- /executors/adb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # export LD_PRELOAD=$LD_PRELOAD:/lib/libSegFault.so 3 | exec ./a.out 4 | -------------------------------------------------------------------------------- /executors/cob: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # export LD_PRELOAD=$LD_PRELOAD:/lib/libSegFault.so 3 | exec ./a.out 4 | -------------------------------------------------------------------------------- /executors/cpp: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # export LD_PRELOAD=$LD_PRELOAD:/lib/libSegFault.so 3 | exec ./a.out 4 | -------------------------------------------------------------------------------- /executors/curry: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # export LD_PRELOAD=$LD_PRELOAD:/lib/libSegFault.so 3 | exec ./a.out 4 | -------------------------------------------------------------------------------- /executors/di: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | b=`basename $1 .di` 3 | mv $1 $b.d 4 | exec dmd -c -ofa.out $b.d 5 | 6 | -------------------------------------------------------------------------------- /executors/f95: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # export LD_PRELOAD=$LD_PRELOAD:/lib/libSegFault.so 3 | exec ./a.out 4 | -------------------------------------------------------------------------------- /executors/go: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # export LD_PRELOAD=$LD_PRELOAD:/lib/libSegFault.so 3 | exec ./a.out 4 | -------------------------------------------------------------------------------- /executors/java: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # export LD_PRELOAD=$LD_PRELOAD:/lib/libSegFault.so 3 | exec ./a.out 4 | -------------------------------------------------------------------------------- /executors/pas: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # export LD_PRELOAD=$LD_PRELOAD:/lib/libSegFault.so 3 | exec ./a.out 4 | -------------------------------------------------------------------------------- /executors/vi: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cat > /tmp/out 3 | vi -s $1 /tmp/out > /dev/null 2>&1 4 | cat /tmp/out 5 | -------------------------------------------------------------------------------- /executors/_java: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | m=`basename $2 .java` 3 | mv $1 $m.java 4 | gcj --main=$m -g -O $m.java 5 | -------------------------------------------------------------------------------- /executors/bef: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # export LD_PRELOAD=$LD_PRELOAD:/lib/libSegFault.so 3 | exec befunge -i -q $1 4 | -------------------------------------------------------------------------------- /cg/life7.output: -------------------------------------------------------------------------------- 1 | o 2 | o 3 | ooo ooo 4 | o o o 5 | o o 6 | o ooo 7 | o o 8 | o o 9 | -------------------------------------------------------------------------------- /executors/out: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # export LD_PRELOAD=$LD_PRELOAD:/lib/libSegFault.so 3 | chmod 755 $1 4 | exec ./$1 5 | -------------------------------------------------------------------------------- /squeezer/cpp.rb: -------------------------------------------------------------------------------- 1 | c99 2 | blank 3 | leading_ws 4 | trailing_ws 5 | last_ws 6 | cond_ret 7 | bracket_ret 8 | semi_ret 9 | -------------------------------------------------------------------------------- /squeezer/cs.rb: -------------------------------------------------------------------------------- 1 | c99 2 | blank 3 | leading_ws 4 | trailing_ws 5 | last_ws 6 | cond_ret 7 | bracket_ret 8 | semi_ret 9 | -------------------------------------------------------------------------------- /squeezer/d.rb: -------------------------------------------------------------------------------- 1 | d 2 | blank 3 | leading_ws 4 | trailing_ws 5 | last_ws 6 | cond_ret 7 | bracket_ret 8 | semi_ret 9 | -------------------------------------------------------------------------------- /cg/cross3.input: -------------------------------------------------------------------------------- 1 | X _ _ _ _ X X 2 | _ _ X _ _ _ _ 3 | _ _ _ _ X _ _ 4 | _ X _ _ X X X 5 | _ _ _ X _ _ _ 6 | X _ _ _ _ _ X 7 | -------------------------------------------------------------------------------- /cg/queen1.input: -------------------------------------------------------------------------------- 1 | Q_______ 2 | ________ 3 | ________ 4 | ________ 5 | ________ 6 | ________ 7 | ________ 8 | ________ 9 | -------------------------------------------------------------------------------- /cg/queen2.input: -------------------------------------------------------------------------------- 1 | _______Q 2 | ________ 3 | ________ 4 | ________ 5 | ________ 6 | ________ 7 | ________ 8 | Q_______ 9 | -------------------------------------------------------------------------------- /cg/queen3.input: -------------------------------------------------------------------------------- 1 | __QQ____ 2 | ________ 3 | ________ 4 | ________ 5 | ___Q____ 6 | __Q_____ 7 | ________ 8 | ________ 9 | -------------------------------------------------------------------------------- /cg/queen4.input: -------------------------------------------------------------------------------- 1 | _Q______ 2 | _____Q__ 3 | ________ 4 | ________ 5 | ________ 6 | __Q__Q__ 7 | ________ 8 | _______Q 9 | -------------------------------------------------------------------------------- /executors/hs: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # export LD_PRELOAD=$LD_PRELOAD:/lib/libSegFault.so 3 | # export LANG=C 4 | exec ./a.out 5 | -------------------------------------------------------------------------------- /cg/crossword4.input: -------------------------------------------------------------------------------- 1 | X _ _ _ _ X X 2 | _ _ X _ _ _ _ 3 | _ _ _ _ X _ _ 4 | _ X _ _ X X X 5 | _ _ _ X _ _ _ 6 | X _ _ _ _ _ X 7 | -------------------------------------------------------------------------------- /cg/spiral1.output: -------------------------------------------------------------------------------- 1 | 1 2 3 4 5 6 7 8 9 10 11 2 | 24 25 26 27 28 29 30 31 32 33 12 3 | 23 22 21 20 19 18 17 16 15 14 13 4 | -------------------------------------------------------------------------------- /executors/ijs: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # export HOME=/home/golf 3 | # export LD_LIBRARY_PATH=$HOME/j601 4 | exec $HOME/j601/jconsole $1 5 | -------------------------------------------------------------------------------- /squeezer/wake.rb: -------------------------------------------------------------------------------- 1 | @src.gsub!(/^#(?!include).*/,'') 2 | @src.gsub!(/^(.*?:.*?)\s#.*/,'\1') 3 | blank 4 | trailing_ws 5 | last_ws 6 | -------------------------------------------------------------------------------- /cg/poly8.input: -------------------------------------------------------------------------------- 1 | 72*x^69+44*x^51-190*x^48-99*x^30+63*x^27 2 | ---------------------------------------- 3 | -18*x^22-11*x^4+7*x 4 | -------------------------------------------------------------------------------- /cg/switch2.input: -------------------------------------------------------------------------------- 1 | A B C D E F 2 | | | | | | | 3 | | \|/ X 4 | | X | | 5 | | /|\ | | 6 | | | | | | | 7 | X | X | 8 | | | | | | | 9 | -------------------------------------------------------------------------------- /sample/cipher.test: -------------------------------------------------------------------------------- 1 | PNEUMATIC 2 | GARAGEOPTIMUSAPPLEXYLOPHONEDINNER 3 | 4 | __INPUT__ 5 | VNVUSEHXVXZYMMPITGMLPIBHHVGSVRHQR 6 | __OUTPUT__ 7 | -------------------------------------------------------------------------------- /cg/life1.input: -------------------------------------------------------------------------------- 1 | 24 2 | o o o oo o o 3 | o o 4 | o o o 5 | o o o o 6 | o o o o oo 7 | -------------------------------------------------------------------------------- /cg/life2.output: -------------------------------------------------------------------------------- 1 | oo 2 | oo o o 3 | o o o 4 | oo 5 | 6 | 7 | 8 | 9 | 10 | 11 | oo 12 | oo 13 | -------------------------------------------------------------------------------- /cg/life3.output: -------------------------------------------------------------------------------- 1 | oo 2 | oo 3 | oo 4 | oo 5 | o ooo 6 | o 7 | oo oo 8 | o o 9 | oooooo 10 | o 11 | o o 12 | ooo 13 | -------------------------------------------------------------------------------- /cg/picross3.output: -------------------------------------------------------------------------------- 1 | X X X X 2 | XXX XXX 3 | XX XX X 4 | XXXXX 5 | XXX X X 6 | XX 7 | X X XXX 8 | XX XXX X 9 | XXXXX 10 | XX X X 11 | -------------------------------------------------------------------------------- /executors/erl: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # export HOME=/home/golf 3 | m=`basename $2 .erl` 4 | mv test.beam $m.beam 5 | erl -noshell -s $m m -s erlang halt 6 | 7 | -------------------------------------------------------------------------------- /squeezer/grb.rb: -------------------------------------------------------------------------------- 1 | sharp 2 | blank 3 | leading_ws 4 | trailing_ws 5 | last_ws 6 | cond_ret 7 | bracket_ret 8 | # 5.times{|i|\n 9 | any_ret('|') 10 | -------------------------------------------------------------------------------- /cg/aa3.output: -------------------------------------------------------------------------------- 1 | /\ /\ 2 | ( V | 3 | \ | / 4 | (r r) 5 | ( " ) 6 | / \ 7 | (_m m_) 8 | / \ 9 | _\ _ /_ 10 | (___/*\___) 11 | -------------------------------------------------------------------------------- /squeezer/go.rb: -------------------------------------------------------------------------------- 1 | c99 2 | leading_ws 3 | trailing_ws 4 | blank 5 | last_ws 6 | cond_ret 7 | bracket_ret 8 | #cket_ret 9 | semi_ret 10 | #any_ret(')') 11 | -------------------------------------------------------------------------------- /cg/poly7.input: -------------------------------------------------------------------------------- 1 | 99*x^60-153*x^58-90*x^57+121*x^55-187*x^53-110*x^52 2 | --------------------------------------------------- 3 | -9*x^45-11*x^40 4 | -------------------------------------------------------------------------------- /cg/poly9.input: -------------------------------------------------------------------------------- 1 | -220*x^97-220*x^83-240*x^81-240*x^67+60*x^63+60*x^49 2 | ---------------------------------------------------- 3 | -20*x^47-20*x^33 4 | -------------------------------------------------------------------------------- /executors/_go: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ARCH=8 3 | if [ `uname -m` = "x86_64" ]; then 4 | ARCH=6 5 | fi 6 | "$ARCH"g -o test."$ARCH" $1 && "$ARCH"l -o a.out test."$ARCH" 7 | -------------------------------------------------------------------------------- /squeezer/c.rb: -------------------------------------------------------------------------------- 1 | c99 2 | blank 3 | leading_ws 4 | trailing_ws 5 | last_ws 6 | cond_ret 7 | bracket_ret 8 | cket_ret 9 | semi_ret 10 | any_ret(')') 11 | any_ret(',') 12 | -------------------------------------------------------------------------------- /squeezer/cc.rb: -------------------------------------------------------------------------------- 1 | c99 2 | blank 3 | leading_ws 4 | trailing_ws 5 | last_ws 6 | cond_ret 7 | bracket_ret 8 | cket_ret 9 | semi_ret 10 | any_ret(')') 11 | any_ret(',') 12 | -------------------------------------------------------------------------------- /squeezer/js.rb: -------------------------------------------------------------------------------- 1 | c99 2 | blank 3 | leading_ws 4 | trailing_ws 5 | last_ws 6 | cond_ret 7 | bracket_ret 8 | cket_ret 9 | semi_ret 10 | any_ret(')') 11 | any_ret(',') 12 | -------------------------------------------------------------------------------- /squeezer/rs.rb: -------------------------------------------------------------------------------- 1 | c99 2 | blank 3 | leading_ws 4 | trailing_ws 5 | last_ws 6 | cond_ret 7 | bracket_ret 8 | cket_ret 9 | semi_ret 10 | any_ret(')') 11 | any_ret(',') 12 | -------------------------------------------------------------------------------- /squeezer/pl.rb: -------------------------------------------------------------------------------- 1 | sharp 2 | blank 3 | leading_ws 4 | trailing_ws 5 | last_ws 6 | cond_ret 7 | bracket_ret 8 | semi_ret 9 | @src.gsub!(';}', '}') 10 | @src.sub!(/;\Z/,'') 11 | -------------------------------------------------------------------------------- /squeezer/rb.rb: -------------------------------------------------------------------------------- 1 | sharp 2 | blank 3 | leading_ws 4 | trailing_ws 5 | last_ws 6 | cond_ret 7 | ret_cket 8 | bra_ret 9 | #bracket_ret 10 | # 5.times{|i|\n 11 | any_ret('|') 12 | -------------------------------------------------------------------------------- /squeezer/rb2.rb: -------------------------------------------------------------------------------- 1 | sharp 2 | blank 3 | leading_ws 4 | trailing_ws 5 | last_ws 6 | cond_ret 7 | ret_cket 8 | bra_ret 9 | #bracket_ret 10 | # 5.times{|i|\n 11 | any_ret('|') 12 | -------------------------------------------------------------------------------- /cg/life3.input: -------------------------------------------------------------------------------- 1 | 25 2 | 3 | o o 4 | o 5 | o 6 | o 7 | o 8 | o 9 | o 10 | o 11 | o o 12 | o 13 | o o 14 | o o 15 | 16 | o ooo 17 | o 18 | -------------------------------------------------------------------------------- /cg/bf1.input: -------------------------------------------------------------------------------- 1 | >+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-] 2 | <.>+++++++++++[<++++++++>-]<-.--------.+++.------.--------.[-]>++++++++[<++++>- 3 | ]<+.[-]++++++++++. 4 | -------------------------------------------------------------------------------- /cg/bf2.input: -------------------------------------------------------------------------------- 1 | +++[>+++++<-]>[>+>+++>+>++>+++++>++<[++<]>---]>->-.[>++>+<<--]>--.--.+.>>>++.<< 2 | .<------.+.+++++.>>-.<++++.<--.>>>.<<---.<.-->-.>+.[+++++.---<]>>[.--->]<<.<+.+ 3 | +.++>+++[.<][.]<++. 4 | -------------------------------------------------------------------------------- /cg/picross3.input: -------------------------------------------------------------------------------- 1 | 1.1.1.1 2 | 3.3 3 | 2.2.1 4 | 5 5 | 3.1.1 6 | 2 7 | 1.1.3 8 | 2.3.1 9 | 5 10 | 2.1.1 11 | - 12 | 1.1.1.1 13 | 4.2 14 | 1.2.2 15 | 4.4 16 | 3.2 17 | 2.1.5 18 | 2.3.1 19 | 2.2.1 20 | -------------------------------------------------------------------------------- /cg/switch3.input: -------------------------------------------------------------------------------- 1 | A B C D E 2 | | | | | | 3 | \|/ | | 4 | X X 5 | /|\ | | 6 | | | | | | 7 | | | | | | 8 | X \|/ 9 | | | X 10 | | | /|\ 11 | | | | | | 12 | | X X 13 | | | | | | 14 | -------------------------------------------------------------------------------- /cg/bf3.input: -------------------------------------------------------------------------------- 1 | ++++[>+++++<-]>[<+++++>-]+<+[>[>+>+<<-]++>>[<<+>>-]>>>[-]++>[-]+>>>+[[-]++++++> 2 | >>]<<<[[<++++++++<++>>-]+<.<[>----<-]<]<<[>>>>>[>>>[-]+++++++++<[>-<-]+++++++++ 3 | >[-[<->-]+[<<<]]<[>+<-]>]<<-]<<-] 4 | -------------------------------------------------------------------------------- /mkpack: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -ex 3 | svn ci -m ci 4 | rm -fr caddy 5 | svn export $SVN/gtest caddy > /dev/null 6 | rm -f caddy/mkpack 7 | tar -cvzf caddy.tgz caddy > /dev/null 8 | scp caddy.tgz i@shinh.org:wrk/sag 9 | 10 | -------------------------------------------------------------------------------- /cg/picross4.output: -------------------------------------------------------------------------------- 1 | XXX XXXX XXX XXX 2 | X X X X X X 3 | X X X X X XXX 4 | X X X X X X 5 | XXX XXXX XXX XXX 6 | 7 | XX XXXX X XXX 8 | X X X X X 9 | X XX X X X XXX 10 | X X X X X X 11 | XX XXXX XXX X 12 | -------------------------------------------------------------------------------- /cg/life6.output: -------------------------------------------------------------------------------- 1 | oooo 2 | o o 3 | o 4 | o o 5 | 6 | 7 | oo 8 | oo 9 | -------------------------------------------------------------------------------- /sample/primefactor.test: -------------------------------------------------------------------------------- 1 | 64 2 | 3 | __INPUT__ 4 | 64: 2^6 5 | __OUTPUT__ 6 | 39 7 | 8 | __INPUT__ 9 | 39: 3 13 10 | __OUTPUT__ 11 | 313 12 | 13 | __INPUT__ 14 | 313: 313 15 | __OUTPUT__ 16 | 4294967295 17 | 18 | __INPUT__ 19 | 4294967295: 3 5 17 257 65537 20 | __OUTPUT__ 21 | -------------------------------------------------------------------------------- /cg/life4.output: -------------------------------------------------------------------------------- 1 | o 2 | oo oo 3 | 4 | o 5 | ooo o o 6 | o oo oo 7 | oo o o 8 | oo 9 | o o 10 | ooo ooo 11 | oooo o o o 12 | o oo 13 | ooo oo 14 | oo oo oo 15 | o ooo oo 16 | o oo 17 | oo o o 18 | o o 19 | -------------------------------------------------------------------------------- /cg/switch4.input: -------------------------------------------------------------------------------- 1 | A B C D E 2 | | | | | | 3 | | | | | | 4 | X | X 5 | | | | | | 6 | | | | | | 7 | | | | X 8 | | | | | | 9 | | | | | | 10 | | X X 11 | | | | | | 12 | | | | | | 13 | | | | | | 14 | | | X | 15 | | | | | | 16 | | | | X 17 | \|/ | | 18 | X | | 19 | /|\ | | 20 | | | | | | 21 | -------------------------------------------------------------------------------- /cg/cross4.input: -------------------------------------------------------------------------------- 1 | _______X_______ 2 | _X_X_X_X_X_X_X_ 3 | _____X_________ 4 | _X_X_X_X_X_X_X_ 5 | __________X____ 6 | _X_X_XXX_X_X_X_ 7 | XXX____________ 8 | _X_X_X_X_X_X_X_ 9 | ____________XXX 10 | _X_X_X_XXX_X_X_ 11 | ____X__________ 12 | _X_X_X_X_X_X_X_ 13 | _________X_____ 14 | _X_X_X_X_X_X_X_ 15 | _______X_______ 16 | -------------------------------------------------------------------------------- /cg/picross2.output: -------------------------------------------------------------------------------- 1 | XXXXX XXXXX 2 | XXX XXXXX XXX 3 | XX XXXXXXXXX XX 4 | X XX X XX X 5 | X XXXXXXXXXXX X 6 | XXXX X XXXX 7 | XXXX X XXXX 8 | XXXXXXXXXXXXX 9 | XXXXXX XXXXXX 10 | XXXXXXXXXXXXX 11 | X XX XX X 12 | X XXXXXXXXXXX X 13 | XX XXXXXXXXX XX 14 | XXX XXXXX XXX 15 | XXXXX XXXXX 16 | -------------------------------------------------------------------------------- /cg/crossword3.input: -------------------------------------------------------------------------------- 1 | _______X_______ 2 | _X_X_X_X_X_X_X_ 3 | _____X_________ 4 | _X_X_X_X_X_X_X_ 5 | __________X____ 6 | _X_X_XXX_X_X_X_ 7 | XXX____________ 8 | _X_X_X_X_X_X_X_ 9 | ____________XXX 10 | _X_X_X_XXX_X_X_ 11 | ____X__________ 12 | _X_X_X_X_X_X_X_ 13 | _________X_____ 14 | _X_X_X_X_X_X_X_ 15 | _______X_______ 16 | -------------------------------------------------------------------------------- /cg/aa4.output: -------------------------------------------------------------------------------- 1 | p p p 2 | /\ p p /\ /\ 3 | /__\ /\_____/\ /__\ /__\ 4 | |. |_=_|. . . .|_=_=_=_=_=_=_|. | 5 | |. |. .| ___ |. . . . . . .|. | 6 | |. | | | | | |. | 7 | __|__|___|_|___|_|_____________|__|__ 8 | / / / \ 9 | -------------------------------------------------------------------------------- /cg/life2.input: -------------------------------------------------------------------------------- 1 | 29 2 | o o o oo 3 | o o oo o o 4 | o o o 5 | o o 6 | o o o o o o 7 | o o o 8 | o o o 9 | o oo o o 10 | o o o 11 | o o o oo 12 | o o o 13 | o 14 | o o o o o 15 | oo oo oo 16 | o o o oo 17 | o o 18 | -------------------------------------------------------------------------------- /cg/picross4.input: -------------------------------------------------------------------------------- 1 | 3.4.3.3 2 | 1.1.1.1.1.1 3 | 1.1.1.1.1.3 4 | 1.1.1.1.1.1 5 | 3.4.3.3 6 | 0 7 | 2.4.1.3 8 | 1.1.1.1.1 9 | 1.2.1.1.1.3 10 | 1.1.1.1.1.1 11 | 2.4.3.1 12 | - 13 | 5.3 14 | 1.1.1.1 15 | 1.1.1.1.1 16 | 2 17 | 5 18 | 1.1.5 19 | 1.1.1.1 20 | 5.1.1 21 | 5 22 | 5 23 | 1.1.5 24 | 1.1.1 25 | 3.1 26 | 0 27 | 5.5 28 | 1.1.1.1.1 29 | 1.1.1.1.1 30 | -------------------------------------------------------------------------------- /cg/cross1.output: -------------------------------------------------------------------------------- 1 | ##################### 2 | #1 #2 #3 #4 # 3 | # # # # # 4 | ##################### 5 | #5 # # # # 6 | # # # # # 7 | ##################### 8 | #6 # # # # 9 | # # # # # 10 | ##################### 11 | #7 # # # # 12 | # # # # # 13 | ##################### 14 | -------------------------------------------------------------------------------- /cg/cross2.output: -------------------------------------------------------------------------------- 1 | ##################### 2 | #1 # # #2 # 3 | # # # # # 4 | ##################### 5 | # ########### # 6 | # ########### # 7 | ##################### 8 | # ########### # 9 | # ########### # 10 | ##################### 11 | #3 # # # # 12 | # # # # # 13 | ##################### 14 | -------------------------------------------------------------------------------- /cg/grid1.input: -------------------------------------------------------------------------------- 1 | 01 34 46 31 55 21 16 88 87 87 2 | 32 40 82 40 43 96 08 82 41 86 3 | 30 16 24 18 04 54 65 96 38 48 4 | 32 00 99 90 24 75 89 41 04 01 5 | 11 80 31 83 08 93 37 96 27 64 6 | 09 81 28 41 48 23 68 55 86 72 7 | 64 61 14 55 33 39 40 18 57 59 8 | 49 34 50 81 85 12 22 54 80 76 9 | 18 45 50 26 81 95 25 14 46 75 10 | 22 52 37 50 37 40 16 71 52 17 11 | -------------------------------------------------------------------------------- /cg/grid2.input: -------------------------------------------------------------------------------- 1 | 80 37 47 73 38 76 42 51 55 94 2 | 08 72 68 33 45 93 80 80 08 30 3 | 82 61 59 65 81 31 01 59 45 71 4 | 04 40 65 63 47 26 85 56 22 54 5 | 44 87 99 68 09 52 10 44 07 71 6 | 97 50 19 15 65 92 42 63 53 00 7 | 39 47 03 45 33 63 71 27 91 29 8 | 85 81 04 63 90 16 06 04 78 70 9 | 60 99 68 84 26 98 24 85 33 67 10 | 82 06 90 58 09 94 81 48 99 40 11 | -------------------------------------------------------------------------------- /cg/grid3.input: -------------------------------------------------------------------------------- 1 | 51 64 31 44 43 67 41 22 94 69 2 | 36 58 47 38 31 35 82 20 12 88 3 | 92 70 79 63 71 36 70 08 72 00 4 | 49 46 76 81 38 32 99 86 21 85 5 | 42 36 35 24 23 21 64 71 49 06 6 | 81 56 54 12 59 59 02 22 88 86 7 | 94 15 61 58 51 28 33 20 74 55 8 | 86 87 83 83 10 15 77 38 77 91 9 | 18 02 57 61 72 59 32 18 62 86 10 | 09 06 85 67 83 35 73 77 19 05 11 | -------------------------------------------------------------------------------- /cg/grid4.input: -------------------------------------------------------------------------------- 1 | 53 46 61 13 09 28 95 90 82 82 2 | 73 45 15 00 57 38 22 27 06 28 3 | 74 99 90 75 07 27 26 46 57 20 4 | 61 91 85 89 84 14 08 84 65 44 5 | 26 71 97 87 46 72 09 68 26 63 6 | 04 77 02 04 96 34 06 23 65 65 7 | 31 48 90 43 34 33 51 28 43 43 8 | 73 19 66 78 39 70 54 86 38 82 9 | 47 67 68 11 88 50 46 03 70 00 10 | 03 62 22 67 68 55 99 82 45 51 11 | -------------------------------------------------------------------------------- /cg/picross2.input: -------------------------------------------------------------------------------- 1 | 5.5 2 | 3.5.3 3 | 2.9.2 4 | 1.2.1.2.1 5 | 1.11.1 6 | 4.1.4 7 | 4.1.4 8 | 13 9 | 6.6 10 | 13 11 | 1.2.2.1 12 | 1.11.1 13 | 2.9.2 14 | 3.5.3 15 | 5.5 16 | - 17 | 5.5 18 | 3.5.3 19 | 2.9.2 20 | 1.11.1 21 | 1.1.6.2.1 22 | 2.1.3.3 23 | 2.1.3.3 24 | 7.1.3 25 | 2.1.3.3 26 | 2.1.3.3 27 | 1.1.6.2.1 28 | 1.11.1 29 | 2.9.2 30 | 3.5.3 31 | 5.5 32 | -------------------------------------------------------------------------------- /cg/crossword1.output: -------------------------------------------------------------------------------- 1 | ##################### 2 | #1 #2 #3 #4 # 3 | # # # # # 4 | ##################### 5 | #5 # # # # 6 | # # # # # 7 | ##################### 8 | #6 # # # # 9 | # # # # # 10 | ##################### 11 | #7 # # # # 12 | # # # # # 13 | ##################### 14 | -------------------------------------------------------------------------------- /cg/crossword2.output: -------------------------------------------------------------------------------- 1 | ##################### 2 | #1 # # #2 # 3 | # # # # # 4 | ##################### 5 | # ########### # 6 | # ########### # 7 | ##################### 8 | # ########### # 9 | # ########### # 10 | ##################### 11 | #3 # # # # 12 | # # # # # 13 | ##################### 14 | -------------------------------------------------------------------------------- /cg/spiral5.output: -------------------------------------------------------------------------------- 1 | 1 2 3 4 5 6 7 8 9 10 2 | 32 33 34 35 36 37 38 39 40 11 3 | 31 56 57 58 59 60 61 62 41 12 4 | 30 55 72 73 74 75 76 63 42 13 5 | 29 54 71 80 79 78 77 64 43 14 6 | 28 53 70 69 68 67 66 65 44 15 7 | 27 52 51 50 49 48 47 46 45 16 8 | 26 25 24 23 22 21 20 19 18 17 9 | -------------------------------------------------------------------------------- /cg/spiral3.output: -------------------------------------------------------------------------------- 1 | 1 2 3 4 5 6 7 8 9 10 2 | 34 35 36 37 38 39 40 41 42 11 3 | 33 60 61 62 63 64 65 66 43 12 4 | 32 59 78 79 80 81 82 67 44 13 5 | 31 58 77 88 89 90 83 68 45 14 6 | 30 57 76 87 86 85 84 69 46 15 7 | 29 56 75 74 73 72 71 70 47 16 8 | 28 55 54 53 52 51 50 49 48 17 9 | 27 26 25 24 23 22 21 20 19 18 10 | -------------------------------------------------------------------------------- /conv_cg.rb: -------------------------------------------------------------------------------- 1 | require 'cases' 2 | Dir["sample/*.test"].each do |f| 3 | x=File.basename(f,".test") 4 | n = 0 5 | get_onefile_cases(File.dirname(f)+"/"+x)[1].each do |i,o| 6 | n+=1 7 | if !i.empty? 8 | open("cg/#{x}#{n}.input", 'w') do |of| 9 | of.puts(i) 10 | end 11 | end 12 | open("cg/#{x}#{n}.output", 'w') do |of| 13 | of.puts(o) 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /cg/spiral4.output: -------------------------------------------------------------------------------- 1 | 1 2 3 4 5 6 7 8 9 10 2 | 36 37 38 39 40 41 42 43 44 11 3 | 35 64 65 66 67 68 69 70 45 12 4 | 34 63 84 85 86 87 88 71 46 13 5 | 33 62 83 96 97 98 89 72 47 14 6 | 32 61 82 95 100 99 90 73 48 15 7 | 31 60 81 94 93 92 91 74 49 16 8 | 30 59 80 79 78 77 76 75 50 17 9 | 29 58 57 56 55 54 53 52 51 18 10 | 28 27 26 25 24 23 22 21 20 19 11 | -------------------------------------------------------------------------------- /config.rb: -------------------------------------------------------------------------------- 1 | # :none, :diff, or :all 2 | $diff_style = :none 3 | 4 | # true or false 5 | $open_code_statistics = true 6 | 7 | # true or false 8 | $submit_confirm = true 9 | 10 | # true if you want to get squeezed file in current directory 11 | $copy_squeezed = false 12 | 13 | # regexp to detect spoj directory 14 | $spoj_dir_regexp = /spoj$/ 15 | 16 | # password for spoj 17 | $spoj_pass = nil 18 | 19 | # don't use marshal to exchange data 20 | $dont_use_marshalp = false 21 | -------------------------------------------------------------------------------- /sample/roman.test: -------------------------------------------------------------------------------- 1 | MMMCCXC 2 | __INPUT__ 3 | 3290 4 | __OUTPUT__ 5 | MCMVII 6 | __INPUT__ 7 | 1907 8 | __OUTPUT__ 9 | M 10 | __INPUT__ 11 | 1000 12 | __OUTPUT__ 13 | DCLI 14 | __INPUT__ 15 | 651 16 | __OUTPUT__ 17 | MMD 18 | __INPUT__ 19 | 2500 20 | __OUTPUT__ 21 | MMCMLXXXIV 22 | __INPUT__ 23 | 2984 24 | __OUTPUT__ 25 | MCMIV 26 | __INPUT__ 27 | 1904 28 | __OUTPUT__ 29 | MMDLXXIX 30 | __INPUT__ 31 | 2579 32 | __OUTPUT__ 33 | MMDCCXCIX 34 | __INPUT__ 35 | 2799 36 | __OUTPUT__ 37 | -------------------------------------------------------------------------------- /cg/aa2.output: -------------------------------------------------------------------------------- 1 | /| __ 2 | / | ,-~ / 3 | Y :| // / 4 | | jj /( .^ 5 | >-"~"-v" 6 | / Y 7 | jo o | 8 | ( ~T~ j 9 | >._-' _./ 10 | / "~" | 11 | Y _, | 12 | /| ;-"~ _ l 13 | / l/ ,-"~ \ 14 | \//\/ .- \ 15 | Y / Y 16 | l I ! 17 | ]\ _\ /"\ 18 | (" ~----( ~ Y. ) 19 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 20 | -------------------------------------------------------------------------------- /cg/spiral2.output: -------------------------------------------------------------------------------- 1 | 1 2 3 4 5 6 7 8 9 10 11 2 | 38 39 40 41 42 43 44 45 46 47 12 3 | 37 68 69 70 71 72 73 74 75 48 13 4 | 36 67 90 91 92 93 94 95 76 49 14 5 | 35 66 89 104 105 106 107 96 77 50 15 6 | 34 65 88 103 110 109 108 97 78 51 16 7 | 33 64 87 102 101 100 99 98 79 52 17 8 | 32 63 86 85 84 83 82 81 80 53 18 9 | 31 62 61 60 59 58 57 56 55 54 19 10 | 30 29 28 27 26 25 24 23 22 21 20 11 | -------------------------------------------------------------------------------- /cg/aa3.input: -------------------------------------------------------------------------------- 1 | 3 2 92 2 | 5 8 95 3 | 3 4 40 4 | 7 5 92 5 | 9 9 95 6 | 8 7 92 7 | 5 1 86 8 | 8 6 41 9 | 10 9 41 10 | 3 6 95 11 | 8 8 47 12 | 5 9 42 13 | 3 3 40 14 | 7 3 41 15 | 6 3 114 16 | 7 2 47 17 | 0 9 40 18 | 6 6 109 19 | 8 1 124 20 | 8 9 95 21 | 1 9 95 22 | 6 0 47 23 | 9 8 95 24 | 3 5 47 25 | 7 6 95 26 | 2 7 47 27 | 2 1 40 28 | 5 4 34 29 | 6 9 92 30 | 2 9 95 31 | 1 8 95 32 | 4 0 92 33 | 2 6 40 34 | 7 9 95 35 | 4 9 47 36 | 4 6 109 37 | 4 3 114 38 | 3 0 47 39 | 7 4 41 40 | 2 8 92 41 | 7 0 92 42 | 3 9 95 43 | 5 2 124 44 | -------------------------------------------------------------------------------- /update_executors.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | mkdir -p executors 4 | rm -rf sag.tgz sag executors/* 5 | wget http://golf.shinh.org/sag.tgz 6 | tar -xvzf sag.tgz 7 | mv sag/s/* executors 8 | perl -i -p -e 's@/golf/local\S*/@@g' executors/* 9 | perl -i -p -e 's@\.\./local\S*/@@g' executors/* 10 | perl -i -p -e 's@export.*@# $&@' executors/* 11 | perl -i -p -e 's@dmd.*-g@dmd -g@' executors/_d 12 | perl -i -p -e 's@dmd.*-c@dmd -c@' executors/di 13 | perl -i -p -e 's@bf@beef@' executors/bf 14 | perl -i -p -e 's@/usr/local/bin/@@' executors/grb 15 | -------------------------------------------------------------------------------- /cg/aa1.output: -------------------------------------------------------------------------------- 1 | ___________ ____ 2 | ______/ \__// \__/____\ 3 | _/ \_/ : //____\\ 4 | /| : : .. / \ 5 | | | :: :: \ / 6 | | | :| || \ \______/ 7 | | | || || |\ / | 8 | \| || || | / | \ 9 | | || || | / /_\ \ 10 | | ___ || ___ || | / / \ 11 | \_-_/ \_-_/ | ____ |/__/ \ 12 | _\_--_/ \ / 13 | /____ / 14 | / \ / 15 | \______\_________/ 16 | -------------------------------------------------------------------------------- /ed.rb: -------------------------------------------------------------------------------- 1 | def edit_distance(a, b) 2 | a = a.downcase 3 | b = b.downcase 4 | d = Array.new(b.size+1){Array.new(a.size+1){0}} 5 | 0.upto(a.size){|i|d[0][i]=i} 6 | 0.upto(b.size){|i|d[i][0]=i} 7 | a.size.times do |i1| 8 | b.size.times do |i2| 9 | cost = a[i1] == b[i2] ? 0 : 1 10 | d[i2+1][i1+1] = [d[i2+1][i1]+1, d[i2][i1+1]+1, d[i2][i1]+cost].min 11 | end 12 | end 13 | d[-1][-1] 14 | end 15 | 16 | def similarity(a, b) 17 | s = edit_distance(a, b) 18 | s = s * 10000 / a.size 19 | if a =~ /#{b}/i 20 | s /= a =~ /^#{b}/i ? 3 : 2 21 | end 22 | s 23 | end 24 | -------------------------------------------------------------------------------- /cg/seven2.output: -------------------------------------------------------------------------------- 1 | ### ### ### ### ### ### 2 | # # # # # # # # # # # # # # 3 | # # # # # # # # # # # # # # 4 | # # # # # # # # # # # # # # 5 | ### ### ### ### ### ### 6 | # # # # # # # # # # # # 7 | # # # # # # # # # # # # 8 | # # # # # # # # # # # # 9 | ### ### ### ### ### 10 | -------------------------------------------------------------------------------- /sample/queen.test: -------------------------------------------------------------------------------- 1 | Q_______ 2 | ________ 3 | ________ 4 | ________ 5 | ________ 6 | ________ 7 | ________ 8 | ________ 9 | 10 | __INPUT__ 11 | 21 12 | __OUTPUT__ 13 | _______Q 14 | ________ 15 | ________ 16 | ________ 17 | ________ 18 | ________ 19 | ________ 20 | Q_______ 21 | 22 | __INPUT__ 23 | 40 24 | __OUTPUT__ 25 | __QQ____ 26 | ________ 27 | ________ 28 | ________ 29 | ___Q____ 30 | __Q_____ 31 | ________ 32 | ________ 33 | 34 | __INPUT__ 35 | 69 36 | __OUTPUT__ 37 | _Q______ 38 | _____Q__ 39 | ________ 40 | ________ 41 | ________ 42 | __Q__Q__ 43 | ________ 44 | _______Q 45 | 46 | __INPUT__ 47 | 97 48 | __OUTPUT__ 49 | -------------------------------------------------------------------------------- /cg/seven1.output: -------------------------------------------------------------------------------- 1 | ### ### ### ### ### ### ### ### 2 | # # # # # # # # # # # # # # 3 | # # # # # # # # # # # # # # 4 | # # # # # # # # # # # # # # 5 | ### ### ### ### ### ### ### 6 | # # # # # # # # # # # # # 7 | # # # # # # # # # # # # # 8 | # # # # # # # # # # # # # 9 | ### ### ### ### ### ### ### 10 | -------------------------------------------------------------------------------- /cg/bf7.input: -------------------------------------------------------------------------------- 1 | +[,+[-[>+>+<<-]>[<+>-]+>>++++++++[<-------->-]<-[<[-]>>>+[<+<+>>-]<[>+<-]<[<++> 2 | >>+[<+<->>-]<[>+<-]]>[<]<]>>[-]<<<[[-]<[>>+>+<<<-]>>[<<+>>-]>>++++++++[<------- 3 | ->-]<->>++++[<++++++++>-]<-<[>>>+<<[>+>[-]<<-]>[<+>-]>[<<<<<+>>>>++++[<++++++++ 4 | >-]>-]<<-<-]>[<<<<[-]>>>>[<<<<->>>>-]]<<++++[<<++++++++>>-]<<-[>>+>+<<<-]>>[<<+ 5 | >>-]+>>+++++[<----->-]<-[<[-]>>>+[<+<->>-]<[>+<-]<[<++>>>+[<+<+>>-]<[>+<-]]>[<] 6 | <]>>[-]<<<[[-]<<[>>+>+<<<-]>>[<<+>>-]+>------------[<[-]>>>+[<+<->>-]<[>+<-]<[< 7 | ++>>>+[<+<+>>-]<[>+<-]]>[<]<]>>[-]<<<<<------------->>[[-]+++++[<<+++++>>-]<<+> 8 | >]<[>++++[<<++++++++>>-]<-]>]<[-]++++++++[<++++++++>-]<+>]<.[-]+>>+<]>[[-]<]<] 9 | !kettlexylophoneroastsroastsroasts 10 | -------------------------------------------------------------------------------- /cg/bf6.input: -------------------------------------------------------------------------------- 1 | +[,+[-[>+>+<<-]>[<+>-]+>>++++++++[<-------->-]<-[<[-]>>>+[<+<+>>-]<[>+<-]<[<++> 2 | >>+[<+<->>-]<[>+<-]]>[<]<]>>[-]<<<[[-]<[>>+>+<<<-]>>[<<+>>-]>>++++++++[<------- 3 | ->-]<->>++++[<++++++++>-]<-<[>>>+<<[>+>[-]<<-]>[<+>-]>[<<<<<+>>>>++++[<++++++++ 4 | >-]>-]<<-<-]>[<<<<[-]>>>>[<<<<->>>>-]]<<++++[<<++++++++>>-]<<-[>>+>+<<<-]>>[<<+ 5 | >>-]+>>+++++[<----->-]<-[<[-]>>>+[<+<->>-]<[>+<-]<[<++>>>+[<+<+>>-]<[>+<-]]>[<] 6 | <]>>[-]<<<[[-]<<[>>+>+<<<-]>>[<<+>>-]+>------------[<[-]>>>+[<+<->>-]<[>+<-]<[< 7 | ++>>>+[<+<+>>-]<[>+<-]]>[<]<]>>[-]<<<<<------------->>[[-]+++++[<<+++++>>-]<<+> 8 | >]<[>++++[<<++++++++>>-]<-]>]<[-]++++++++[<++++++++>-]<+>]<.[-]+>>+<]>[[-]<]<] 9 | !dinnernovemberlocustselephantjanuary 10 | -------------------------------------------------------------------------------- /cg/cross3.output: -------------------------------------------------------------------------------- 1 | ##################### 2 | #1 # #2 #3 # 3 | # # # # # 4 | #################################### 5 | #4 # ######5 # #6 #7 # 6 | # # ###### # # # # 7 | #################################### 8 | #8 # #9 # # #10 # # 9 | # # # # # # # # 10 | ##################### ########### 11 | # ######11 # # 12 | # ###### # # 13 | #################################### 14 | #12 #13 # ######14 #15 # # 15 | # # # ###### # # # 16 | #################################### 17 | #16 # # # # # 18 | # # # # # # 19 | ########################## 20 | -------------------------------------------------------------------------------- /cg/crossword4.output: -------------------------------------------------------------------------------- 1 | ##################### 2 | #1 # #2 #3 # 3 | # # # # # 4 | #################################### 5 | #4 # ######5 # #6 #7 # 6 | # # ###### # # # # 7 | #################################### 8 | #8 # #9 # # #10 # # 9 | # # # # # # # # 10 | ##################### ########### 11 | # ######11 # # 12 | # ###### # # 13 | #################################### 14 | #12 #13 # ######14 #15 # # 15 | # # # ###### # # # 16 | #################################### 17 | #16 # # # # # 18 | # # # # # # 19 | ########################## 20 | -------------------------------------------------------------------------------- /cg/range2.output: -------------------------------------------------------------------------------- 1 | 2-5, 7-9, 11-13, 16-19, 21-22, 24-26, 28-32, 34-41, 44-51, 53-54, 56-57, 59-66, 70, 72, 74, 77, 79, 81-82, 84-87, 89-90, 93-96, 98-99, 102, 104, 106-110, 112, 115-121, 123-125, 127-129, 132-137, 140-143, 145-157, 159-165, 168-173, 175, 178-182, 186, 188-200, 202, 204-214, 216-217, 219-223, 225, 228-230, 232-234, 236, 238-239, 241-245, 247-249, 251-252, 254-256, 260-263, 265-273, 275-277, 280, 282-283, 285-287, 289-292, 296-302, 305-306, 308-313, 315-319, 321, 323-339, 341-342, 344, 346, 348, 350, 352-354, 356, 358-360, 362-368, 370, 373, 375-378, 380-383, 385-392, 394-396, 398-402, 404, 406-421, 424-425, 428-429, 431, 433, 436-440, 442-455, 457-459, 461-462, 464-468, 470-478, 480, 482-483, 485-488, 490-494, 496-499. 2 | -------------------------------------------------------------------------------- /cg/bf5.output: -------------------------------------------------------------------------------- 1 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.> 2 | -------------------------------------------------------------------------------- /sample/switch.test: -------------------------------------------------------------------------------- 1 | A B C D 2 | | | | | 3 | X | | 4 | | | X 5 | | | | | 6 | | X | 7 | | | | | 8 | __INPUT__ 9 | B D A C 10 | __OUTPUT__ 11 | A B C D E F 12 | | | | | | | 13 | | \|/ X 14 | | X | | 15 | | /|\ | | 16 | | | | | | | 17 | X | X | 18 | | | | | | | 19 | __INPUT__ 20 | D A C F B E 21 | __OUTPUT__ 22 | A B C D E 23 | | | | | | 24 | \|/ | | 25 | X X 26 | /|\ | | 27 | | | | | | 28 | | | | | | 29 | X \|/ 30 | | | X 31 | | | /|\ 32 | | | | | | 33 | | X X 34 | | | | | | 35 | __INPUT__ 36 | B D C A E 37 | __OUTPUT__ 38 | A B C D E 39 | | | | | | 40 | | | | | | 41 | X | X 42 | | | | | | 43 | | | | | | 44 | | | | X 45 | | | | | | 46 | | | | | | 47 | | X X 48 | | | | | | 49 | | | | | | 50 | | | | | | 51 | | | X | 52 | | | | | | 53 | | | | X 54 | \|/ | | 55 | X | | 56 | /|\ | | 57 | | | | | | 58 | __INPUT__ 59 | E C B D A 60 | __OUTPUT__ 61 | -------------------------------------------------------------------------------- /cg/sha1.input: -------------------------------------------------------------------------------- 1 | A Crow, half-dead with thirst, came upon a Pitcher which had 2 | once been full of water; but when the Crow put its beak into the 3 | mouth of the Pitcher he found that only very little water was left 4 | in it, and that he could not reach far enough down to get at it. 5 | He tried, and he tried, but at last had to give up in despair. 6 | Then a thought came to him, and he took a pebble and dropped it 7 | into the Pitcher. Then he took another pebble and dropped it into 8 | the Pitcher. Then he took another pebble and dropped that into 9 | the Pitcher. Then he took another pebble and dropped that into 10 | the Pitcher. Then he took another pebble and dropped that into 11 | the Pitcher. Then he took another pebble and dropped that into 12 | the Pitcher. At last, at last, he saw the water mount up near 13 | him, and after casting in a few more pebbles he was able to quench 14 | his thirst and save his life. 15 | 16 | 17 | Little by little does the trick. 18 | -------------------------------------------------------------------------------- /cg/pi1.output: -------------------------------------------------------------------------------- 1 | 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989 2 | -------------------------------------------------------------------------------- /cg/sha2.input: -------------------------------------------------------------------------------- 1 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 2 | -------------------------------------------------------------------------------- /sample/pi.test: -------------------------------------------------------------------------------- 1 | _ 2 | __INPUT__ 3 | 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989 4 | __OUTPUT__ 5 | -------------------------------------------------------------------------------- /cg/bf3.output: -------------------------------------------------------------------------------- 1 | 0 2 | 1 3 | 4 4 | 9 5 | 16 6 | 25 7 | 36 8 | 49 9 | 64 10 | 81 11 | 100 12 | 121 13 | 144 14 | 169 15 | 196 16 | 225 17 | 256 18 | 289 19 | 324 20 | 361 21 | 400 22 | 441 23 | 484 24 | 529 25 | 576 26 | 625 27 | 676 28 | 729 29 | 784 30 | 841 31 | 900 32 | 961 33 | 1024 34 | 1089 35 | 1156 36 | 1225 37 | 1296 38 | 1369 39 | 1444 40 | 1521 41 | 1600 42 | 1681 43 | 1764 44 | 1849 45 | 1936 46 | 2025 47 | 2116 48 | 2209 49 | 2304 50 | 2401 51 | 2500 52 | 2601 53 | 2704 54 | 2809 55 | 2916 56 | 3025 57 | 3136 58 | 3249 59 | 3364 60 | 3481 61 | 3600 62 | 3721 63 | 3844 64 | 3969 65 | 4096 66 | 4225 67 | 4356 68 | 4489 69 | 4624 70 | 4761 71 | 4900 72 | 5041 73 | 5184 74 | 5329 75 | 5476 76 | 5625 77 | 5776 78 | 5929 79 | 6084 80 | 6241 81 | 6400 82 | 6561 83 | 6724 84 | 6889 85 | 7056 86 | 7225 87 | 7396 88 | 7569 89 | 7744 90 | 7921 91 | 8100 92 | 8281 93 | 8464 94 | 8649 95 | 8836 96 | 9025 97 | 9216 98 | 9409 99 | 9604 100 | 9801 101 | 10000 102 | -------------------------------------------------------------------------------- /sample/seven.test: -------------------------------------------------------------------------------- 1 | 0123456789 2 | 3 | __INPUT__ 4 | ### ### ### ### ### ### ### ### 5 | # # # # # # # # # # # # # # 6 | # # # # # # # # # # # # # # 7 | # # # # # # # # # # # # # # 8 | ### ### ### ### ### ### ### 9 | # # # # # # # # # # # # # 10 | # # # # # # # # # # # # # 11 | # # # # # # # # # # # # # 12 | ### ### ### ### ### ### ### 13 | __OUTPUT__ 14 | 841873420 15 | 16 | __INPUT__ 17 | ### ### ### ### ### ### 18 | # # # # # # # # # # # # # # 19 | # # # # # # # # # # # # # # 20 | # # # # # # # # # # # # # # 21 | ### ### ### ### ### ### 22 | # # # # # # # # # # # # 23 | # # # # # # # # # # # # 24 | # # # # # # # # # # # # 25 | ### ### ### ### ### 26 | __OUTPUT__ 27 | -------------------------------------------------------------------------------- /sample/poly.test: -------------------------------------------------------------------------------- 1 | -x^5+x^4-3*x^3-x^2-4 2 | -------------------- 3 | x^2-x+2 4 | __INPUT__ 5 | -x^3-x-2 6 | __OUTPUT__ 7 | -6*x^4-8*x^3+3*x^2-2*x-1 8 | ------------------------ 9 | 2*x^2+4*x+1 10 | __INPUT__ 11 | -3*x^2+2*x-1 12 | __OUTPUT__ 13 | x^4-1 14 | ----------- 15 | x^3-x^2+x-1 16 | __INPUT__ 17 | x+1 18 | __OUTPUT__ 19 | -x^5+5*x^4-11*x^3+10*x^2-9 20 | -------------------------- 21 | -x^3+3*x^2-2*x-3 22 | __INPUT__ 23 | x^2-2*x+3 24 | __OUTPUT__ 25 | x^3-12*x^2+81 26 | ------------- 27 | x-3 28 | __INPUT__ 29 | x^2-9*x-27 30 | __OUTPUT__ 31 | -35*x^2-7 32 | --------- 33 | 5*x^2+1 34 | __INPUT__ 35 | -7 36 | __OUTPUT__ 37 | 99*x^60-153*x^58-90*x^57+121*x^55-187*x^53-110*x^52 38 | --------------------------------------------------- 39 | -9*x^45-11*x^40 40 | __INPUT__ 41 | -11*x^15+17*x^13+10*x^12 42 | __OUTPUT__ 43 | 72*x^69+44*x^51-190*x^48-99*x^30+63*x^27 44 | ---------------------------------------- 45 | -18*x^22-11*x^4+7*x 46 | __INPUT__ 47 | -4*x^47+9*x^26 48 | __OUTPUT__ 49 | -220*x^97-220*x^83-240*x^81-240*x^67+60*x^63+60*x^49 50 | ---------------------------------------------------- 51 | -20*x^47-20*x^33 52 | __INPUT__ 53 | 11*x^50+12*x^34-3*x^16 54 | __OUTPUT__ 55 | 3*x^4-8*x^3-12*x^2+81 56 | --------------------- 57 | x-3 58 | __INPUT__ 59 | 3*x^3+x^2-9*x-27 60 | __OUTPUT__ 61 | -------------------------------------------------------------------------------- /cg/range2.input: -------------------------------------------------------------------------------- 1 | 2 3 4 5 7 8 9 11 12 13 16 17 18 19 21 22 24 25 26 28 29 30 31 32 34 35 36 37 38 39 40 41 44 45 46 47 48 49 50 51 53 54 56 57 59 60 61 62 63 64 65 66 70 72 74 77 79 81 82 84 85 86 87 89 90 93 94 95 96 98 99 102 104 106 107 108 109 110 112 115 116 117 118 119 120 121 123 124 125 127 128 129 132 133 134 135 136 137 140 141 142 143 145 146 147 148 149 150 151 152 153 154 155 156 157 159 160 161 162 163 164 165 168 169 170 171 172 173 175 178 179 180 181 182 186 188 189 190 191 192 193 194 195 196 197 198 199 200 202 204 205 206 207 208 209 210 211 212 213 214 216 217 219 220 221 222 223 225 228 229 230 232 233 234 236 238 239 241 242 243 244 245 247 248 249 251 252 254 255 256 260 261 262 263 265 266 267 268 269 270 271 272 273 275 276 277 280 282 283 285 286 287 289 290 291 292 296 297 298 299 300 301 302 305 306 308 309 310 311 312 313 315 316 317 318 319 321 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 341 342 344 346 348 350 352 353 354 356 358 359 360 362 363 364 365 366 367 368 370 373 375 376 377 378 380 381 382 383 385 386 387 388 389 390 391 392 394 395 396 398 399 400 401 402 404 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 424 425 428 429 431 433 436 437 438 439 440 442 443 444 445 446 447 448 449 450 451 452 453 454 455 457 458 459 461 462 464 465 466 467 468 470 471 472 473 474 475 476 477 478 480 482 483 485 486 487 488 490 491 492 493 494 496 497 498 499 2 | -------------------------------------------------------------------------------- /install_apt.rb: -------------------------------------------------------------------------------- 1 | APT_PACKAGES = { 2 | '.rb' => 'ruby', 3 | '.pl' => 'perl', 4 | '.py' => 'python', 5 | '.php' => 'php5-cli', 6 | '.scm' => 'gauche', 7 | '.l' => 'clisp', 8 | '.js' => 'spidermonkey-bin', 9 | '.lua' => 'lua5.1', 10 | '.tcl' => 'tcl8.4', 11 | # '.xtal' => '', 12 | '.st' => 'gnu-smalltalk', 13 | '.pro' => 'swi-prolog', 14 | '.for' => 'gforth', 15 | '.bas' => 'yabasic', 16 | '.pl6' => 'pugs', 17 | '.erl' => 'erlang', 18 | # '.ijs' => '', 19 | '.a+' => 'aplus-fsf', 20 | # '.mind' => '', 21 | '.c' => 'gcc', 22 | '.cpp' => 'g++', 23 | # '.d' => '', 24 | '.ml' => 'ocaml', 25 | '.hs' => 'ghc6', 26 | '.ada' => 'gnat', 27 | '.m' => 'gobjc', 28 | '.java' => 'gcj', 29 | '.pas' => 'gpc', 30 | '.f95' => 'gfortran', 31 | '.cs' => 'mono-mcs', 32 | '.cob' => 'open-cobol', 33 | # '.curry' => '', 34 | '.awk' => 'mawk', 35 | '.sed' => 'sed', 36 | '.sh' => 'bash', 37 | # '.xgawk' => '', 38 | '.m4' => 'm4', 39 | '.ps' => 'ghostscript', 40 | '.vhdl' => 'ghdl', 41 | '.bf' => 'beef', 42 | '.ws' => 'whitespace', 43 | # '.bef' => '', 44 | # '.pef' => '', 45 | # '.ms' => '', 46 | # '.gs' => '', 47 | '.unl' => 'unlambda', 48 | # '.lazy' => '', 49 | # '.wr' => '', 50 | # '.di' => '', 51 | '.s' => 'binutils', 52 | # '.out' => '', 53 | # '.z8b' => '', 54 | '.vi' => 'vim', 55 | # '.grb' => '', 56 | } 57 | 58 | def install_apt 59 | system("sudo apt-get install -y #{APT_PACKAGES.values*' '}") 60 | end 61 | -------------------------------------------------------------------------------- /sample/grid.test: -------------------------------------------------------------------------------- 1 | 01 34 46 31 55 21 16 88 87 87 2 | 32 40 82 40 43 96 08 82 41 86 3 | 30 16 24 18 04 54 65 96 38 48 4 | 32 00 99 90 24 75 89 41 04 01 5 | 11 80 31 83 08 93 37 96 27 64 6 | 09 81 28 41 48 23 68 55 86 72 7 | 64 61 14 55 33 39 40 18 57 59 8 | 49 34 50 81 85 12 22 54 80 76 9 | 18 45 50 26 81 95 25 14 46 75 10 | 22 52 37 50 37 40 16 71 52 17 11 | 12 | __INPUT__ 13 | 615 14 | __OUTPUT__ 15 | 80 37 47 73 38 76 42 51 55 94 16 | 08 72 68 33 45 93 80 80 08 30 17 | 82 61 59 65 81 31 01 59 45 71 18 | 04 40 65 63 47 26 85 56 22 54 19 | 44 87 99 68 09 52 10 44 07 71 20 | 97 50 19 15 65 92 42 63 53 00 21 | 39 47 03 45 33 63 71 27 91 29 22 | 85 81 04 63 90 16 06 04 78 70 23 | 60 99 68 84 26 98 24 85 33 67 24 | 82 06 90 58 09 94 81 48 99 40 25 | 26 | __INPUT__ 27 | 644 28 | __OUTPUT__ 29 | 51 64 31 44 43 67 41 22 94 69 30 | 36 58 47 38 31 35 82 20 12 88 31 | 92 70 79 63 71 36 70 08 72 00 32 | 49 46 76 81 38 32 99 86 21 85 33 | 42 36 35 24 23 21 64 71 49 06 34 | 81 56 54 12 59 59 02 22 88 86 35 | 94 15 61 58 51 28 33 20 74 55 36 | 86 87 83 83 10 15 77 38 77 91 37 | 18 02 57 61 72 59 32 18 62 86 38 | 09 06 85 67 83 35 73 77 19 05 39 | 40 | __INPUT__ 41 | 647 42 | __OUTPUT__ 43 | 53 46 61 13 09 28 95 90 82 82 44 | 73 45 15 00 57 38 22 27 06 28 45 | 74 99 90 75 07 27 26 46 57 20 46 | 61 91 85 89 84 14 08 84 65 44 47 | 26 71 97 87 46 72 09 68 26 63 48 | 04 77 02 04 96 34 06 23 65 65 49 | 31 48 90 43 34 33 51 28 43 43 50 | 73 19 66 78 39 70 54 86 38 82 51 | 47 67 68 11 88 50 46 03 70 00 52 | 03 62 22 67 68 55 99 82 45 51 53 | 54 | __INPUT__ 55 | 625 56 | __OUTPUT__ 57 | -------------------------------------------------------------------------------- /cg/aa4.input: -------------------------------------------------------------------------------- 1 | 18 4 124 2 | 1 6 95 3 | 10 6 124 4 | 31 6 95 5 | 3 4 124 6 | 10 5 124 7 | 25 3 95 8 | 3 3 124 9 | 27 4 46 10 | 33 4 46 11 | 35 6 124 12 | 32 5 124 13 | 5 0 112 14 | 14 4 95 15 | 15 7 47 16 | 14 6 95 17 | 21 6 95 18 | 18 5 124 19 | 33 5 46 20 | 13 4 95 21 | 30 3 61 22 | 24 1 92 23 | 0 7 47 24 | 13 3 46 25 | 14 2 95 26 | 34 0 112 27 | 16 2 95 28 | 32 4 124 29 | 9 3 95 30 | 4 5 46 31 | 18 2 92 32 | 3 2 47 33 | 34 6 95 34 | 6 5 124 35 | 38 7 92 36 | 25 2 92 37 | 3 5 124 38 | 26 6 95 39 | 32 3 124 40 | 24 3 61 41 | 15 2 95 42 | 19 3 95 43 | 9 6 95 44 | 24 2 95 45 | 24 6 95 46 | 13 6 95 47 | 36 6 95 48 | 6 2 92 49 | 5 1 92 50 | 16 6 124 51 | 11 3 46 52 | 29 6 95 53 | 18 3 124 54 | 33 1 47 55 | 35 4 124 56 | 6 6 124 57 | 35 2 92 58 | 5 2 95 59 | 23 1 47 60 | 28 6 95 61 | 10 3 124 62 | 5 6 95 63 | 12 6 124 64 | 21 4 46 65 | 16 5 124 66 | 10 4 124 67 | 17 2 47 68 | 23 3 95 69 | 33 2 95 70 | 4 6 95 71 | 32 2 47 72 | 19 4 46 73 | 25 4 46 74 | 11 6 95 75 | 6 3 124 76 | 12 5 124 77 | 35 3 124 78 | 18 1 112 79 | 18 6 124 80 | 21 3 95 81 | 23 6 95 82 | 29 4 46 83 | 3 6 124 84 | 11 1 112 85 | 27 6 95 86 | 23 4 46 87 | 34 2 95 88 | 24 0 112 89 | 27 3 95 90 | 17 6 95 91 | 4 1 47 92 | 7 4 46 93 | 28 3 61 94 | 6 4 124 95 | 8 6 95 96 | 4 2 95 97 | 29 3 95 98 | 12 2 95 99 | 22 2 47 100 | 9 4 46 101 | 15 6 95 102 | 11 7 47 103 | 10 2 47 104 | 20 3 61 105 | 15 4 95 106 | 11 2 92 107 | 7 6 95 108 | 13 2 95 109 | 31 3 95 110 | 35 5 124 111 | 23 2 95 112 | 22 6 95 113 | 22 3 61 114 | 33 6 95 115 | 17 3 46 116 | 32 6 124 117 | 33 3 46 118 | 20 6 95 119 | 4 3 46 120 | 25 6 95 121 | 8 3 61 122 | 4 4 46 123 | 26 3 61 124 | 15 3 46 125 | 7 3 95 126 | 2 6 95 127 | 30 6 95 128 | 37 6 95 129 | 31 4 46 130 | 19 6 95 131 | 34 1 92 132 | -------------------------------------------------------------------------------- /executors/run_mncore2.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | mncore2_emuenv_url = "https://projects.preferred.jp/mn-core/assets/mncore2_emuenv_20240221.zip" 4 | mncore2_emuenv = "/tmp/mncore2_emuenv_20240221" 5 | if !File.exist?(mncore2_emuenv) 6 | Dir.chdir("/tmp") do 7 | STDERR.puts "Downloading mncore2_emuenv in #{mncore2_emuenv}..." 8 | system("curl -O #{mncore2_emuenv_url}") 9 | system("unzip mncore2_emuenv_20240221.zip") 10 | end 11 | end 12 | 13 | ASM = "#{mncore2_emuenv}/assemble3" 14 | EMU = "#{mncore2_emuenv}/gpfn3_package_main" 15 | 16 | def write_pdm(str) 17 | if str.empty? 18 | return "" 19 | end 20 | 21 | payload = "" 22 | str.each_byte do |b| 23 | payload += "%02x" % b 24 | end 25 | while payload.size % 16 != 0 26 | payload += "00" 27 | end 28 | addr = "%09x" % 0 29 | len = "%06x" % (payload.size / 16) 30 | 31 | vsm = "c 0 0 i01 i00 0 #{addr} #{len} #{payload}\n" 32 | vsm += "nop; wait i01\n" 33 | return vsm 34 | end 35 | 36 | def parse_pdm_out(out) 37 | o = "" 38 | out.each_line do |line| 39 | o += line.split(": ")[1].strip 40 | end 41 | 42 | s = "" 43 | (o.size / 2).times do |i| 44 | c = o[i*2, 2].hex 45 | break if c == 0 46 | s += c.chr 47 | end 48 | s 49 | end 50 | 51 | full_vsm = write_pdm(STDIN.read) 52 | full_vsm += File.read(ARGV[0]) 53 | full_vsm += "f\n" 54 | full_vsm += "e 0 0 i02 i00 0 000000000 010000\n" 55 | full_vsm += "nop; wait i02\n" 56 | 57 | File.open("/tmp/full.vsm", "w") do |of| 58 | of.print(full_vsm) 59 | end 60 | 61 | score = `#{ASM} --instruction-mode flat #{ARGV[0]}`.split("\n").size 62 | STDERR.puts "#{score} instructions" 63 | 64 | system("#{ASM} --instruction-mode flat /tmp/full.vsm > /tmp/full.asm") 65 | system("#{EMU} < /tmp/full.asm > /tmp/emu.out") 66 | 67 | print parse_pdm_out(File.read("/tmp/emu.out")) 68 | -------------------------------------------------------------------------------- /sample/picross.test: -------------------------------------------------------------------------------- 1 | 1 2 | 1 3 | 3 4 | - 5 | 1 6 | 1.1 7 | 2 8 | 9 | __INPUT__ 10 | X 11 | X 12 | XXX 13 | __OUTPUT__ 14 | 5.5 15 | 3.5.3 16 | 2.9.2 17 | 1.2.1.2.1 18 | 1.11.1 19 | 4.1.4 20 | 4.1.4 21 | 13 22 | 6.6 23 | 13 24 | 1.2.2.1 25 | 1.11.1 26 | 2.9.2 27 | 3.5.3 28 | 5.5 29 | - 30 | 5.5 31 | 3.5.3 32 | 2.9.2 33 | 1.11.1 34 | 1.1.6.2.1 35 | 2.1.3.3 36 | 2.1.3.3 37 | 7.1.3 38 | 2.1.3.3 39 | 2.1.3.3 40 | 1.1.6.2.1 41 | 1.11.1 42 | 2.9.2 43 | 3.5.3 44 | 5.5 45 | 46 | __INPUT__ 47 | XXXXX XXXXX 48 | XXX XXXXX XXX 49 | XX XXXXXXXXX XX 50 | X XX X XX X 51 | X XXXXXXXXXXX X 52 | XXXX X XXXX 53 | XXXX X XXXX 54 | XXXXXXXXXXXXX 55 | XXXXXX XXXXXX 56 | XXXXXXXXXXXXX 57 | X XX XX X 58 | X XXXXXXXXXXX X 59 | XX XXXXXXXXX XX 60 | XXX XXXXX XXX 61 | XXXXX XXXXX 62 | __OUTPUT__ 63 | 1.1.1.1 64 | 3.3 65 | 2.2.1 66 | 5 67 | 3.1.1 68 | 2 69 | 1.1.3 70 | 2.3.1 71 | 5 72 | 2.1.1 73 | - 74 | 1.1.1.1 75 | 4.2 76 | 1.2.2 77 | 4.4 78 | 3.2 79 | 2.1.5 80 | 2.3.1 81 | 2.2.1 82 | 83 | __INPUT__ 84 | X X X X 85 | XXX XXX 86 | XX XX X 87 | XXXXX 88 | XXX X X 89 | XX 90 | X X XXX 91 | XX XXX X 92 | XXXXX 93 | XX X X 94 | __OUTPUT__ 95 | 3.4.3.3 96 | 1.1.1.1.1.1 97 | 1.1.1.1.1.3 98 | 1.1.1.1.1.1 99 | 3.4.3.3 100 | 0 101 | 2.4.1.3 102 | 1.1.1.1.1 103 | 1.2.1.1.1.3 104 | 1.1.1.1.1.1 105 | 2.4.3.1 106 | - 107 | 5.3 108 | 1.1.1.1 109 | 1.1.1.1.1 110 | 2 111 | 5 112 | 1.1.5 113 | 1.1.1.1 114 | 5.1.1 115 | 5 116 | 5 117 | 1.1.5 118 | 1.1.1 119 | 3.1 120 | 0 121 | 5.5 122 | 1.1.1.1.1 123 | 1.1.1.1.1 124 | 125 | __INPUT__ 126 | XXX XXXX XXX XXX 127 | X X X X X X 128 | X X X X X XXX 129 | X X X X X X 130 | XXX XXXX XXX XXX 131 | 132 | XX XXXX X XXX 133 | X X X X X 134 | X XX X X X XXX 135 | X X X X X X 136 | XX XXXX XXX X 137 | __OUTPUT__ 138 | -------------------------------------------------------------------------------- /cg/aa2.input: -------------------------------------------------------------------------------- 1 | 8 8 62 2 | 13 3 106 3 | 24 18 126 4 | 11 7 126 5 | 21 1 47 6 | 17 1 44 7 | 8 18 126 8 | 9 5 47 9 | 14 17 126 10 | 17 7 106 11 | 19 3 94 12 | 6 13 47 13 | 5 15 108 14 | 17 5 89 15 | 21 18 126 16 | 10 8 95 17 | 4 12 47 18 | 14 16 92 19 | 13 9 34 20 | 16 8 47 21 | 12 0 47 22 | 21 0 95 23 | 17 18 126 24 | 9 6 111 25 | 19 17 46 26 | 20 0 95 27 | 9 17 45 28 | 19 16 47 29 | 0 18 126 30 | 12 4 34 31 | 4 18 126 32 | 2 18 126 33 | 22 17 41 34 | 6 12 108 35 | 1 18 126 36 | 13 11 95 37 | 17 2 47 38 | 12 3 106 39 | 12 9 126 40 | 13 2 124 41 | 9 18 126 42 | 10 12 45 43 | 18 1 45 44 | 22 18 126 45 | 13 15 73 46 | 6 11 124 47 | 6 10 89 48 | 16 9 124 49 | 9 7 126 50 | 5 17 34 51 | 11 8 45 52 | 14 8 95 53 | 17 4 34 54 | 9 12 44 55 | 12 8 39 56 | 12 2 58 57 | 11 17 45 58 | 12 18 126 59 | 13 1 124 60 | 15 13 46 61 | 9 8 46 62 | 11 4 45 63 | 18 13 92 64 | 8 17 45 65 | 3 18 126 66 | 4 17 40 67 | 5 16 93 68 | 25 18 126 69 | 11 11 126 70 | 16 10 124 71 | 5 18 126 72 | 13 16 95 73 | 11 12 34 74 | 10 7 84 75 | 18 18 126 76 | 8 6 106 77 | 12 6 111 78 | 6 16 92 79 | 15 8 46 80 | 19 15 33 81 | 14 18 126 82 | 7 7 40 83 | 20 2 47 84 | 14 14 47 85 | 17 12 92 86 | 13 4 126 87 | 7 13 92 88 | 5 11 47 89 | 13 18 126 90 | 15 4 45 91 | 23 18 126 92 | 7 18 126 93 | 16 11 108 94 | 16 4 118 95 | 4 13 92 96 | 16 13 45 97 | 21 16 92 98 | 19 14 89 99 | 18 3 46 100 | 13 0 124 101 | 15 18 126 102 | 10 11 34 103 | 16 18 126 104 | 5 14 89 105 | 7 17 126 106 | 10 2 89 107 | 20 18 126 108 | 9 11 45 109 | 19 18 126 110 | 10 3 124 111 | 19 1 126 112 | 5 13 47 113 | 12 10 95 114 | 14 4 34 115 | 7 9 47 116 | 16 3 40 117 | 6 18 126 118 | 12 17 40 119 | 12 12 126 120 | 11 1 47 121 | 18 17 89 122 | 10 18 126 123 | 17 6 124 124 | 15 3 47 125 | 16 2 47 126 | 10 17 45 127 | 8 13 47 128 | 20 16 34 129 | 7 12 47 130 | 8 11 59 131 | 11 18 126 132 | 13 10 44 133 | 11 9 34 134 | 10 4 62 135 | -------------------------------------------------------------------------------- /cg/cal3.output: -------------------------------------------------------------------------------- 1 | 2399 2 | 3 | January February March 4 | Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 5 | 1 2 1 2 3 4 5 6 1 2 3 4 5 6 6 | 3 4 5 6 7 8 9 7 8 9 10 11 12 13 7 8 9 10 11 12 13 7 | 10 11 12 13 14 15 16 14 15 16 17 18 19 20 14 15 16 17 18 19 20 8 | 17 18 19 20 21 22 23 21 22 23 24 25 26 27 21 22 23 24 25 26 27 9 | 24 25 26 27 28 29 30 28 28 29 30 31 10 | 31 11 | April May June 12 | Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 13 | 1 2 3 1 1 2 3 4 5 14 | 4 5 6 7 8 9 10 2 3 4 5 6 7 8 6 7 8 9 10 11 12 15 | 11 12 13 14 15 16 17 9 10 11 12 13 14 15 13 14 15 16 17 18 19 16 | 18 19 20 21 22 23 24 16 17 18 19 20 21 22 20 21 22 23 24 25 26 17 | 25 26 27 28 29 30 23 24 25 26 27 28 29 27 28 29 30 18 | 30 31 19 | July August September 20 | Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 21 | 1 2 3 1 2 3 4 5 6 7 1 2 3 4 22 | 4 5 6 7 8 9 10 8 9 10 11 12 13 14 5 6 7 8 9 10 11 23 | 11 12 13 14 15 16 17 15 16 17 18 19 20 21 12 13 14 15 16 17 18 24 | 18 19 20 21 22 23 24 22 23 24 25 26 27 28 19 20 21 22 23 24 25 25 | 25 26 27 28 29 30 31 29 30 31 26 27 28 29 30 26 | 27 | October November December 28 | Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 29 | 1 2 1 2 3 4 5 6 1 2 3 4 30 | 3 4 5 6 7 8 9 7 8 9 10 11 12 13 5 6 7 8 9 10 11 31 | 10 11 12 13 14 15 16 14 15 16 17 18 19 20 12 13 14 15 16 17 18 32 | 17 18 19 20 21 22 23 21 22 23 24 25 26 27 19 20 21 22 23 24 25 33 | 24 25 26 27 28 29 30 28 29 30 26 27 28 29 30 31 34 | 31 35 | -------------------------------------------------------------------------------- /cg/cal2.output: -------------------------------------------------------------------------------- 1 | 2000 2 | 3 | January February March 4 | Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 5 | 1 1 2 3 4 5 1 2 3 4 6 | 2 3 4 5 6 7 8 6 7 8 9 10 11 12 5 6 7 8 9 10 11 7 | 9 10 11 12 13 14 15 13 14 15 16 17 18 19 12 13 14 15 16 17 18 8 | 16 17 18 19 20 21 22 20 21 22 23 24 25 26 19 20 21 22 23 24 25 9 | 23 24 25 26 27 28 29 27 28 29 26 27 28 29 30 31 10 | 30 31 11 | April May June 12 | Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 13 | 1 1 2 3 4 5 6 1 2 3 14 | 2 3 4 5 6 7 8 7 8 9 10 11 12 13 4 5 6 7 8 9 10 15 | 9 10 11 12 13 14 15 14 15 16 17 18 19 20 11 12 13 14 15 16 17 16 | 16 17 18 19 20 21 22 21 22 23 24 25 26 27 18 19 20 21 22 23 24 17 | 23 24 25 26 27 28 29 28 29 30 31 25 26 27 28 29 30 18 | 30 19 | July August September 20 | Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 21 | 1 1 2 3 4 5 1 2 22 | 2 3 4 5 6 7 8 6 7 8 9 10 11 12 3 4 5 6 7 8 9 23 | 9 10 11 12 13 14 15 13 14 15 16 17 18 19 10 11 12 13 14 15 16 24 | 16 17 18 19 20 21 22 20 21 22 23 24 25 26 17 18 19 20 21 22 23 25 | 23 24 25 26 27 28 29 27 28 29 30 31 24 25 26 27 28 29 30 26 | 30 31 27 | October November December 28 | Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 29 | 1 2 3 4 5 6 7 1 2 3 4 1 2 30 | 8 9 10 11 12 13 14 5 6 7 8 9 10 11 3 4 5 6 7 8 9 31 | 15 16 17 18 19 20 21 12 13 14 15 16 17 18 10 11 12 13 14 15 16 32 | 22 23 24 25 26 27 28 19 20 21 22 23 24 25 17 18 19 20 21 22 23 33 | 29 30 31 26 27 28 29 30 24 25 26 27 28 29 30 34 | 31 35 | -------------------------------------------------------------------------------- /cg/cal1.output: -------------------------------------------------------------------------------- 1 | 1900 2 | 3 | January February March 4 | Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 5 | 1 2 3 4 5 6 1 2 3 1 2 3 6 | 7 8 9 10 11 12 13 4 5 6 7 8 9 10 4 5 6 7 8 9 10 7 | 14 15 16 17 18 19 20 11 12 13 14 15 16 17 11 12 13 14 15 16 17 8 | 21 22 23 24 25 26 27 18 19 20 21 22 23 24 18 19 20 21 22 23 24 9 | 28 29 30 31 25 26 27 28 25 26 27 28 29 30 31 10 | 11 | April May June 12 | Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 13 | 1 2 3 4 5 6 7 1 2 3 4 5 1 2 14 | 8 9 10 11 12 13 14 6 7 8 9 10 11 12 3 4 5 6 7 8 9 15 | 15 16 17 18 19 20 21 13 14 15 16 17 18 19 10 11 12 13 14 15 16 16 | 22 23 24 25 26 27 28 20 21 22 23 24 25 26 17 18 19 20 21 22 23 17 | 29 30 27 28 29 30 31 24 25 26 27 28 29 30 18 | 19 | July August September 20 | Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 21 | 1 2 3 4 5 6 7 1 2 3 4 1 22 | 8 9 10 11 12 13 14 5 6 7 8 9 10 11 2 3 4 5 6 7 8 23 | 15 16 17 18 19 20 21 12 13 14 15 16 17 18 9 10 11 12 13 14 15 24 | 22 23 24 25 26 27 28 19 20 21 22 23 24 25 16 17 18 19 20 21 22 25 | 29 30 31 26 27 28 29 30 31 23 24 25 26 27 28 29 26 | 30 27 | October November December 28 | Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 29 | 1 2 3 4 5 6 1 2 3 1 30 | 7 8 9 10 11 12 13 4 5 6 7 8 9 10 2 3 4 5 6 7 8 31 | 14 15 16 17 18 19 20 11 12 13 14 15 16 17 9 10 11 12 13 14 15 32 | 21 22 23 24 25 26 27 18 19 20 21 22 23 24 16 17 18 19 20 21 22 33 | 28 29 30 31 25 26 27 28 29 30 23 24 25 26 27 28 29 34 | 30 31 35 | -------------------------------------------------------------------------------- /cg/cal4.output: -------------------------------------------------------------------------------- 1 | 1753 2 | 3 | January February March 4 | Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 5 | 1 2 3 4 5 6 1 2 3 1 2 3 6 | 7 8 9 10 11 12 13 4 5 6 7 8 9 10 4 5 6 7 8 9 10 7 | 14 15 16 17 18 19 20 11 12 13 14 15 16 17 11 12 13 14 15 16 17 8 | 21 22 23 24 25 26 27 18 19 20 21 22 23 24 18 19 20 21 22 23 24 9 | 28 29 30 31 25 26 27 28 25 26 27 28 29 30 31 10 | 11 | April May June 12 | Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 13 | 1 2 3 4 5 6 7 1 2 3 4 5 1 2 14 | 8 9 10 11 12 13 14 6 7 8 9 10 11 12 3 4 5 6 7 8 9 15 | 15 16 17 18 19 20 21 13 14 15 16 17 18 19 10 11 12 13 14 15 16 16 | 22 23 24 25 26 27 28 20 21 22 23 24 25 26 17 18 19 20 21 22 23 17 | 29 30 27 28 29 30 31 24 25 26 27 28 29 30 18 | 19 | July August September 20 | Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 21 | 1 2 3 4 5 6 7 1 2 3 4 1 22 | 8 9 10 11 12 13 14 5 6 7 8 9 10 11 2 3 4 5 6 7 8 23 | 15 16 17 18 19 20 21 12 13 14 15 16 17 18 9 10 11 12 13 14 15 24 | 22 23 24 25 26 27 28 19 20 21 22 23 24 25 16 17 18 19 20 21 22 25 | 29 30 31 26 27 28 29 30 31 23 24 25 26 27 28 29 26 | 30 27 | October November December 28 | Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 29 | 1 2 3 4 5 6 1 2 3 1 30 | 7 8 9 10 11 12 13 4 5 6 7 8 9 10 2 3 4 5 6 7 8 31 | 14 15 16 17 18 19 20 11 12 13 14 15 16 17 9 10 11 12 13 14 15 32 | 21 22 23 24 25 26 27 18 19 20 21 22 23 24 16 17 18 19 20 21 22 33 | 28 29 30 31 25 26 27 28 29 30 23 24 25 26 27 28 29 34 | 30 31 35 | -------------------------------------------------------------------------------- /sample/range.test: -------------------------------------------------------------------------------- 1 | 1 2 3 4 5 6 7 2 | 3 | __INPUT__ 4 | 1-7. 5 | __OUTPUT__ 6 | 2 3 4 5 7 8 9 11 12 13 16 17 18 19 21 22 24 25 26 28 29 30 31 32 34 35 36 37 38 39 40 41 44 45 46 47 48 49 50 51 53 54 56 57 59 60 61 62 63 64 65 66 70 72 74 77 79 81 82 84 85 86 87 89 90 93 94 95 96 98 99 102 104 106 107 108 109 110 112 115 116 117 118 119 120 121 123 124 125 127 128 129 132 133 134 135 136 137 140 141 142 143 145 146 147 148 149 150 151 152 153 154 155 156 157 159 160 161 162 163 164 165 168 169 170 171 172 173 175 178 179 180 181 182 186 188 189 190 191 192 193 194 195 196 197 198 199 200 202 204 205 206 207 208 209 210 211 212 213 214 216 217 219 220 221 222 223 225 228 229 230 232 233 234 236 238 239 241 242 243 244 245 247 248 249 251 252 254 255 256 260 261 262 263 265 266 267 268 269 270 271 272 273 275 276 277 280 282 283 285 286 287 289 290 291 292 296 297 298 299 300 301 302 305 306 308 309 310 311 312 313 315 316 317 318 319 321 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 341 342 344 346 348 350 352 353 354 356 358 359 360 362 363 364 365 366 367 368 370 373 375 376 377 378 380 381 382 383 385 386 387 388 389 390 391 392 394 395 396 398 399 400 401 402 404 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 424 425 428 429 431 433 436 437 438 439 440 442 443 444 445 446 447 448 449 450 451 452 453 454 455 457 458 459 461 462 464 465 466 467 468 470 471 472 473 474 475 476 477 478 480 482 483 485 486 487 488 490 491 492 493 494 496 497 498 499 7 | 8 | __INPUT__ 9 | 2-5, 7-9, 11-13, 16-19, 21-22, 24-26, 28-32, 34-41, 44-51, 53-54, 56-57, 59-66, 70, 72, 74, 77, 79, 81-82, 84-87, 89-90, 93-96, 98-99, 102, 104, 106-110, 112, 115-121, 123-125, 127-129, 132-137, 140-143, 145-157, 159-165, 168-173, 175, 178-182, 186, 188-200, 202, 204-214, 216-217, 219-223, 225, 228-230, 232-234, 236, 238-239, 241-245, 247-249, 251-252, 254-256, 260-263, 265-273, 275-277, 280, 282-283, 285-287, 289-292, 296-302, 305-306, 308-313, 315-319, 321, 323-339, 341-342, 344, 346, 348, 350, 352-354, 356, 358-360, 362-368, 370, 373, 375-378, 380-383, 385-392, 394-396, 398-402, 404, 406-421, 424-425, 428-429, 431, 433, 436-440, 442-455, 457-459, 461-462, 464-468, 470-478, 480, 482-483, 485-488, 490-494, 496-499. 10 | __OUTPUT__ 11 | -------------------------------------------------------------------------------- /sample/life.test: -------------------------------------------------------------------------------- 1 | 24 2 | o o o oo o o 3 | o o 4 | o o o 5 | o o o o 6 | o o o o oo 7 | __INPUT__ 8 | o 9 | o 10 | o 11 | __OUTPUT__ 12 | 29 13 | o o o oo 14 | o o oo o o 15 | o o o 16 | o o 17 | o o o o o o 18 | o o o 19 | o o o 20 | o oo o o 21 | o o o 22 | o o o oo 23 | o o o 24 | o 25 | o o o o o 26 | oo oo oo 27 | o o o oo 28 | o o 29 | 30 | __INPUT__ 31 | oo 32 | oo o o 33 | o o o 34 | oo 35 | 36 | 37 | 38 | 39 | 40 | 41 | oo 42 | oo 43 | __OUTPUT__ 44 | 25 45 | 46 | o o 47 | o 48 | o 49 | o 50 | o 51 | o 52 | o 53 | o 54 | o o 55 | o 56 | o o 57 | o o 58 | 59 | o ooo 60 | o 61 | 62 | __INPUT__ 63 | oo 64 | oo 65 | oo 66 | oo 67 | o ooo 68 | o 69 | oo oo 70 | o o 71 | oooooo 72 | o 73 | o o 74 | ooo 75 | __OUTPUT__ 76 | 30 77 | ooo o 78 | o 79 | oo 80 | oo o 81 | o o o 82 | 83 | __INPUT__ 84 | o 85 | oo oo 86 | 87 | o 88 | ooo o o 89 | o oo oo 90 | oo o o 91 | oo 92 | o o 93 | ooo ooo 94 | oooo o o o 95 | o oo 96 | ooo oo 97 | oo oo oo 98 | o ooo oo 99 | o oo 100 | oo o o 101 | o o 102 | __OUTPUT__ 103 | 201 104 | ooo 105 | o 106 | o 107 | 108 | 109 | oo 110 | oo 111 | o 112 | 113 | __INPUT__ 114 | o 115 | oo 116 | o o 117 | 118 | 119 | 120 | ooo 121 | o 122 | o 123 | __OUTPUT__ 124 | 100 125 | oooo 126 | o o 127 | o 128 | o o 129 | 130 | 131 | oo 132 | oo 133 | __INPUT__ 134 | oooo 135 | o o 136 | o 137 | o o 138 | 139 | 140 | oo 141 | oo 142 | __OUTPUT__ 143 | 99 144 | o 145 | oo 146 | o ooo 147 | 148 | __INPUT__ 149 | o 150 | o 151 | ooo ooo 152 | o o o 153 | o o 154 | o ooo 155 | o o 156 | o o 157 | __OUTPUT__ 158 | -------------------------------------------------------------------------------- /sample/sha.test: -------------------------------------------------------------------------------- 1 | A Crow, half-dead with thirst, came upon a Pitcher which had 2 | once been full of water; but when the Crow put its beak into the 3 | mouth of the Pitcher he found that only very little water was left 4 | in it, and that he could not reach far enough down to get at it. 5 | He tried, and he tried, but at last had to give up in despair. 6 | Then a thought came to him, and he took a pebble and dropped it 7 | into the Pitcher. Then he took another pebble and dropped it into 8 | the Pitcher. Then he took another pebble and dropped that into 9 | the Pitcher. Then he took another pebble and dropped that into 10 | the Pitcher. Then he took another pebble and dropped that into 11 | the Pitcher. Then he took another pebble and dropped that into 12 | the Pitcher. At last, at last, he saw the water mount up near 13 | him, and after casting in a few more pebbles he was able to quench 14 | his thirst and save his life. 15 | 16 | 17 | Little by little does the trick. 18 | __INPUT__ 19 | 6ab072e182a2cd21d0d2f644ce19219f47a021802abef342a3cf126c812086e7 20 | __OUTPUT__ 21 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 22 | __INPUT__ 23 | dabe4ad2e8e13263662b3f9ac30ade7f176ff7cf1efe1afc1fa4d9a21a9976fa 24 | __OUTPUT__ 25 | abc 26 | __INPUT__ 27 | ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad 28 | __OUTPUT__ 29 | abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq 30 | __INPUT__ 31 | 248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1 32 | __OUTPUT__ 33 | -------------------------------------------------------------------------------- /net/http/multipart.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # -*- coding: utf-8 -*- 3 | # 4 | # = net/http/multipart.rb 5 | # 6 | # Copyright (c) 2007 Hirofumi HONDA 7 | # 8 | # This program is free software. You can re-distribute and/or 9 | # modify this program under the same terms of ruby itself --- 10 | # Ruby Distribution License or GNU General Public License. 11 | # 12 | 13 | require 'net/http' 14 | begin 15 | require 'rubygems' 16 | require 'mime/types' 17 | rescue LoadError => e 18 | end 19 | 20 | module Net 21 | module HTTPHeader 22 | 23 | CR = "\015" 24 | LF = "\012" 25 | EOL = CR + LF 26 | 27 | def set_multipart_form_data( filepath = {}, params = {} ) 28 | 29 | boundary = "boundary" 30 | self.set_content_type 'multipart/form-data', { "boundary" => boundary } 31 | content = "" 32 | 33 | params.each do |key, value| 34 | value = [value] if value.class != Array 35 | value.each do |i| 36 | content << [ 37 | %Q|--#{boundary}|, 38 | %Q|Content-Disposition: form-data; name="#{key}"|, 39 | %Q||, 40 | %Q|#{i}| 41 | ].join(EOL) << EOL 42 | end 43 | end 44 | 45 | filepath.each do |key, value| 46 | value = [value] if value.class != Array 47 | value.each do |i| 48 | begin 49 | mime_type = MIME::Types.of(i).to_s 50 | rescue NameError => e 51 | ensure 52 | mime_type = "application/octet-stream" if (mime_type.nil? or mime_type.empty?) 53 | end 54 | content << [ 55 | %Q|--#{boundary}|, 56 | %Q|Content-Disposition: form-data; name="#{key}"; filename="#{File::basename(i)}"|, 57 | %Q|Content-Type: #{mime_type}|, 58 | %Q||, 59 | %Q|#{open(i).read}| 60 | ].join(EOL) << EOL 61 | end 62 | end 63 | 64 | content << %Q|--#{boundary}--| 65 | 66 | self.content_length = content.size 67 | self.body = content 68 | 69 | end 70 | end 71 | end 72 | 73 | if __FILE__==$0 74 | 75 | Net::HTTP.version_1_2 76 | http = Net::HTTP.start("localhost", 12380 ) 77 | req = Net::HTTP::Post.new("/attach.cgi") 78 | req.set_multipart_form_data({"attach_file" => ARGV[0]}, {"p" => "FrontPage", "command" => "edit", "attach" => "ファイルの添付"}) 79 | res = http.request(req) 80 | 81 | if res.class.superclass == Net::HTTPSuccess 82 | puts "OK" 83 | else 84 | puts "failed" 85 | end 86 | 87 | end 88 | -------------------------------------------------------------------------------- /cg/aa1.input: -------------------------------------------------------------------------------- 1 | 18 14 95 2 | 25 5 95 3 | 22 11 47 4 | 12 9 95 5 | 23 14 95 6 | 16 6 124 7 | 31 5 47 8 | 10 1 47 9 | 32 13 47 10 | 14 10 47 11 | 16 4 58 12 | 24 6 92 13 | 5 9 95 14 | 17 1 47 15 | 11 9 95 16 | 28 1 95 17 | 34 10 92 18 | 9 3 58 19 | 15 1 95 20 | 9 6 124 21 | 15 3 46 22 | 16 14 95 23 | 22 1 92 24 | 16 1 95 25 | 27 6 47 26 | 19 14 95 27 | 29 0 95 28 | 4 9 95 29 | 6 1 95 30 | 9 7 124 31 | 16 7 124 32 | 23 3 47 33 | 20 0 95 34 | 30 1 92 35 | 8 9 124 36 | 16 11 95 37 | 15 7 124 38 | 23 7 124 39 | 25 10 95 40 | 1 3 47 41 | 8 7 124 42 | 13 9 95 43 | 15 4 58 44 | 30 14 95 45 | 16 8 124 46 | 24 14 95 47 | 26 8 47 48 | 2 3 124 49 | 26 14 95 50 | 18 12 95 51 | 15 6 124 52 | 32 4 47 53 | 15 14 95 54 | 17 14 95 55 | 21 0 95 56 | 23 6 124 57 | 8 2 95 58 | 30 2 92 59 | 4 10 95 60 | 8 4 58 61 | 27 2 95 62 | 16 10 124 63 | 8 6 124 64 | 3 2 47 65 | 16 3 46 66 | 0 5 124 67 | 7 1 95 68 | 23 4 92 69 | 28 8 47 70 | 27 14 95 71 | 26 10 95 72 | 28 14 95 73 | 7 2 92 74 | 12 10 45 75 | 15 0 95 76 | 33 12 47 77 | 15 8 124 78 | 29 7 124 79 | 18 11 95 80 | 30 8 92 81 | 30 5 95 82 | 12 2 58 83 | 16 0 95 84 | 2 5 124 85 | 2 2 95 86 | 21 10 95 87 | 24 2 47 88 | 15 12 47 89 | 24 10 47 90 | 23 8 124 91 | 23 10 124 92 | 3 10 92 93 | 15 5 124 94 | 17 12 95 95 | 23 1 95 96 | 29 8 95 97 | 29 2 95 98 | 27 1 95 99 | 25 9 47 100 | 34 11 47 101 | 33 9 92 102 | 12 3 58 103 | 26 5 95 104 | 8 5 58 105 | 27 11 92 106 | 29 14 95 107 | 16 12 95 108 | 19 10 95 109 | 26 1 95 110 | 17 11 92 111 | 11 10 95 112 | 11 0 95 113 | 26 2 95 114 | 14 1 92 115 | 25 14 95 116 | 28 0 95 117 | 27 10 47 118 | 20 13 92 119 | 9 8 124 120 | 21 14 92 121 | 9 1 95 122 | 17 0 95 123 | 14 0 95 124 | 24 5 92 125 | 32 3 92 126 | 19 12 95 127 | 12 0 95 128 | 16 9 124 129 | 10 10 92 130 | 18 0 95 131 | 21 11 95 132 | 2 8 124 133 | 27 0 95 134 | 28 5 95 135 | 14 13 47 136 | 26 0 95 137 | 20 10 95 138 | 0 6 124 139 | 31 14 47 140 | 9 2 47 141 | 20 11 45 142 | 30 6 124 143 | 25 1 47 144 | 27 5 95 145 | 14 14 92 146 | 31 7 92 147 | 19 11 45 148 | 6 9 95 149 | 16 5 124 150 | 15 9 124 151 | 23 9 124 152 | 18 10 95 153 | 0 4 124 154 | 5 10 45 155 | 5 1 95 156 | 28 2 95 157 | 13 10 95 158 | 20 14 95 159 | 9 4 58 160 | 9 9 124 161 | 2 7 124 162 | 25 2 47 163 | 27 7 47 164 | 28 9 47 165 | 6 10 95 166 | 13 0 95 167 | 8 8 124 168 | 2 6 124 169 | 2 9 124 170 | 19 0 95 171 | 4 1 95 172 | 2 4 124 173 | 18 1 47 174 | 7 10 47 175 | 24 1 95 176 | 8 1 95 177 | 29 5 95 178 | 22 14 95 179 | 29 1 95 180 | 1 7 92 181 | 9 5 124 182 | 32 8 92 183 | 22 5 92 184 | 31 2 92 185 | -------------------------------------------------------------------------------- /cg/spiral6.output: -------------------------------------------------------------------------------- 1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 2 | 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 30 3 | 99 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 128 31 4 | 98 191 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 218 129 32 5 | 97 190 275 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 300 219 130 33 6 | 96 189 274 351 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 374 301 220 131 34 7 | 95 188 273 350 419 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 440 375 302 221 132 35 8 | 94 187 272 349 418 479 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 498 441 376 303 222 133 36 9 | 93 186 271 348 417 478 531 576 577 578 579 580 581 582 583 584 585 586 587 588 589 548 499 442 377 304 223 134 37 10 | 92 185 270 347 416 477 530 575 612 613 614 615 616 617 618 619 620 621 622 623 590 549 500 443 378 305 224 135 38 11 | 91 184 269 346 415 476 529 574 611 640 641 642 643 644 645 646 647 648 649 624 591 550 501 444 379 306 225 136 39 12 | 90 183 268 345 414 475 528 573 610 639 660 661 662 663 664 665 666 667 650 625 592 551 502 445 380 307 226 137 40 13 | 89 182 267 344 413 474 527 572 609 638 659 658 657 656 655 654 653 652 651 626 593 552 503 446 381 308 227 138 41 14 | 88 181 266 343 412 473 526 571 608 637 636 635 634 633 632 631 630 629 628 627 594 553 504 447 382 309 228 139 42 15 | 87 180 265 342 411 472 525 570 607 606 605 604 603 602 601 600 599 598 597 596 595 554 505 448 383 310 229 140 43 16 | 86 179 264 341 410 471 524 569 568 567 566 565 564 563 562 561 560 559 558 557 556 555 506 449 384 311 230 141 44 17 | 85 178 263 340 409 470 523 522 521 520 519 518 517 516 515 514 513 512 511 510 509 508 507 450 385 312 231 142 45 18 | 84 177 262 339 408 469 468 467 466 465 464 463 462 461 460 459 458 457 456 455 454 453 452 451 386 313 232 143 46 19 | 83 176 261 338 407 406 405 404 403 402 401 400 399 398 397 396 395 394 393 392 391 390 389 388 387 314 233 144 47 20 | 82 175 260 337 336 335 334 333 332 331 330 329 328 327 326 325 324 323 322 321 320 319 318 317 316 315 234 145 48 21 | 81 174 259 258 257 256 255 254 253 252 251 250 249 248 247 246 245 244 243 242 241 240 239 238 237 236 235 146 49 22 | 80 173 172 171 170 169 168 167 166 165 164 163 162 161 160 159 158 157 156 155 154 153 152 151 150 149 148 147 50 23 | 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 24 | -------------------------------------------------------------------------------- /cases.rb: -------------------------------------------------------------------------------- 1 | require 'ed' 2 | require 'db' 3 | 4 | def read_onefile_cases(testfile) 5 | puts "Loading testcases from #{testfile}" 6 | t = File.read(testfile) 7 | testcases = [] 8 | while t.sub!(/(.*?)\n__INPUT__\n/m, '') 9 | i = $1 10 | if !t.sub!(/(.*?)\n__OUTPUT__\n/m, '') 11 | raise "malformed test description file" 12 | end 13 | o = $1 14 | testcases << [i, o] 15 | end 16 | [testcases, t] 17 | end 18 | 19 | def get_onefile_cases(basename) 20 | testfile = basename + '.test' 21 | if !File.exist?(testfile) 22 | return nil 23 | end 24 | 25 | testcases, t = read_onefile_cases(testfile) 26 | 27 | # use codegolf's evaluation by default 28 | type = :cg 29 | if t =~ /ag$/ 30 | type = :ag 31 | elsif t =~ /exact$/ 32 | type = :exact 33 | end 34 | 35 | [type, testcases] 36 | end 37 | 38 | def get_files_cases(basepath) 39 | files = Dir["#{basepath}*.output"].sort 40 | if files.empty? 41 | return nil 42 | end 43 | 44 | puts "Loading testcases from #{basepath}*" 45 | testcases = [] 46 | files.each do |file| 47 | o = File.read(file) 48 | input_file = File.join(File.dirname(file), 49 | File.basename(file, '.output') + '.input') 50 | i = '' 51 | if File.exist?(input_file) 52 | i = File.read(input_file) 53 | end 54 | testcases << [i, o] 55 | end 56 | 57 | [:cg, testcases] 58 | end 59 | 60 | def get_ag_cases(basename, problem) 61 | if problem 62 | update_file2problem(basename, problem) 63 | else 64 | problem = file2problem(basename) 65 | end 66 | dummy, problem = ag_unescape(problem).split('?') 67 | puts "Loading testcases of '#{problem}'" 68 | db = db_ag(problem + '.db') 69 | 70 | testcases = [] 71 | testcases << [db['input'].to_s, db['output'].to_s] 72 | if db['output2'].to_s != '' || db['input2'].to_s != '' 73 | testcases << [db['input2'].to_s, db['output2'].to_s] 74 | end 75 | if db['output3'].to_s != '' || db['input3'].to_s != '' 76 | testcases << [db['input3'].to_s, db['output3'].to_s] 77 | end 78 | 79 | [:ag, testcases] 80 | end 81 | 82 | def get_spoj_cases(basename) 83 | testfile = spoj_file(basename.upcase) + '.test' 84 | if !File.exist?(testfile) 85 | return nil 86 | end 87 | testcases, t = read_onefile_cases(testfile) 88 | [:spoj, testcases] 89 | end 90 | 91 | def get_testcases(basename, problem) 92 | if !problem 93 | r = get_onefile_cases(basename) 94 | return r if r 95 | if $spoj_dir_regexp =~ Dir.pwd 96 | r = get_spoj_cases(basename) 97 | return r if r 98 | end 99 | r = get_files_cases(File.join('test', basename)) 100 | return r if r 101 | r = get_files_cases(File.join(SRC_DIR, 'cg', basename)) 102 | return r if r 103 | end 104 | get_ag_cases(basename, problem) 105 | end 106 | -------------------------------------------------------------------------------- /squeeze.rb: -------------------------------------------------------------------------------- 1 | # -*- coding: binary -*- 2 | 3 | if !String.method_defined?(:ord) 4 | class String 5 | def ord 6 | self[0] 7 | end 8 | end 9 | end 10 | 11 | def get_statistics(s) 12 | a=[0,0,0,0] 13 | an=/[a-zA-Z0-9]/ 14 | ws=/[ \t\n]/ 15 | s.each_byte{|x| 16 | s=x.chr 17 | a[an=~s ?2:ws=~s ?1: x<127&&x>32?3:0]+=1 18 | } 19 | a[1..-1] * '/' 20 | end 21 | 22 | class Squeezer 23 | def sharp 24 | @src.gsub!(/^#(?!!).*/, '') 25 | @src.gsub!(/ *# .*/, '') 26 | end 27 | 28 | def c99 29 | @src.gsub!(/ *\/\/.*/, '') 30 | @src.gsub!(/\/\*.*?\*\//m, '') 31 | end 32 | 33 | def d 34 | c99 35 | # cannot nest, incorrect 36 | @src.gsub!(/\/\+.*?\+\//, '') 37 | end 38 | 39 | def hs 40 | @src.gsub!(/ *--.*/, '') 41 | end 42 | 43 | def caml 44 | @src.gsub!(/\(\*.*?\*\)/m, '') 45 | end 46 | 47 | def blank 48 | @src.gsub!(/^\n/, '') 49 | end 50 | 51 | def last_ws 52 | @src.rstrip! 53 | end 54 | 55 | def trailing_ws 56 | @src.gsub!(/ +$/, '') 57 | end 58 | 59 | def leading_ws 60 | @src.gsub!(/^[ \t]+/, '') 61 | end 62 | 63 | def any_ret(t) 64 | @src.gsub!("#{t}\n", t) 65 | end 66 | 67 | def ret_any(t) 68 | @src.gsub!("\n#{t}", t) 69 | end 70 | 71 | def semi_ret 72 | any_ret(';') 73 | end 74 | 75 | def cond_ret 76 | # long_exp?true_exp:false_exp 77 | any_ret('?') 78 | any_ret(':') 79 | any_ret('&&') 80 | any_ret('||') 81 | end 82 | 83 | def bra_ret 84 | any_ret('{') 85 | end 86 | 87 | def cket_ret 88 | any_ret('}') 89 | end 90 | 91 | def ret_cket 92 | ret_any('}') 93 | end 94 | 95 | def bracket_ret 96 | bra_ret 97 | ret_cket 98 | end 99 | 100 | def initialize(filename) 101 | @ext = File.extname(filename) 102 | @base = File.basename(filename, @ext) 103 | @src = File.open(filename, "r:binary").read 104 | @orig_size = @src.size 105 | end 106 | 107 | def run 108 | [SRC_DIR, GOLF_DIR].each do |dir| 109 | squeezer = File.join(dir, 'squeezer', "#{@ext[1..-1]}.rb") 110 | if File.exist?(squeezer) 111 | eval(File.read(squeezer)) 112 | end 113 | end 114 | 115 | now = Time.now.strftime('-%Y-%m-%d-%H-%M-%S') 116 | squeezed = File.join(CODE_DIR, @base+now+@ext) 117 | File.open(squeezed, 'w') do |ofile| 118 | ofile.print(@src) 119 | end 120 | 121 | puts "#{@orig_size} => #{@src.size} (#{get_statistics(@src)})" 122 | if @ext == '.z8b' 123 | system("z80dasm -a -t -g0 #{squeezed} 2>-") 124 | elsif @ext == '.out' 125 | system("objdump -b binary -m i386 #{squeezed} 2>&-") 126 | else 127 | puts @src.gsub(/[\x00-\x09\x0b-\x1f\x7f-\xff]/n){'\\x%x'%$&.ord} 128 | end 129 | puts 130 | 131 | [squeezed, @src.size] 132 | end 133 | end 134 | 135 | def squeeze(filename) 136 | print 'Running squeezer... ' 137 | sq = Squeezer.new(filename) 138 | sq.run 139 | end -------------------------------------------------------------------------------- /cg/pascal1.output: -------------------------------------------------------------------------------- 1 | 1 2 | 1 1 3 | 1 2 1 4 | 1 3 3 1 5 | 1 4 6 4 1 6 | 1 5 10 10 5 1 7 | 1 6 15 20 15 6 1 8 | 1 7 21 35 35 21 7 1 9 | 1 8 28 56 70 56 28 8 1 10 | 1 9 36 84 126 126 84 36 9 1 11 | 1 10 45 120 210 252 210 120 45 10 1 12 | 1 11 55 165 330 462 462 330 165 55 11 1 13 | 1 12 66 220 495 792 924 792 495 220 66 12 1 14 | 1 13 78 286 715 1287 1716 1716 1287 715 286 78 13 1 15 | 1 14 91 364 1001 2002 3003 3432 3003 2002 1001 364 91 14 1 16 | 1 15 105 455 1365 3003 5005 6435 6435 5005 3003 1365 455 105 15 1 17 | 1 16 120 560 1820 4368 8008 11440 12870 11440 8008 4368 1820 560 120 16 1 18 | 1 17 136 680 2380 6188 12376 19448 24310 24310 19448 12376 6188 2380 680 136 17 1 19 | 1 18 153 816 3060 8568 18564 31824 43758 48620 43758 31824 18564 8568 3060 816 153 18 1 20 | 1 19 171 969 3876 11628 27132 50388 75582 92378 92378 75582 50388 27132 11628 3876 969 171 19 1 21 | 1 20 190 1140 4845 15504 38760 77520 125970 167960 184756 167960 125970 77520 38760 15504 4845 1140 190 20 1 22 | 1 21 210 1330 5985 20349 54264 116280 203490 293930 352716 352716 293930 203490 116280 54264 20349 5985 1330 210 21 1 23 | 1 22 231 1540 7315 26334 74613 170544 319770 497420 646646 705432 646646 497420 319770 170544 74613 26334 7315 1540 231 22 1 24 | 1 23 253 1771 8855 33649 100947 245157 490314 817190 1144066 1352078 1352078 1144066 817190 490314 245157 100947 33649 8855 1771 253 23 1 25 | 1 24 276 2024 10626 42504 134596 346104 735471 1307504 1961256 2496144 2704156 2496144 1961256 1307504 735471 346104 134596 42504 10626 2024 276 24 1 26 | 1 25 300 2300 12650 53130 177100 480700 1081575 2042975 3268760 4457400 5200300 5200300 4457400 3268760 2042975 1081575 480700 177100 53130 12650 2300 300 25 1 27 | 1 26 325 2600 14950 65780 230230 657800 1562275 3124550 5311735 7726160 9657700 10400600 9657700 7726160 5311735 3124550 1562275 657800 230230 65780 14950 2600 325 26 1 28 | 1 27 351 2925 17550 80730 296010 888030 2220075 4686825 8436285 13037895 17383860 20058300 20058300 17383860 13037895 8436285 4686825 2220075 888030 296010 80730 17550 2925 351 27 1 29 | 1 28 378 3276 20475 98280 376740 1184040 3108105 6906900 13123110 21474180 30421755 37442160 40116600 37442160 30421755 21474180 13123110 6906900 3108105 1184040 376740 98280 20475 3276 378 28 1 30 | 1 29 406 3654 23751 118755 475020 1560780 4292145 10015005 20030010 34597290 51895935 67863915 77558760 77558760 67863915 51895935 34597290 20030010 10015005 4292145 1560780 475020 118755 23751 3654 406 29 1 31 | 1 30 435 4060 27405 142506 593775 2035800 5852925 14307150 30045015 54627300 86493225 119759850 145422675 155117520 145422675 119759850 86493225 54627300 30045015 14307150 5852925 2035800 593775 142506 27405 4060 435 30 1 32 | 1 31 465 4495 31465 169911 736281 2629575 7888725 20160075 44352165 84672315 141120525 206253075 265182525 300540195 300540195 265182525 206253075 141120525 84672315 44352165 20160075 7888725 2629575 736281 169911 31465 4495 465 31 1 33 | 1 32 496 4960 35960 201376 906192 3365856 10518300 28048800 64512240 129024480 225792840 347373600 471435600 565722720 601080390 565722720 471435600 347373600 225792840 129024480 64512240 28048800 10518300 3365856 906192 201376 35960 4960 496 32 1 34 | 1 33 528 5456 40920 237336 1107568 4272048 13884156 38567100 92561040 193536720 354817320 573166440 818809200 1037158320 1166803110 1166803110 1037158320 818809200 573166440 354817320 193536720 92561040 38567100 13884156 4272048 1107568 237336 40920 5456 528 33 1 35 | -------------------------------------------------------------------------------- /sample/pascal.test: -------------------------------------------------------------------------------- 1 | 2 | __INPUT__ 3 | 1 4 | 1 1 5 | 1 2 1 6 | 1 3 3 1 7 | 1 4 6 4 1 8 | 1 5 10 10 5 1 9 | 1 6 15 20 15 6 1 10 | 1 7 21 35 35 21 7 1 11 | 1 8 28 56 70 56 28 8 1 12 | 1 9 36 84 126 126 84 36 9 1 13 | 1 10 45 120 210 252 210 120 45 10 1 14 | 1 11 55 165 330 462 462 330 165 55 11 1 15 | 1 12 66 220 495 792 924 792 495 220 66 12 1 16 | 1 13 78 286 715 1287 1716 1716 1287 715 286 78 13 1 17 | 1 14 91 364 1001 2002 3003 3432 3003 2002 1001 364 91 14 1 18 | 1 15 105 455 1365 3003 5005 6435 6435 5005 3003 1365 455 105 15 1 19 | 1 16 120 560 1820 4368 8008 11440 12870 11440 8008 4368 1820 560 120 16 1 20 | 1 17 136 680 2380 6188 12376 19448 24310 24310 19448 12376 6188 2380 680 136 17 1 21 | 1 18 153 816 3060 8568 18564 31824 43758 48620 43758 31824 18564 8568 3060 816 153 18 1 22 | 1 19 171 969 3876 11628 27132 50388 75582 92378 92378 75582 50388 27132 11628 3876 969 171 19 1 23 | 1 20 190 1140 4845 15504 38760 77520 125970 167960 184756 167960 125970 77520 38760 15504 4845 1140 190 20 1 24 | 1 21 210 1330 5985 20349 54264 116280 203490 293930 352716 352716 293930 203490 116280 54264 20349 5985 1330 210 21 1 25 | 1 22 231 1540 7315 26334 74613 170544 319770 497420 646646 705432 646646 497420 319770 170544 74613 26334 7315 1540 231 22 1 26 | 1 23 253 1771 8855 33649 100947 245157 490314 817190 1144066 1352078 1352078 1144066 817190 490314 245157 100947 33649 8855 1771 253 23 1 27 | 1 24 276 2024 10626 42504 134596 346104 735471 1307504 1961256 2496144 2704156 2496144 1961256 1307504 735471 346104 134596 42504 10626 2024 276 24 1 28 | 1 25 300 2300 12650 53130 177100 480700 1081575 2042975 3268760 4457400 5200300 5200300 4457400 3268760 2042975 1081575 480700 177100 53130 12650 2300 300 25 1 29 | 1 26 325 2600 14950 65780 230230 657800 1562275 3124550 5311735 7726160 9657700 10400600 9657700 7726160 5311735 3124550 1562275 657800 230230 65780 14950 2600 325 26 1 30 | 1 27 351 2925 17550 80730 296010 888030 2220075 4686825 8436285 13037895 17383860 20058300 20058300 17383860 13037895 8436285 4686825 2220075 888030 296010 80730 17550 2925 351 27 1 31 | 1 28 378 3276 20475 98280 376740 1184040 3108105 6906900 13123110 21474180 30421755 37442160 40116600 37442160 30421755 21474180 13123110 6906900 3108105 1184040 376740 98280 20475 3276 378 28 1 32 | 1 29 406 3654 23751 118755 475020 1560780 4292145 10015005 20030010 34597290 51895935 67863915 77558760 77558760 67863915 51895935 34597290 20030010 10015005 4292145 1560780 475020 118755 23751 3654 406 29 1 33 | 1 30 435 4060 27405 142506 593775 2035800 5852925 14307150 30045015 54627300 86493225 119759850 145422675 155117520 145422675 119759850 86493225 54627300 30045015 14307150 5852925 2035800 593775 142506 27405 4060 435 30 1 34 | 1 31 465 4495 31465 169911 736281 2629575 7888725 20160075 44352165 84672315 141120525 206253075 265182525 300540195 300540195 265182525 206253075 141120525 84672315 44352165 20160075 7888725 2629575 736281 169911 31465 4495 465 31 1 35 | 1 32 496 4960 35960 201376 906192 3365856 10518300 28048800 64512240 129024480 225792840 347373600 471435600 565722720 601080390 565722720 471435600 347373600 225792840 129024480 64512240 28048800 10518300 3365856 906192 201376 35960 4960 496 32 1 36 | 1 33 528 5456 40920 237336 1107568 4272048 13884156 38567100 92561040 193536720 354817320 573166440 818809200 1037158320 1166803110 1166803110 1037158320 818809200 573166440 354817320 193536720 92561040 38567100 13884156 4272048 1107568 237336 40920 5456 528 33 1 37 | __OUTPUT__ 38 | -------------------------------------------------------------------------------- /cg/cross4.output: -------------------------------------------------------------------------------- 1 | #################################### #################################### 2 | #1 # #2 # #3 # #4 # #5 # #6 # #7 # #8 # 3 | # # # # # # # # # # # # # # # # 4 | #################################### #################################### 5 | # ###### ###### ###### # # ###### ###### ###### # 6 | # ###### ###### ###### # # ###### ###### ###### # 7 | ############################################################################ 8 | #9 # # # # ######10 # # # # # # # # # 9 | # # # # # ###### # # # # # # # # # 10 | ############################################################################ 11 | # ###### ###### ###### ###### ###### ###### ###### # 12 | # ###### ###### ###### ###### ###### ###### ###### # 13 | ############################################################################ 14 | #11 # # # # # # # # # ######12 # # # # 15 | # # # # # # # # # # ###### # # # # 16 | ############################################################################ 17 | # # # ###### ################ ######13 ###### ###### # 18 | # # # ###### ################ ###### ###### ###### # 19 | ###### ################################################################## 20 | #14 # # #15 # # # # # # # # # 21 | # # # # # # # # # # # # # 22 | ###### ################################################################## 23 | #16 # #17 ###### ###### ###### ###### ###### # # # 24 | # # # ###### ###### ###### ###### ###### # # # 25 | ################################################################## ###### 26 | #18 # # # # # # # # # # # # 27 | # # # # # # # # # # # # # 28 | ################################################################## ###### 29 | # ###### ###### ###### ################ ######19 # #20 # 30 | # ###### ###### ###### ################ ###### # # # 31 | ############################################################################ 32 | #21 # # # ######22 # # #23 # # # # # # # 33 | # # # # ###### # # # # # # # # # # 34 | ############################################################################ 35 | # ###### ######24 ###### ###### ###### ###### ###### # 36 | # ###### ###### ###### ###### ###### ###### ###### # 37 | ############################################################################ 38 | #25 # # # # # # # # ######26 # # # # # 39 | # # # # # # # # # ###### # # # # # 40 | ############################################################################ 41 | # ###### ###### ###### # # ###### ###### ###### # 42 | # ###### ###### ###### # # ###### ###### ###### # 43 | #################################### #################################### 44 | #27 # # # # # # # #28 # # # # # # # 45 | # # # # # # # # # # # # # # # # 46 | #################################### #################################### 47 | -------------------------------------------------------------------------------- /cg/crossword3.output: -------------------------------------------------------------------------------- 1 | #################################### #################################### 2 | #1 # #2 # #3 # #4 # #5 # #6 # #7 # #8 # 3 | # # # # # # # # # # # # # # # # 4 | #################################### #################################### 5 | # ###### ###### ###### # # ###### ###### ###### # 6 | # ###### ###### ###### # # ###### ###### ###### # 7 | ############################################################################ 8 | #9 # # # # ######10 # # # # # # # # # 9 | # # # # # ###### # # # # # # # # # 10 | ############################################################################ 11 | # ###### ###### ###### ###### ###### ###### ###### # 12 | # ###### ###### ###### ###### ###### ###### ###### # 13 | ############################################################################ 14 | #11 # # # # # # # # # ######12 # # # # 15 | # # # # # # # # # # ###### # # # # 16 | ############################################################################ 17 | # # # ###### ################ ######13 ###### ###### # 18 | # # # ###### ################ ###### ###### ###### # 19 | ###### ################################################################## 20 | #14 # # #15 # # # # # # # # # 21 | # # # # # # # # # # # # # 22 | ###### ################################################################## 23 | #16 # #17 ###### ###### ###### ###### ###### # # # 24 | # # # ###### ###### ###### ###### ###### # # # 25 | ################################################################## ###### 26 | #18 # # # # # # # # # # # # 27 | # # # # # # # # # # # # # 28 | ################################################################## ###### 29 | # ###### ###### ###### ################ ######19 # #20 # 30 | # ###### ###### ###### ################ ###### # # # 31 | ############################################################################ 32 | #21 # # # ######22 # # #23 # # # # # # # 33 | # # # # ###### # # # # # # # # # # 34 | ############################################################################ 35 | # ###### ######24 ###### ###### ###### ###### ###### # 36 | # ###### ###### ###### ###### ###### ###### ###### # 37 | ############################################################################ 38 | #25 # # # # # # # # ######26 # # # # # 39 | # # # # # # # # # ###### # # # # # 40 | ############################################################################ 41 | # ###### ###### ###### # # ###### ###### ###### # 42 | # ###### ###### ###### # # ###### ###### ###### # 43 | #################################### #################################### 44 | #27 # # # # # # # #28 # # # # # # # 45 | # # # # # # # # # # # # # # # # 46 | #################################### #################################### 47 | -------------------------------------------------------------------------------- /execute.rb: -------------------------------------------------------------------------------- 1 | require 'open3' 2 | 3 | require 'db' 4 | 5 | def show_error_none(expect, output) 6 | puts "\nOutput:\n#{output}\n\nExpect:\n#{expect}\n\n" 7 | end 8 | 9 | def show_error_diff(expect, output) 10 | File.open('output', 'w') do |ofile| 11 | ofile.puts(output) 12 | end 13 | File.open('expect', 'w') do |ofile| 14 | ofile.puts(expect) 15 | end 16 | system("diff -u expect output") 17 | end 18 | 19 | def show_error(expect, output) 20 | output.gsub!("\n", "\\n\n") 21 | expect.gsub!(/\n/, "\\n\n") 22 | if $diff_style == :diff 23 | show_error_diff(expect, output) 24 | elsif $diff_style == :all 25 | show_error_none(expect, output) 26 | puts 'Diff:' 27 | show_error_diff(expect, output) 28 | else 29 | show_error_none(expect, output) 30 | end 31 | end 32 | 33 | def execute(type, filename, testcases, no_check) 34 | ext = File.extname(filename)[1..-1] 35 | FileUtils.rm_rf(TEST_DIR) 36 | FileUtils.mkdir_p(TEST_DIR) 37 | testfile = File.join(TEST_DIR, 'test.' + ext) 38 | File.open(testfile, 'w') do |ofile| 39 | ofile.print(File.read(filename)) 40 | end 41 | 42 | failed = false 43 | Dir.chdir(TEST_DIR) do 44 | if (File.exist?(compiler = File.join(GOLF_DIR, 'executors', "_#{ext}")) || 45 | File.exist?(compiler = File.join(SRC_DIR, 'executors', "_#{ext}"))) 46 | print 'Compiling... ' 47 | cmd = "#{compiler} '#{testfile}' '#{filename}'" 48 | if $suppress_stderr 49 | cmd += ' 2>-' 50 | end 51 | if system(cmd) 52 | puts 'OK' 53 | else 54 | puts 'FAILED' 55 | return false 56 | end 57 | end 58 | 59 | if (!(executor = $executor) && 60 | !File.exist?(executor = File.join(GOLF_DIR, 'executors', ext)) && 61 | !File.exist?(executor = File.join(SRC_DIR, 'executors', ext))) 62 | raise "No executor found for #{filename}" 63 | end 64 | 65 | n = 0 66 | testcases.each do |i, e| 67 | i.gsub!("\r\n", "\n") 68 | e.gsub!("\r\n", "\n") 69 | if no_check 70 | puts "\n=== Test ##{n+=1} ===" 71 | else 72 | print "Test ##{n+=1}... " 73 | end 74 | STDOUT.flush 75 | cmd = "#{executor} '#{testfile}'" 76 | cmd += " '#{filename}'" if !$executor 77 | if $suppress_stderr 78 | cmd += ' 2>-' 79 | end 80 | start = Time.now 81 | 82 | popen_mode = no_check ? 'w' : 'r+' 83 | 84 | IO.popen(cmd, popen_mode) do |pipe| 85 | if ext == 'sed' && i.empty? 86 | i = "\n" 87 | end 88 | 89 | if i.empty? 90 | pipe.close_write 91 | end 92 | 93 | o = '' 94 | while true 95 | sel = IO.select([pipe], i.empty? ? [] : [pipe], nil) 96 | if sel[0][0] 97 | begin 98 | b = pipe.readpartial(4096) 99 | o += b 100 | rescue 101 | break 102 | end 103 | end 104 | if sel[1][0] 105 | begin 106 | wb = pipe.write(i[0, 4096]) 107 | i = i[wb..-1] 108 | if i.empty? 109 | pipe.close_write 110 | end 111 | rescue Errno::EPIPE 112 | end 113 | end 114 | end 115 | 116 | if no_check 117 | break 118 | end 119 | 120 | case type 121 | when :ag 122 | e.rstrip! 123 | o.rstrip! 124 | when :cg 125 | e.strip! 126 | o.strip! 127 | end 128 | o.gsub!("\r\n", "\n") 129 | 130 | if o == e 131 | puts "OK #{Time.now-start}" 132 | else 133 | puts 'FAILED' 134 | failed = true 135 | show_error(e, o) 136 | end 137 | end 138 | end 139 | end 140 | puts 141 | !failed 142 | end 143 | -------------------------------------------------------------------------------- /cg/total1.input: -------------------------------------------------------------------------------- 1 | 88 2 | 92 35 3 | 91 12 66 4 | 94 27 54 93 5 | 90 96 95 13 07 6 | 44 33 37 33 23 91 7 | 32 28 03 81 50 22 53 8 | 19 82 63 11 83 35 73 02 9 | 97 35 98 67 02 03 64 47 99 10 | 66 16 79 28 04 10 77 63 43 38 11 | 60 80 33 50 19 73 21 81 68 68 10 12 | 28 07 89 78 23 75 83 86 04 29 30 26 13 | 93 67 91 19 56 41 07 93 59 34 21 12 18 14 | 78 68 33 64 02 15 01 90 43 45 81 48 62 85 15 | 33 35 88 74 84 11 00 24 96 75 34 04 19 91 70 16 | 53 27 08 90 33 78 80 49 81 53 12 80 98 84 20 57 17 | 30 66 88 54 60 86 27 98 34 79 19 67 02 65 29 00 02 18 | 09 38 32 41 98 54 25 67 41 43 82 32 27 15 70 70 24 38 19 | 09 26 31 80 96 73 09 99 97 05 07 19 04 66 64 54 83 31 88 20 | 01 42 58 78 84 11 98 62 07 30 40 06 44 44 15 41 16 20 15 96 21 | 08 06 35 75 57 82 55 97 58 38 23 08 23 87 76 00 52 80 57 58 86 22 | 39 59 91 52 28 28 11 39 09 62 75 98 03 63 32 03 23 63 86 35 24 33 23 | 19 15 41 17 02 80 70 46 06 73 22 62 27 44 48 40 50 41 88 31 77 99 17 24 | 16 73 28 61 54 41 27 91 10 97 78 98 46 35 29 41 69 34 81 95 98 10 98 32 25 | 31 08 98 16 18 55 47 03 05 46 36 77 66 59 06 98 51 09 78 45 27 64 37 58 46 26 | 71 32 30 12 36 17 40 54 55 83 49 60 92 38 71 82 78 53 79 50 48 18 64 53 68 08 27 | 94 09 53 08 11 32 63 93 63 39 39 19 43 61 69 72 35 43 79 42 24 11 64 62 42 53 91 28 | 38 67 54 09 64 39 97 06 76 54 64 80 59 50 39 29 90 78 67 62 40 32 09 10 97 28 81 09 29 | 22 54 48 48 62 69 02 20 15 12 82 04 32 01 62 42 71 66 87 68 63 85 68 64 77 50 30 82 31 30 | 15 72 97 10 49 79 13 09 28 68 81 67 92 36 80 98 24 20 82 36 06 93 71 71 67 44 51 57 18 06 31 | 48 78 62 40 97 29 93 69 15 05 44 73 08 70 78 44 13 78 40 25 77 13 17 92 60 03 99 83 86 56 45 32 | 62 87 91 42 36 42 56 62 19 18 96 22 01 10 77 17 39 34 46 26 84 93 20 76 75 10 76 09 32 16 40 91 33 | 11 51 48 82 31 38 84 58 72 17 21 61 50 13 65 12 70 32 90 51 22 30 99 44 68 62 11 67 31 11 84 42 59 34 | 45 62 20 58 42 29 38 98 17 02 98 86 83 73 37 51 76 82 27 26 49 85 21 05 47 70 34 80 99 63 03 59 05 47 35 | 66 47 51 52 07 82 41 28 41 90 98 08 21 20 62 04 21 16 04 98 97 64 12 65 30 17 36 79 13 68 89 77 70 93 71 36 | 21 83 77 03 09 51 54 37 53 51 37 65 74 48 93 74 17 26 59 04 11 48 76 84 02 94 49 51 05 77 74 61 23 16 52 99 37 | 58 31 45 04 23 03 83 20 11 21 27 10 48 43 92 72 68 90 39 75 51 35 89 41 71 25 82 26 23 61 76 16 44 05 58 85 47 38 | 27 34 46 82 57 96 43 21 19 28 10 44 50 23 08 76 58 62 91 90 72 08 38 14 51 38 60 95 33 74 39 49 00 03 37 68 82 34 39 | 37 66 14 09 78 61 25 55 26 76 82 11 64 55 57 37 30 73 58 22 95 40 41 06 20 80 51 88 35 76 10 18 49 62 75 60 59 81 68 40 | 79 91 35 18 54 03 54 97 83 30 23 37 13 04 09 90 81 17 54 44 76 74 08 68 89 67 00 78 60 51 19 63 67 50 80 21 60 78 07 61 41 | 05 72 43 54 50 07 16 08 57 16 29 71 12 72 98 12 57 39 76 32 83 68 85 83 83 01 67 12 14 84 41 70 56 12 64 55 93 47 96 66 37 42 | 50 29 94 34 81 48 20 68 60 78 13 17 97 17 46 44 63 67 47 21 07 25 87 45 30 74 36 81 23 00 68 51 24 90 14 50 84 19 56 79 03 40 43 | 79 32 46 12 03 56 66 46 77 79 73 93 13 17 55 93 19 57 17 53 51 14 72 02 99 74 68 21 05 41 30 06 98 93 83 02 37 11 13 34 82 84 81 44 | 54 13 46 61 58 46 33 97 69 28 51 19 79 29 53 54 74 43 41 29 75 66 49 33 10 08 23 08 93 01 97 92 87 21 99 19 31 82 99 29 26 90 93 48 45 | 27 26 06 09 32 28 71 97 93 62 41 69 21 80 45 79 93 90 03 95 67 77 18 98 48 42 68 69 01 10 45 95 20 04 68 32 60 79 85 71 82 65 22 69 15 46 | 22 75 98 08 53 18 84 30 09 03 08 88 38 43 72 63 21 98 07 75 95 30 94 80 09 05 31 25 73 00 64 69 29 43 03 02 39 32 53 44 43 19 55 27 15 95 47 | 62 91 09 09 45 00 90 32 34 77 84 06 09 38 89 38 11 45 52 59 34 70 51 45 10 25 70 22 83 62 91 00 35 16 57 63 83 14 94 00 21 82 88 99 95 58 44 48 | 35 48 34 09 20 33 74 18 21 28 31 20 37 68 55 03 87 24 43 65 46 21 77 60 64 08 14 54 38 01 96 80 71 83 42 54 42 81 89 40 83 93 22 49 27 31 47 43 49 | 62 25 75 49 55 71 14 26 66 25 99 10 56 12 20 88 67 32 43 52 00 06 84 76 81 61 32 55 93 76 59 53 65 80 05 22 45 01 30 72 28 80 43 07 43 95 26 10 21 50 | 65 51 67 07 04 74 04 11 38 57 59 02 52 33 61 75 63 88 30 17 70 19 04 93 80 20 18 08 62 36 69 54 67 68 41 52 05 03 23 74 43 78 68 47 77 63 61 72 38 22 51 | -------------------------------------------------------------------------------- /sample/total.test: -------------------------------------------------------------------------------- 1 | 88 2 | 92 35 3 | 91 12 66 4 | 94 27 54 93 5 | 90 96 95 13 07 6 | 44 33 37 33 23 91 7 | 32 28 03 81 50 22 53 8 | 19 82 63 11 83 35 73 02 9 | 97 35 98 67 02 03 64 47 99 10 | 66 16 79 28 04 10 77 63 43 38 11 | 60 80 33 50 19 73 21 81 68 68 10 12 | 28 07 89 78 23 75 83 86 04 29 30 26 13 | 93 67 91 19 56 41 07 93 59 34 21 12 18 14 | 78 68 33 64 02 15 01 90 43 45 81 48 62 85 15 | 33 35 88 74 84 11 00 24 96 75 34 04 19 91 70 16 | 53 27 08 90 33 78 80 49 81 53 12 80 98 84 20 57 17 | 30 66 88 54 60 86 27 98 34 79 19 67 02 65 29 00 02 18 | 09 38 32 41 98 54 25 67 41 43 82 32 27 15 70 70 24 38 19 | 09 26 31 80 96 73 09 99 97 05 07 19 04 66 64 54 83 31 88 20 | 01 42 58 78 84 11 98 62 07 30 40 06 44 44 15 41 16 20 15 96 21 | 08 06 35 75 57 82 55 97 58 38 23 08 23 87 76 00 52 80 57 58 86 22 | 39 59 91 52 28 28 11 39 09 62 75 98 03 63 32 03 23 63 86 35 24 33 23 | 19 15 41 17 02 80 70 46 06 73 22 62 27 44 48 40 50 41 88 31 77 99 17 24 | 16 73 28 61 54 41 27 91 10 97 78 98 46 35 29 41 69 34 81 95 98 10 98 32 25 | 31 08 98 16 18 55 47 03 05 46 36 77 66 59 06 98 51 09 78 45 27 64 37 58 46 26 | 71 32 30 12 36 17 40 54 55 83 49 60 92 38 71 82 78 53 79 50 48 18 64 53 68 08 27 | 94 09 53 08 11 32 63 93 63 39 39 19 43 61 69 72 35 43 79 42 24 11 64 62 42 53 91 28 | 38 67 54 09 64 39 97 06 76 54 64 80 59 50 39 29 90 78 67 62 40 32 09 10 97 28 81 09 29 | 22 54 48 48 62 69 02 20 15 12 82 04 32 01 62 42 71 66 87 68 63 85 68 64 77 50 30 82 31 30 | 15 72 97 10 49 79 13 09 28 68 81 67 92 36 80 98 24 20 82 36 06 93 71 71 67 44 51 57 18 06 31 | 48 78 62 40 97 29 93 69 15 05 44 73 08 70 78 44 13 78 40 25 77 13 17 92 60 03 99 83 86 56 45 32 | 62 87 91 42 36 42 56 62 19 18 96 22 01 10 77 17 39 34 46 26 84 93 20 76 75 10 76 09 32 16 40 91 33 | 11 51 48 82 31 38 84 58 72 17 21 61 50 13 65 12 70 32 90 51 22 30 99 44 68 62 11 67 31 11 84 42 59 34 | 45 62 20 58 42 29 38 98 17 02 98 86 83 73 37 51 76 82 27 26 49 85 21 05 47 70 34 80 99 63 03 59 05 47 35 | 66 47 51 52 07 82 41 28 41 90 98 08 21 20 62 04 21 16 04 98 97 64 12 65 30 17 36 79 13 68 89 77 70 93 71 36 | 21 83 77 03 09 51 54 37 53 51 37 65 74 48 93 74 17 26 59 04 11 48 76 84 02 94 49 51 05 77 74 61 23 16 52 99 37 | 58 31 45 04 23 03 83 20 11 21 27 10 48 43 92 72 68 90 39 75 51 35 89 41 71 25 82 26 23 61 76 16 44 05 58 85 47 38 | 27 34 46 82 57 96 43 21 19 28 10 44 50 23 08 76 58 62 91 90 72 08 38 14 51 38 60 95 33 74 39 49 00 03 37 68 82 34 39 | 37 66 14 09 78 61 25 55 26 76 82 11 64 55 57 37 30 73 58 22 95 40 41 06 20 80 51 88 35 76 10 18 49 62 75 60 59 81 68 40 | 79 91 35 18 54 03 54 97 83 30 23 37 13 04 09 90 81 17 54 44 76 74 08 68 89 67 00 78 60 51 19 63 67 50 80 21 60 78 07 61 41 | 05 72 43 54 50 07 16 08 57 16 29 71 12 72 98 12 57 39 76 32 83 68 85 83 83 01 67 12 14 84 41 70 56 12 64 55 93 47 96 66 37 42 | 50 29 94 34 81 48 20 68 60 78 13 17 97 17 46 44 63 67 47 21 07 25 87 45 30 74 36 81 23 00 68 51 24 90 14 50 84 19 56 79 03 40 43 | 79 32 46 12 03 56 66 46 77 79 73 93 13 17 55 93 19 57 17 53 51 14 72 02 99 74 68 21 05 41 30 06 98 93 83 02 37 11 13 34 82 84 81 44 | 54 13 46 61 58 46 33 97 69 28 51 19 79 29 53 54 74 43 41 29 75 66 49 33 10 08 23 08 93 01 97 92 87 21 99 19 31 82 99 29 26 90 93 48 45 | 27 26 06 09 32 28 71 97 93 62 41 69 21 80 45 79 93 90 03 95 67 77 18 98 48 42 68 69 01 10 45 95 20 04 68 32 60 79 85 71 82 65 22 69 15 46 | 22 75 98 08 53 18 84 30 09 03 08 88 38 43 72 63 21 98 07 75 95 30 94 80 09 05 31 25 73 00 64 69 29 43 03 02 39 32 53 44 43 19 55 27 15 95 47 | 62 91 09 09 45 00 90 32 34 77 84 06 09 38 89 38 11 45 52 59 34 70 51 45 10 25 70 22 83 62 91 00 35 16 57 63 83 14 94 00 21 82 88 99 95 58 44 48 | 35 48 34 09 20 33 74 18 21 28 31 20 37 68 55 03 87 24 43 65 46 21 77 60 64 08 14 54 38 01 96 80 71 83 42 54 42 81 89 40 83 93 22 49 27 31 47 43 49 | 62 25 75 49 55 71 14 26 66 25 99 10 56 12 20 88 67 32 43 52 00 06 84 76 81 61 32 55 93 76 59 53 65 80 05 22 45 01 30 72 28 80 43 07 43 95 26 10 21 50 | 65 51 67 07 04 74 04 11 38 57 59 02 52 33 61 75 63 88 30 17 70 19 04 93 80 20 18 08 62 36 69 54 67 68 41 52 05 03 23 74 43 78 68 47 77 63 61 72 38 22 51 | __INPUT__ 52 | 3682 53 | __OUTPUT__ 54 | -------------------------------------------------------------------------------- /sample/bf.test: -------------------------------------------------------------------------------- 1 | >+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-] 2 | <.>+++++++++++[<++++++++>-]<-.--------.+++.------.--------.[-]>++++++++[<++++>- 3 | ]<+.[-]++++++++++. 4 | __INPUT__ 5 | Hello world! 6 | __OUTPUT__ 7 | +++[>+++++<-]>[>+>+++>+>++>+++++>++<[++<]>---]>->-.[>++>+<<--]>--.--.+.>>>++.<< 8 | .<------.+.+++++.>>-.<++++.<--.>>>.<<---.<.-->-.>+.[+++++.---<]>>[.--->]<<.<+.+ 9 | +.++>+++[.<][.]<++. 10 | __INPUT__ 11 | Just another brainfuck hacker. 12 | __OUTPUT__ 13 | ++++[>+++++<-]>[<+++++>-]+<+[>[>+>+<<-]++>>[<<+>>-]>>>[-]++>[-]+>>>+[[-]++++++> 14 | >>]<<<[[<++++++++<++>>-]+<.<[>----<-]<]<<[>>>>>[>>>[-]+++++++++<[>-<-]+++++++++ 15 | >[-[<->-]+[<<<]]<[>+<-]>]<<-]<<-] 16 | __INPUT__ 17 | 0 18 | 1 19 | 4 20 | 9 21 | 16 22 | 25 23 | 36 24 | 49 25 | 64 26 | 81 27 | 100 28 | 121 29 | 144 30 | 169 31 | 196 32 | 225 33 | 256 34 | 289 35 | 324 36 | 361 37 | 400 38 | 441 39 | 484 40 | 529 41 | 576 42 | 625 43 | 676 44 | 729 45 | 784 46 | 841 47 | 900 48 | 961 49 | 1024 50 | 1089 51 | 1156 52 | 1225 53 | 1296 54 | 1369 55 | 1444 56 | 1521 57 | 1600 58 | 1681 59 | 1764 60 | 1849 61 | 1936 62 | 2025 63 | 2116 64 | 2209 65 | 2304 66 | 2401 67 | 2500 68 | 2601 69 | 2704 70 | 2809 71 | 2916 72 | 3025 73 | 3136 74 | 3249 75 | 3364 76 | 3481 77 | 3600 78 | 3721 79 | 3844 80 | 3969 81 | 4096 82 | 4225 83 | 4356 84 | 4489 85 | 4624 86 | 4761 87 | 4900 88 | 5041 89 | 5184 90 | 5329 91 | 5476 92 | 5625 93 | 5776 94 | 5929 95 | 6084 96 | 6241 97 | 6400 98 | 6561 99 | 6724 100 | 6889 101 | 7056 102 | 7225 103 | 7396 104 | 7569 105 | 7744 106 | 7921 107 | 8100 108 | 8281 109 | 8464 110 | 8649 111 | 8836 112 | 9025 113 | 9216 114 | 9409 115 | 9604 116 | 9801 117 | 10000 118 | __OUTPUT__ 119 | ,.!a 120 | __INPUT__ 121 | a 122 | __OUTPUT__ 123 | ,[>>++++++[-<+++++++>]<+<[->.<]>+++.<++++[->++++<]>.>,]!optimus 124 | 125 | __INPUT__ 126 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.> 127 | __OUTPUT__ 128 | +[,+[-[>+>+<<-]>[<+>-]+>>++++++++[<-------->-]<-[<[-]>>>+[<+<+>>-]<[>+<-]<[<++> 129 | >>+[<+<->>-]<[>+<-]]>[<]<]>>[-]<<<[[-]<[>>+>+<<<-]>>[<<+>>-]>>++++++++[<------- 130 | ->-]<->>++++[<++++++++>-]<-<[>>>+<<[>+>[-]<<-]>[<+>-]>[<<<<<+>>>>++++[<++++++++ 131 | >-]>-]<<-<-]>[<<<<[-]>>>>[<<<<->>>>-]]<<++++[<<++++++++>>-]<<-[>>+>+<<<-]>>[<<+ 132 | >>-]+>>+++++[<----->-]<-[<[-]>>>+[<+<->>-]<[>+<-]<[<++>>>+[<+<+>>-]<[>+<-]]>[<] 133 | <]>>[-]<<<[[-]<<[>>+>+<<<-]>>[<<+>>-]+>------------[<[-]>>>+[<+<->>-]<[>+<-]<[< 134 | ++>>>+[<+<+>>-]<[>+<-]]>[<]<]>>[-]<<<<<------------->>[[-]+++++[<<+++++>>-]<<+> 135 | >]<[>++++[<<++++++++>>-]<-]>]<[-]++++++++[<++++++++>-]<+>]<.[-]+>>+<]>[[-]<]<] 136 | !dinnernovemberlocustselephantjanuary 137 | __INPUT__ 138 | qvaareabirzoreybphfgfryrcunagwnahnel 139 | __OUTPUT__ 140 | +[,+[-[>+>+<<-]>[<+>-]+>>++++++++[<-------->-]<-[<[-]>>>+[<+<+>>-]<[>+<-]<[<++> 141 | >>+[<+<->>-]<[>+<-]]>[<]<]>>[-]<<<[[-]<[>>+>+<<<-]>>[<<+>>-]>>++++++++[<------- 142 | ->-]<->>++++[<++++++++>-]<-<[>>>+<<[>+>[-]<<-]>[<+>-]>[<<<<<+>>>>++++[<++++++++ 143 | >-]>-]<<-<-]>[<<<<[-]>>>>[<<<<->>>>-]]<<++++[<<++++++++>>-]<<-[>>+>+<<<-]>>[<<+ 144 | >>-]+>>+++++[<----->-]<-[<[-]>>>+[<+<->>-]<[>+<-]<[<++>>>+[<+<+>>-]<[>+<-]]>[<] 145 | <]>>[-]<<<[[-]<<[>>+>+<<<-]>>[<<+>>-]+>------------[<[-]>>>+[<+<->>-]<[>+<-]<[< 146 | ++>>>+[<+<+>>-]<[>+<-]]>[<]<]>>[-]<<<<<------------->>[[-]+++++[<<+++++>>-]<<+> 147 | >]<[>++++[<<++++++++>>-]<-]>]<[-]++++++++[<++++++++>-]<+>]<.[-]+>>+<]>[[-]<]<] 148 | !kettlexylophoneroastsroastsroasts 149 | __INPUT__ 150 | xrggyrklybcubarebnfgfebnfgfebnfgf 151 | __OUTPUT__ 152 | -------------------------------------------------------------------------------- /db.rb: -------------------------------------------------------------------------------- 1 | require 'net/http' 2 | require 'open-uri' 3 | 4 | def initialize_db_module 5 | if !$dont_use_marshalp 6 | $SERIALIZER = Marshal 7 | $DATA_PATH = 'marshalp' 8 | return 9 | end 10 | 11 | begin 12 | require 'json' 13 | $SERIALIZER = JSON 14 | $DATA_PATH = 'jsonp' 15 | rescue LoadError 16 | STDERR.puts 'No json module installed. We\'ll use YAML, but please consider installing json module as there are known bugs in YAML loader.' 17 | require 'yaml' 18 | $SERIALIZER = YAML 19 | $DATA_PATH = 'yamlp' 20 | end 21 | end 22 | 23 | def golf_file(f) 24 | File.join(GOLF_DIR, f) 25 | end 26 | 27 | def ag_file(f) 28 | File.join(AG_DIR, f) 29 | end 30 | 31 | def db_ag(f) 32 | Marshal.load(File.read(ag_file(f))) 33 | end 34 | 35 | def ag_escape(url) 36 | url.gsub(' ', '+') 37 | end 38 | 39 | def ag_escape(url) 40 | url.gsub(' ', '+') 41 | end 42 | 43 | def ag_unescape(url) 44 | url.gsub('+', ' ') 45 | end 46 | 47 | def download_ag(http, f) 48 | initialize_db_module 49 | url = ag_escape("/#{$DATA_PATH}.rb?#{f[/[^.]+/]}") 50 | puts "Downloading #{f}..." 51 | File.open(ag_file(f), 'w') do |ofile| 52 | o = $SERIALIZER.load(http.get(url).read_body) 53 | ofile.print Marshal.dump(o) 54 | end 55 | end 56 | 57 | def update_ag_db(http, f) 58 | if !File.exists?(ag_file(f)) 59 | download_ag(http, f) 60 | end 61 | end 62 | 63 | def update_ag 64 | http = Net::HTTP::new('golf.shinh.org', 80) 65 | download_ag(http, 'problem.db') 66 | ag_problems.each do |f| 67 | update_ag_db(http, f + '.db') 68 | end 69 | end 70 | 71 | def spoj_file(f) 72 | File.join(SPOJ_DIR, f) 73 | end 74 | 75 | def update_spoj 76 | puts 'Downloading the list of problems...' 77 | c = open('http://www.spoj.pl/SHORTEN/ranks/', &:read) 78 | File.open(spoj_file('ranks.html'), 'w') do |of| 79 | of.print(c) 80 | end 81 | c.scan(//) do 82 | probname = $1 83 | filename = spoj_file(probname) 84 | if File.exists?(filename + '.html') 85 | next 86 | end 87 | 88 | puts "Downloading the #{probname}.html..." 89 | spec = open("http://www.spoj.pl/SHORTEN/problems/#{probname}/", &:read) 90 | File.open(filename + '.html', 'w') do |of| 91 | of.print(spec) 92 | end 93 | 94 | spec.gsub!(//, "\n") 95 | if spec =~ /
[\s\n]*Input:<\/strong>(.*?)Output:<\/strong>(.*?)<\/pre>/ms
 96 |       input = $1.strip
 97 |       output = $2.strip
 98 |       File.open(filename + '.test', 'w') do |of|
 99 |         of.puts(input + "\n\n__INPUT__\n" + output + "\n\n__OUTPUT__")
100 |       end
101 |     else
102 |       puts "Example I/O not found"
103 |     end
104 |   end
105 | end
106 | 
107 | def golf_db_file
108 |   golf_file('golf.db')
109 | end
110 | 
111 | def ag_problems
112 |   db_ag('problem.db')['root']
113 | end
114 | 
115 | def get_user
116 |   golf_db = get_golf_db
117 |   golf_db.transaction do
118 |     golf_db['user'].rstrip
119 |   end
120 | end
121 | 
122 | def get_golf_db
123 |   PStore.new(golf_db_file)
124 | end
125 | 
126 | def update_file2problem(basename, problem)
127 |   golf_db = get_golf_db
128 |   golf_db.transaction do
129 |     golf_db['file2problem'][basename] = problem
130 |   end
131 | end
132 | 
133 | def file2problem(basename, guess_ag = true)
134 |   golf_db = get_golf_db
135 |   golf_db.transaction(true) do
136 |     problem = golf_db['file2problem'][basename]
137 |     return problem if problem
138 |   end
139 | 
140 |   return nil if !guess_ag
141 | 
142 |   eds = []
143 |   ag_problems.each do |problem|
144 |     eds << [similarity(problem, basename), problem]
145 |   end
146 |   eds.sort!
147 |   #ed, problem = eds[0]
148 |   #print "#{basename} corresponds to #{problem}? (edit distance #{ed}) (Y/n): "
149 |   puts "#{basename} corresponds to"
150 |   puts " #{i=0}: none of below"
151 |   eds[0,5].each do |ed, problem|
152 |     puts " #{i+=1}: #{problem} (#{ed})"
153 |   end
154 |   print "Input 0-5 [1] ? : "
155 |   num = STDIN.gets
156 |   if num =~ /^$/
157 |     num = 1
158 |   else
159 |     num = num.to_i
160 |   end
161 |   if num > 0
162 |     problem = eds[num-1][1]
163 |     problem = "http://golf.shinh.org/p.rb?#{ag_escape(problem)}"
164 |   else
165 |     print "Please input problem URL for #{basename}: "
166 |     problem = STDIN.gets
167 |     if problem =~ /^$/
168 |       raise "Couldn't obtain problem name"
169 |     end
170 |   end
171 | 
172 |   update_file2problem(basename, problem)
173 | 
174 |   problem
175 | end
176 | 


--------------------------------------------------------------------------------
/sample/spiral.test:
--------------------------------------------------------------------------------
 1 | 11 3
 2 | __INPUT__
 3 |  1  2  3  4  5  6  7  8  9 10 11
 4 | 24 25 26 27 28 29 30 31 32 33 12
 5 | 23 22 21 20 19 18 17 16 15 14 13
 6 | __OUTPUT__
 7 | 11 10
 8 | __INPUT__
 9 |   1   2   3   4   5   6   7   8   9  10  11
10 |  38  39  40  41  42  43  44  45  46  47  12
11 |  37  68  69  70  71  72  73  74  75  48  13
12 |  36  67  90  91  92  93  94  95  76  49  14
13 |  35  66  89 104 105 106 107  96  77  50  15
14 |  34  65  88 103 110 109 108  97  78  51  16
15 |  33  64  87 102 101 100  99  98  79  52  17
16 |  32  63  86  85  84  83  82  81  80  53  18
17 |  31  62  61  60  59  58  57  56  55  54  19
18 |  30  29  28  27  26  25  24  23  22  21  20
19 | __OUTPUT__
20 | 10 9
21 | __INPUT__
22 |   1   2   3   4   5   6   7   8   9  10
23 |  34  35  36  37  38  39  40  41  42  11
24 |  33  60  61  62  63  64  65  66  43  12
25 |  32  59  78  79  80  81  82  67  44  13
26 |  31  58  77  88  89  90  83  68  45  14
27 |  30  57  76  87  86  85  84  69  46  15
28 |  29  56  75  74  73  72  71  70  47  16
29 |  28  55  54  53  52  51  50  49  48  17
30 |  27  26  25  24  23  22  21  20  19  18
31 | __OUTPUT__
32 | 10 10
33 | __INPUT__
34 |   1   2   3   4   5   6   7   8   9  10
35 |  36  37  38  39  40  41  42  43  44  11
36 |  35  64  65  66  67  68  69  70  45  12
37 |  34  63  84  85  86  87  88  71  46  13
38 |  33  62  83  96  97  98  89  72  47  14
39 |  32  61  82  95 100  99  90  73  48  15
40 |  31  60  81  94  93  92  91  74  49  16
41 |  30  59  80  79  78  77  76  75  50  17
42 |  29  58  57  56  55  54  53  52  51  18
43 |  28  27  26  25  24  23  22  21  20  19
44 | __OUTPUT__
45 | 10 8
46 | __INPUT__
47 |   1   2   3   4   5   6   7   8   9  10
48 |  32  33  34  35  36  37  38  39  40  11
49 |  31  56  57  58  59  60  61  62  41  12
50 |  30  55  72  73  74  75  76  63  42  13
51 |  29  54  71  80  79  78  77  64  43  14
52 |  28  53  70  69  68  67  66  65  44  15
53 |  27  52  51  50  49  48  47  46  45  16
54 |  26  25  24  23  22  21  20  19  18  17
55 | __OUTPUT__
56 | 29 23
57 | __INPUT__
58 |   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29
59 | 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127  30
60 |  99 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 128  31
61 |  98 191 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 218 129  32
62 |  97 190 275 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 300 219 130  33
63 |  96 189 274 351 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 374 301 220 131  34
64 |  95 188 273 350 419 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 440 375 302 221 132  35
65 |  94 187 272 349 418 479 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 498 441 376 303 222 133  36
66 |  93 186 271 348 417 478 531 576 577 578 579 580 581 582 583 584 585 586 587 588 589 548 499 442 377 304 223 134  37
67 |  92 185 270 347 416 477 530 575 612 613 614 615 616 617 618 619 620 621 622 623 590 549 500 443 378 305 224 135  38
68 |  91 184 269 346 415 476 529 574 611 640 641 642 643 644 645 646 647 648 649 624 591 550 501 444 379 306 225 136  39
69 |  90 183 268 345 414 475 528 573 610 639 660 661 662 663 664 665 666 667 650 625 592 551 502 445 380 307 226 137  40
70 |  89 182 267 344 413 474 527 572 609 638 659 658 657 656 655 654 653 652 651 626 593 552 503 446 381 308 227 138  41
71 |  88 181 266 343 412 473 526 571 608 637 636 635 634 633 632 631 630 629 628 627 594 553 504 447 382 309 228 139  42
72 |  87 180 265 342 411 472 525 570 607 606 605 604 603 602 601 600 599 598 597 596 595 554 505 448 383 310 229 140  43
73 |  86 179 264 341 410 471 524 569 568 567 566 565 564 563 562 561 560 559 558 557 556 555 506 449 384 311 230 141  44
74 |  85 178 263 340 409 470 523 522 521 520 519 518 517 516 515 514 513 512 511 510 509 508 507 450 385 312 231 142  45
75 |  84 177 262 339 408 469 468 467 466 465 464 463 462 461 460 459 458 457 456 455 454 453 452 451 386 313 232 143  46
76 |  83 176 261 338 407 406 405 404 403 402 401 400 399 398 397 396 395 394 393 392 391 390 389 388 387 314 233 144  47
77 |  82 175 260 337 336 335 334 333 332 331 330 329 328 327 326 325 324 323 322 321 320 319 318 317 316 315 234 145  48
78 |  81 174 259 258 257 256 255 254 253 252 251 250 249 248 247 246 245 244 243 242 241 240 239 238 237 236 235 146  49
79 |  80 173 172 171 170 169 168 167 166 165 164 163 162 161 160 159 158 157 156 155 154 153 152 151 150 149 148 147  50
80 |  79  78  77  76  75  74  73  72  71  70  69  68  67  66  65  64  63  62  61  60  59  58  57  56  55  54  53  52  51
81 | __OUTPUT__
82 | 


--------------------------------------------------------------------------------
/README:
--------------------------------------------------------------------------------
  1 | caddy - a testing/squeezing/submission helper tool for golfers
  2 | 
  3 | * setup
  4 | 
  5 | Add alias to your .bashrc or something:
  6 | 
  7 |  alias caddy='ruby ~/src/gtester/caddy.rb'
  8 | 
  9 | Run caddy update:
 10 | 
 11 |  % caddy update
 12 | 
 13 | This command downloads the problem information in golf.shinh.org.
 14 | Please run this command again if another challenge is added in
 15 | golf.shinh.org. Note that you will be asked your name for submission
 16 | if this is the first run.
 17 | 
 18 | If you use Debian or Ubuntu, you can install language environments by
 19 | 
 20 |  % caddy install_apt
 21 | 
 22 | * basic usage
 23 | 
 24 | For example, suppose you have a solution of delete words
 25 | (http://golf.shinh.org/p.rb?delete+words) as "delword.rb". You should
 26 | specify the file name as commandline argument:
 27 | 
 28 |  % caddy delword.rb
 29 | 
 30 | Then you may see
 31 | 
 32 |  delword corresponds to
 33 |   0: none of below
 34 |   1: delete words (4166)
 35 |   2: hello world (4545)
 36 |   3: Ring world (6000)
 37 |   4: Factorial (7777)
 38 |   5: odd lines (7777)
 39 |  Input 0-5 [1] ? :
 40 | 
 41 | In this case, this program guesses the name of problem correctly. Just
 42 | type return. you will see local testing and squeezing.
 43 | 
 44 |  Loading testcases of 'delete words'
 45 |  Test #1... OK
 46 |  Test #2... OK
 47 |  Test #3... OK
 48 |  
 49 |  Running squeezer... 669 => 80
 50 |  #!ruby -pa
 51 |  gets(c=" "*-~~b=/.$/).map{sub$F[0],c;gsub(/.+/){scan(b)-[gsub b,""]}}
 52 |  
 53 |  Test #1... OK
 54 |  Test #2... OK
 55 |  Test #3... OK
 56 |  
 57 |  Submit this 80B code as shinh (Y/n) ? :
 58 | 
 59 | Here, you are asked if you want to submit this code to the golf
 60 | server. After you type return again, you will see
 61 | 
 62 |  Submitting... Success!
 63 | 
 64 | That's all of the basic usage.
 65 | 
 66 | * tell the name of challenge explicitly
 67 | 
 68 | I had the solution of "sort characters" challenge as "csort.rb".
 69 | 
 70 |  % caddy csort.rb
 71 |  csort corresponds to
 72 |   0: none of below
 73 |   1: Factorial (6666)
 74 |   2: Card Sharp (7000)
 75 |   3: Circle Art (7000)
 76 |   4: Timeout (7142)
 77 |   5: factoriazation (7142)
 78 |  Input 0-5 [1] ? :
 79 | 
 80 | Now, the system couldn't guess the challenge name correctly. You
 81 | should tell the name of problem to caddy as follows:
 82 | 
 83 |  % caddy csort.rb 'http://golf.shinh.org/p.rb?sort+characters'
 84 | 
 85 | Once the system learn the correct relation, you should not specify the
 86 | URL explicitly.
 87 | 
 88 | * configuration
 89 | 
 90 | You have your configuration in $HOME/.golf/config.rb. Maybe you see
 91 | how to modify this file easily.
 92 | 
 93 | caddy has some command line flags. Please check these option by
 94 | invoking the program with no arguments:
 95 | 
 96 |  % caddy
 97 | 
 98 | * add/modify squeezer
 99 | 
100 | Squeezer removes comments and unnecessary white spaces. For example,
101 | the following ruby code
102 | 
103 |  # FizzBuzz
104 |  1.upto(?d){|n|
105 |    puts ["Fizz#{s=[:Buzz][n%5]}"][n%3]||s||n
106 |  }
107 | 
108 | is squeezed into
109 | 
110 |  1.upto(?d){|n|puts ["Fizz#{s=[:Buzz][n%5]}"][n%3]||s||n}
111 | 
112 | With squeezer, you can write relatively readable code for golfing. Now
113 | we don't have squeezers for all languages. You can add/modify the
114 | squeezing algorithm. Please check squeeze.rb and squeezer/* for
115 | detail. If you write nice squeezer for your favorite language, please
116 | send me the code, and I'll add the squeezer into the package.
117 | 
118 | * add your own testcases
119 | 
120 | If you prepare testcases file, caddy can be used for other golf
121 | challenges (e.g. http://codegolf.com/). Suppose you have the solution
122 | of "99 bottles of beer" (http://codegolf.com/99-bottles-of-beer) as
123 | "bottle.rb". In this case, caddy checks if there is a file
124 | "bottle.test" in the current directory. If it exists, caddy extracts
125 | testcases from the file. Please check sample/* for the format of the
126 | testcase file.
127 | 
128 | There is another format of testcases. If there are files named
129 | test/bottle*.output and test/bottle*.input (*.input is optional),
130 | caddy extracts testcases from these files. The sample if in cg/*.
131 | And, if you use the same naming convention as mine, you can use cg/*
132 | to test your solutions for codegolf.com. Note that the files under cg/
133 | are incomplete.
134 | 
135 | * modify executors
136 | 
137 | You can change how to execute source code by modifying files under
138 | executors. For example, if the name of your ruby executable is
139 | not "ruby" but "ruby1.8", you can modify executors/rb as follows:
140 | 
141 |  #!/bin/sh
142 |  exec ruby1.8 $1
143 | 
144 | * uninstall
145 | 
146 | Remove ~/.golf.
147 | 
148 | * todos
149 | 
150 | - add better test cases for codegolf.com
151 | - add submitter for codegolf.com
152 | - add more squeezers
153 | - check if caddy works on cygwin
154 | - remember other todos.
155 | 
156 | * thanks
157 | 
158 | caddy uses net/http/multipart:
159 | 
160 | http://sieben.dip.jp/hikifarm/Laboratory/?net%2Fhttp%2Fmultipart.rb
161 | 
162 | * licence
163 | 
164 | GPLv2 or later.
165 | 
166 | * change log
167 | 
168 | - add -s1 and -s2 and -i option. (apparently, i must rename flags)
169 | - change name of files stored in ~/.golf/code. (thanks for irori)
170 | - initial release
171 | 
172 | ------------------
173 |  shinichiro.h
174 |   shinichiro.hamaji _at_ gmail.com
175 | 


--------------------------------------------------------------------------------
/submit.rb:
--------------------------------------------------------------------------------
  1 | def confirm_submit(code_size, user)
  2 |   if $submit_confirm
  3 |     print "Submit this #{code_size}B code as #{user} (Y/n) ? : "
  4 |     yn = STDIN.gets
  5 |     if yn !~ /^$/ && yn !~ /^[yY]$/
  6 |       exit 0
  7 |     end
  8 |   end
  9 | end
 10 | 
 11 | def submit_ag(base, user_suffix, num_retry, code, ext, pn, code_size)
 12 |   user = get_user
 13 |   if user_suffix
 14 |     user = "#{user}(#{user_suffix})"
 15 |   end
 16 | 
 17 |   confirm_submit(code_size, user)
 18 | 
 19 |   print 'Submitting... '
 20 |   data = {
 21 |     'problem' => pn,
 22 |     'user' => user,
 23 |     'reveal' => $open_code_statistics ? '1' : '',
 24 |   }
 25 | 
 26 |   ok = false
 27 |   1.upto(num_retry) do |num_attacks|
 28 |     Net::HTTP.start('golf.shinh.org', 80) do |http|
 29 |       req = Net::HTTP::Post.new('/submit.rb')
 30 |       FileUtils.cp(code, tmpfile = File.join('/tmp', base+ext))
 31 |       req.set_multipart_form_data({'file' => tmpfile}, data)
 32 |       File.unlink(tmpfile)
 33 |       res = http.request(req)
 34 |       if res.class.superclass != Net::HTTPSuccess
 35 |         puts "Failed to connect the golf server"
 36 |         exit 1
 37 |       end
 38 | 
 39 |       res = res.read_body
 40 |       if res =~ /Success[^<]*/
 41 |         puts $&
 42 |         ok = true
 43 |       else
 44 |         puts 'FAILED'
 45 |         puts
 46 |         puts res.sub(/.*/m, '').gsub(/<.*?>/, '').sub('return top', '')
 47 |       end
 48 |     end
 49 | 
 50 |     if ok
 51 |       break
 52 |     end
 53 | 
 54 |     if num_attacks % 100 == 0
 55 |       puts "#{num_attacks}..."
 56 | 
 57 |       if num_attacks >= 10000
 58 |         raise 'Please refrain from >10000 attempts'
 59 |       end
 60 |     end
 61 |   end
 62 | end
 63 | 
 64 | def submit_ag_perf(filename, input_filename)
 65 |   ext = File.extname(filename)
 66 |   base = File.basename(filename, ext)
 67 | 
 68 |   Net::HTTP.start('golf.shinh.org', 80) do |http|
 69 |     req = Net::HTTP::Post.new('/checker.rb')
 70 |     FileUtils.cp(filename, tmpfile = File.join('/tmp', base+ext))
 71 |     input = input_filename ? File.read(input_filename) : ""
 72 |     req.set_multipart_form_data({'file' => tmpfile}, {'input' => input})
 73 |     File.unlink(tmpfile)
 74 | 
 75 |     res = http.request(req)
 76 |     if res.class.superclass != Net::HTTPSuccess
 77 |       puts "Failed to connect the golf server"
 78 |       exit 1
 79 |     end
 80 | 
 81 |     res = res.read_body
 82 |     puts res
 83 |   end
 84 | end
 85 | 
 86 | SPOJ_LANGS = {
 87 |   '.adb' => 7,
 88 |   '.s' => 13,
 89 |   '.sh' => 28,
 90 |   '.bf' => 12,
 91 |   # 
 92 |   # 
 93 |   '.c' => 11,
 94 |   '.cs' => 27,
 95 |   # 
 96 |   # 
 97 |   '.cc' => 41,
 98 |   # 
 99 |   '.clj' => 111,
100 |   # 
101 |   # 
102 |   '.l' => 31,
103 |   '.d' => 20,
104 |   '.erl' => 36,
105 |   '.fs' => 124,
106 |   '.f95' => 5,
107 |   '.go' => 114,
108 |   '.hs' => 21,
109 |   # 
110 |   # 
111 |   '.jar' => 24,
112 |   '.java' => 10,
113 |   '.js' => 35,
114 |   '.lua' => 26,
115 |   '.n' => 30,
116 |   # 
117 |   '.ml' => 8,
118 |   # 
119 |   # 
120 |   '.pas' => 2,
121 |   '.pl' => 3,
122 |   '.pl6' => 54,
123 |   '.php' => 29,
124 |   '.pike' => 19,
125 |   '.pro' => 15,
126 |   # 
127 |   # 
128 |   '.py' => 4,
129 |   '.rb' => 17,
130 |   '.rb19' => 17,
131 |   '.scala' => 39,
132 |   # 
133 |   # 
134 |   '.scm' => 33,
135 |   '.st' => 23,
136 |   '.tcl' => 38,
137 |   '.ws' => 6,
138 | }
139 | 
140 | def submit_spoj(code_file, code_size, base, ext)
141 |   user = get_user
142 | 
143 |   langid = SPOJ_LANGS[ext]
144 |   if !langid
145 |     puts "Cannot determine the language for #{ext}"
146 |     exit 1
147 |   end
148 | 
149 |   confirm_submit(code_size, user)
150 | 
151 |   print 'Submitting... '
152 | 
153 |   require 'net/https'
154 | 
155 |   probname = base.upcase
156 | 
157 |   pass = $spoj_pass
158 |   if !pass
159 |     print "Password for #{user}: "
160 |     system("stty -echo")
161 |     pass = gets.strip
162 |     system("stty echo")
163 |   end
164 | 
165 |   code = File.read(code_file)
166 | 
167 |   https = Net::HTTP.new('www.spoj.pl', 443)
168 |   https.use_ssl = true
169 |   https.start do |w|
170 |     body = ("submit=Send&login_user=#{user}&password=#{pass}&lang=#{langid}&" +
171 |             "problemcode=#{probname}&file=#{URI.escape(code, /[^\w]/)}")
172 |     r = w.post("/SHORTEN/submit/complete/", body)
173 |     if r.code == '200' && r.body =~ /Solution submitted/
174 |       puts 'done!'
175 |       puts 'https://www.spoj.pl/SHORTEN/status/'
176 |     else
177 |       puts "failed! (#{r.code})"
178 |       File.open('error.html', 'w') do |of|
179 |         of.print r.body
180 |       end
181 |       puts "error.html was saved"
182 |       exit 1
183 |     end
184 |   end
185 | end
186 | 


--------------------------------------------------------------------------------
/sample/cross.test:
--------------------------------------------------------------------------------
  1 | ____
  2 | ____
  3 | ____
  4 | ____
  5 | __INPUT__
  6 | #####################
  7 | #1   #2   #3   #4   #
  8 | #    #    #    #    #
  9 | #####################
 10 | #5   #    #    #    #
 11 | #    #    #    #    #
 12 | #####################
 13 | #6   #    #    #    #
 14 | #    #    #    #    #
 15 | #####################
 16 | #7   #    #    #    #
 17 | #    #    #    #    #
 18 | #####################
 19 | __OUTPUT__
 20 | ____
 21 | _XX_
 22 | _XX_
 23 | ____
 24 | __INPUT__
 25 | #####################
 26 | #1   #    #    #2   #
 27 | #    #    #    #    #
 28 | #####################
 29 | #    ###########    #
 30 | #    ###########    #
 31 | #####################
 32 | #    ###########    #
 33 | #    ###########    #
 34 | #####################
 35 | #3   #    #    #    #
 36 | #    #    #    #    #
 37 | #####################
 38 | __OUTPUT__
 39 | X _ _ _ _ X X
 40 | _ _ X _ _ _ _
 41 | _ _ _ _ X _ _
 42 | _ X _ _ X X X
 43 | _ _ _ X _ _ _
 44 | X _ _ _ _ _ X
 45 | __INPUT__
 46 |      #####################
 47 |      #1   #    #2   #3   #
 48 |      #    #    #    #    #
 49 | ####################################
 50 | #4   #    ######5   #    #6   #7   #
 51 | #    #    ######    #    #    #    #
 52 | ####################################
 53 | #8   #    #9   #    #    #10  #    #
 54 | #    #    #    #    #    #    #    #
 55 | #####################    ###########
 56 | #    ######11  #    #
 57 | #    ######    #    #
 58 | ####################################
 59 | #12  #13  #    ######14  #15  #    #
 60 | #    #    #    ######    #    #    #
 61 | ####################################
 62 |      #16  #    #    #    #    #
 63 |      #    #    #    #    #    #
 64 |      ##########################
 65 | __OUTPUT__
 66 | _______X_______
 67 | _X_X_X_X_X_X_X_
 68 | _____X_________
 69 | _X_X_X_X_X_X_X_
 70 | __________X____
 71 | _X_X_XXX_X_X_X_
 72 | XXX____________
 73 | _X_X_X_X_X_X_X_
 74 | ____________XXX
 75 | _X_X_X_XXX_X_X_
 76 | ____X__________
 77 | _X_X_X_X_X_X_X_
 78 | _________X_____
 79 | _X_X_X_X_X_X_X_
 80 | _______X_______
 81 | __INPUT__
 82 | ####################################    ####################################
 83 | #1   #    #2   #    #3   #    #4   #    #5   #    #6   #    #7   #    #8   #
 84 | #    #    #    #    #    #    #    #    #    #    #    #    #    #    #    #
 85 | ####################################    ####################################
 86 | #    ######    ######    ######    #    #    ######    ######    ######    #
 87 | #    ######    ######    ######    #    #    ######    ######    ######    #
 88 | ############################################################################
 89 | #9   #    #    #    #    ######10  #    #    #    #    #    #    #    #    #
 90 | #    #    #    #    #    ######    #    #    #    #    #    #    #    #    #
 91 | ############################################################################
 92 | #    ######    ######    ######    ######    ######    ######    ######    #
 93 | #    ######    ######    ######    ######    ######    ######    ######    #
 94 | ############################################################################
 95 | #11  #    #    #    #    #    #    #    #    #    ######12  #    #    #    #
 96 | #    #    #    #    #    #    #    #    #    #    ######    #    #    #    #
 97 | ############################################################################
 98 | #    #    #    ######    ################    ######13  ######    ######    #
 99 | #    #    #    ######    ################    ######    ######    ######    #
100 | ######    ##################################################################
101 |                #14  #    #    #15  #    #    #    #    #    #    #    #    #
102 |                #    #    #    #    #    #    #    #    #    #    #    #    #
103 | ######    ##################################################################
104 | #16  #    #17  ######    ######    ######    ######    ######    #    #    #
105 | #    #    #    ######    ######    ######    ######    ######    #    #    #
106 | ##################################################################    ######
107 | #18  #    #    #    #    #    #    #    #    #    #    #    #
108 | #    #    #    #    #    #    #    #    #    #    #    #    #
109 | ##################################################################    ######
110 | #    ######    ######    ######    ################    ######19  #    #20  #
111 | #    ######    ######    ######    ################    ######    #    #    #
112 | ############################################################################
113 | #21  #    #    #    ######22  #    #    #23  #    #    #    #    #    #    #
114 | #    #    #    #    ######    #    #    #    #    #    #    #    #    #    #
115 | ############################################################################
116 | #    ######    ######24  ######    ######    ######    ######    ######    #
117 | #    ######    ######    ######    ######    ######    ######    ######    #
118 | ############################################################################
119 | #25  #    #    #    #    #    #    #    #    ######26  #    #    #    #    #
120 | #    #    #    #    #    #    #    #    #    ######    #    #    #    #    #
121 | ############################################################################
122 | #    ######    ######    ######    #    #    ######    ######    ######    #
123 | #    ######    ######    ######    #    #    ######    ######    ######    #
124 | ####################################    ####################################
125 | #27  #    #    #    #    #    #    #    #28  #    #    #    #    #    #    #
126 | #    #    #    #    #    #    #    #    #    #    #    #    #    #    #    #
127 | ####################################    ####################################
128 | __OUTPUT__
129 | 


--------------------------------------------------------------------------------
/sample/crossword.test:
--------------------------------------------------------------------------------
  1 | ____
  2 | ____
  3 | ____
  4 | ____
  5 | __INPUT__
  6 | #####################
  7 | #1   #2   #3   #4   #
  8 | #    #    #    #    #
  9 | #####################
 10 | #5   #    #    #    #
 11 | #    #    #    #    #
 12 | #####################
 13 | #6   #    #    #    #
 14 | #    #    #    #    #
 15 | #####################
 16 | #7   #    #    #    #
 17 | #    #    #    #    #
 18 | #####################
 19 | __OUTPUT__
 20 | ___
 21 | _XX_
 22 | _XX_
 23 | ____
 24 | __INPUT__
 25 | #####################
 26 | #1   #    #    #2   #
 27 | #    #    #    #    #
 28 | #####################
 29 | #    ###########    #
 30 | #    ###########    #
 31 | #####################
 32 | #    ###########    #
 33 | #    ###########    #
 34 | #####################
 35 | #3   #    #    #    #
 36 | #    #    #    #    #
 37 | #####################
 38 | __OUTPUT__
 39 | _______X_______
 40 | _X_X_X_X_X_X_X_
 41 | _____X_________
 42 | _X_X_X_X_X_X_X_
 43 | __________X____
 44 | _X_X_XXX_X_X_X_
 45 | XXX____________
 46 | _X_X_X_X_X_X_X_
 47 | ____________XXX
 48 | _X_X_X_XXX_X_X_
 49 | ____X__________
 50 | _X_X_X_X_X_X_X_
 51 | _________X_____
 52 | _X_X_X_X_X_X_X_
 53 | _______X_______
 54 | __INPUT__
 55 | ####################################    ####################################
 56 | #1   #    #2   #    #3   #    #4   #    #5   #    #6   #    #7   #    #8   #
 57 | #    #    #    #    #    #    #    #    #    #    #    #    #    #    #    #
 58 | ####################################    ####################################
 59 | #    ######    ######    ######    #    #    ######    ######    ######    #
 60 | #    ######    ######    ######    #    #    ######    ######    ######    #
 61 | ############################################################################
 62 | #9   #    #    #    #    ######10  #    #    #    #    #    #    #    #    #
 63 | #    #    #    #    #    ######    #    #    #    #    #    #    #    #    #
 64 | ############################################################################
 65 | #    ######    ######    ######    ######    ######    ######    ######    #
 66 | #    ######    ######    ######    ######    ######    ######    ######    #
 67 | ############################################################################
 68 | #11  #    #    #    #    #    #    #    #    #    ######12  #    #    #    #
 69 | #    #    #    #    #    #    #    #    #    #    ######    #    #    #    #
 70 | ############################################################################
 71 | #    #    #    ######    ################    ######13  ######    ######    #
 72 | #    #    #    ######    ################    ######    ######    ######    #
 73 | ######    ##################################################################
 74 |                #14  #    #    #15  #    #    #    #    #    #    #    #    #
 75 |                #    #    #    #    #    #    #    #    #    #    #    #    #
 76 | ######    ##################################################################
 77 | #16  #    #17  ######    ######    ######    ######    ######    #    #    #
 78 | #    #    #    ######    ######    ######    ######    ######    #    #    #
 79 | ##################################################################    ######
 80 | #18  #    #    #    #    #    #    #    #    #    #    #    #
 81 | #    #    #    #    #    #    #    #    #    #    #    #    #
 82 | ##################################################################    ######
 83 | #    ######    ######    ######    ################    ######19  #    #20  #
 84 | #    ######    ######    ######    ################    ######    #    #    #
 85 | ############################################################################
 86 | #21  #    #    #    ######22  #    #    #23  #    #    #    #    #    #    #
 87 | #    #    #    #    ######    #    #    #    #    #    #    #    #    #    #
 88 | ############################################################################
 89 | #    ######    ######24  ######    ######    ######    ######    ######    #
 90 | #    ######    ######    ######    ######    ######    ######    ######    #
 91 | ############################################################################
 92 | #25  #    #    #    #    #    #    #    #    ######26  #    #    #    #    #
 93 | #    #    #    #    #    #    #    #    #    ######    #    #    #    #    #
 94 | ############################################################################
 95 | #    ######    ######    ######    #    #    ######    ######    ######    #
 96 | #    ######    ######    ######    #    #    ######    ######    ######    #
 97 | ####################################    ####################################
 98 | #27  #    #    #    #    #    #    #    #28  #    #    #    #    #    #    #
 99 | #    #    #    #    #    #    #    #    #    #    #    #    #    #    #    #
100 | ####################################    ####################################
101 | __OUTPUT__
102 | X _ _ _ _ X X
103 | _ _ X _ _ _ _
104 | _ _ _ _ X _ _
105 | _ X _ _ X X X
106 | _ _ _ X _ _ _
107 | X _ _ _ _ _ X
108 | __INPUT__
109 |      #####################
110 |      #1   #    #2   #3   #
111 |      #    #    #    #    #
112 | ####################################
113 | #4   #    ######5   #    #6   #7   #
114 | #    #    ######    #    #    #    #
115 | ####################################
116 | #8   #    #9   #    #    #10  #    #
117 | #    #    #    #    #    #    #    #
118 | #####################    ###########
119 | #    ######11  #    #
120 | #    ######    #    #
121 | ####################################
122 | #12  #13  #    ######14  #15  #    #
123 | #    #    #    ######    #    #    #
124 | ####################################
125 |      #16  #    #    #    #    #
126 |      #    #    #    #    #    #
127 |      ##########################
128 | __OUTPUT__
129 | 


--------------------------------------------------------------------------------
/caddy.rb:
--------------------------------------------------------------------------------
  1 | #!/usr/bin/env ruby
  2 | 
  3 | require 'fileutils'
  4 | require 'open-uri'
  5 | require 'uri'
  6 | require 'pstore'
  7 | require 'optparse'
  8 | require 'net/http'
  9 | 
 10 | Net::HTTP.version_1_2
 11 | 
 12 | $: << SRC_DIR = File.expand_path(File.dirname(__FILE__))
 13 | 
 14 | GOLF_DIR = File.join(ENV['HOME'], '.golf')
 15 | AG_DIR = File.join(GOLF_DIR, 'ag')
 16 | CODE_DIR = File.join(GOLF_DIR, 'code')
 17 | TEST_DIR = File.join(GOLF_DIR, 'test')
 18 | SPOJ_DIR = File.join(GOLF_DIR, 'spoj')
 19 | 
 20 | FileUtils.mkdir_p(GOLF_DIR)
 21 | FileUtils.mkdir_p(AG_DIR)
 22 | FileUtils.mkdir_p(CODE_DIR)
 23 | FileUtils.mkdir_p(SPOJ_DIR)
 24 | 
 25 | configfile = File.join(GOLF_DIR, 'config.rb')
 26 | if !File.exist?(configfile)
 27 |   puts "Installing config.rb into #{configfile}"
 28 |   FileUtils.cp(File.join(SRC_DIR, 'config.rb'), configfile)
 29 | end
 30 | require configfile
 31 | 
 32 | require 'db'
 33 | require 'cases'
 34 | require 'install_apt'
 35 | require 'execute'
 36 | require 'submit'
 37 | require 'squeeze'
 38 | require 'net/http/multipart'
 39 | 
 40 | def help
 41 |   print %Q(Usage: caddy [OPTION]... FILE|update|install_apt [URL]
 42 | 
 43 | Options:
 44 |  -l : local test only
 45 |  -r[times]: remote test only (default times=1)
 46 |  -s1: skip pre-squeezing test
 47 |  -s2: skip post-squeezing test
 48 |  -sq: squeezing only
 49 |  -e : execute only - don\'t check the results
 50 |  -i : run all process ignoring errors
 51 |  -n : skip squeezing
 52 |  -s : suppress stderr
 53 |  -c : copy squeezed file into current directory
 54 |  -dn: change diff style to 'none'
 55 |  -dd: change diff style to 'diff'
 56 |  -da: change diff style to 'all'
 57 |  -u [suffix]: add user suffix (e.g. sym)
 58 |  -ex [executor]: specify executor
 59 | )
 60 |   exit 0
 61 | end
 62 | 
 63 | if !File.exist?(golf_db_file)
 64 |   puts "Initializing DB in #{GOLF_DIR}"
 65 |   print 'Enter your user name: '
 66 |   user = STDIN.gets
 67 |   golf_db = get_golf_db
 68 |   golf_db.transaction do
 69 |     golf_db['file2problem'] = {}
 70 |     golf_db['user'] = user
 71 |   end
 72 | end
 73 | 
 74 | do_local1 = true
 75 | do_local2 = true
 76 | do_remote = 1
 77 | do_squeeze = true
 78 | user_suffix = nil
 79 | ignore_errors = false
 80 | squeeze_only = false
 81 | no_check = false
 82 | use_perf_checker = false
 83 | 
 84 | argn = 0
 85 | while opt = ARGV[argn]
 86 |   if opt =~ /^-/
 87 |     case opt
 88 |     when '-l'
 89 |       do_remote = false
 90 |     when /-r(\d*)/
 91 |       do_local1 = do_local2 = false
 92 |       if $1 != ''
 93 |         do_remote = $1.to_i
 94 |       end
 95 |     when '-e'
 96 |       do_remote = false
 97 |       no_check = true
 98 |     when '-s1'
 99 |       do_local1 = false
100 |     when '-s2'
101 |       do_local2 = false
102 |     when '-sq'
103 |       squeeze_only = true
104 |     when '-n'
105 |       do_squeeze = false
106 |     when '-i'
107 |       ignore_errors = true
108 |     when '-p'
109 |       use_perf_checker = true
110 |     when '-s'
111 |       $suppress_stderr = true
112 |     when '-c'
113 |       $copy_squeezed = true
114 |     when '-dn'
115 |       $diff_style = :none
116 |     when '-dd'
117 |       $diff_style = :diff
118 |     when '-da'
119 |       $diff_style = :all
120 |     when '-u'
121 |       user_suffix = ARGV[argn+1]
122 |       ARGV.delete_at(argn)
123 |     when '-ex'
124 |       $executor = ARGV[argn+1]
125 |       ARGV.delete_at(argn)
126 |     else
127 |       puts "Unknown option: #{opt}"
128 |       help
129 |     end
130 |     ARGV.delete_at(argn)
131 |   else
132 |     argn += 1
133 |   end
134 | end
135 | 
136 | case ARGV[0]
137 | when 'update'
138 |   update_ag
139 | when 'update_spoj'
140 |   update_spoj
141 | when 'install_apt'
142 |   install_apt
143 | when nil
144 |   help
145 | else
146 |   filename = ARGV[0]
147 |   problem = ARGV[1]
148 | 
149 |   if !File.exist?(filename)
150 |     raise "#{filename}: file not found"
151 |   end
152 |   ext = File.extname(filename)
153 |   base = File.basename(filename, ext)
154 | 
155 |   if squeeze_only
156 |     squeezed, code_size = squeeze(filename)
157 |     if $copy_squeezed
158 |       FileUtils.cp(squeezed, 'out' + ext)
159 |     end
160 |     exit(0)
161 |   end
162 | 
163 |   if use_perf_checker
164 |     submit_ag_perf(filename, problem)
165 |     exit(0)
166 |   end
167 | 
168 |   if problem && problem !~ /^http:/
169 |     puts "Problem must be a URL"
170 |     exit(1)
171 |   end
172 | 
173 |   if ext == '.z8' || ext == '.zasm'
174 |     if !system("z80asm #{filename} -o #{base}.z8b")
175 |       puts "Couldn't compile #{filename}"
176 |       exit(1)
177 |     end
178 |     filename = "#{base}.z8b"
179 |     ext = '.z8b'
180 |   elsif ext == '.asm'
181 |     if !system("nasm #{filename} -o #{base}.out")
182 |       puts "Couldn't compile #{filename}"
183 |       exit(1)
184 |     end
185 |     filename = "#{base}.out"
186 |     ext = '.out'
187 |   end
188 | 
189 |   tests = get_testcases(base, problem)
190 |   if !tests
191 |     raise "Couldn't obtain test for #{filename}"
192 |   end
193 | 
194 |   type, testcases = tests
195 |   if do_local1
196 |     if !execute(type, filename, testcases, no_check)
197 |       puts 'FAILED'
198 |       if !ignore_errors
199 |         exit(1)
200 |       end
201 |     end
202 |   end
203 | 
204 |   if do_squeeze
205 |     squeezed, code_size = squeeze(filename)
206 |     if do_local2
207 |       if !execute(type, squeezed, testcases, no_check)
208 |         puts 'FAILED'
209 |         if !ignore_errors
210 |           exit(1)
211 |         end
212 |       end
213 |     end
214 | 
215 |     if $copy_squeezed
216 |       FileUtils.cp(squeezed, 'out' + ext)
217 |     end
218 |   else
219 |     squeezed = filename
220 |     code_size = File.size(filename)
221 |   end
222 | 
223 |   if do_remote && $spoj_dir_regexp =~ Dir.pwd
224 |     submit_spoj(squeezed, code_size, base, ext)
225 |     exit
226 |   end
227 | 
228 |   problem = file2problem(base, false)
229 |   if do_remote && problem =~ /^http:\/\/golf.shinh.org\/p.rb\?/
230 |     submit_ag(base, user_suffix, do_remote, squeezed, ext, $', code_size)
231 |   end
232 | end
233 | 


--------------------------------------------------------------------------------
/sample/cal.test:
--------------------------------------------------------------------------------
  1 | 1900
  2 | __INPUT__
  3 |                               1900
  4 | 
  5 |       January               February               March
  6 | Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
  7 |     1  2  3  4  5  6               1  2  3               1  2  3
  8 |  7  8  9 10 11 12 13   4  5  6  7  8  9 10   4  5  6  7  8  9 10
  9 | 14 15 16 17 18 19 20  11 12 13 14 15 16 17  11 12 13 14 15 16 17
 10 | 21 22 23 24 25 26 27  18 19 20 21 22 23 24  18 19 20 21 22 23 24
 11 | 28 29 30 31           25 26 27 28           25 26 27 28 29 30 31
 12 | 
 13 |        April                  May                   June
 14 | Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
 15 |  1  2  3  4  5  6  7         1  2  3  4  5                  1  2
 16 |  8  9 10 11 12 13 14   6  7  8  9 10 11 12   3  4  5  6  7  8  9
 17 | 15 16 17 18 19 20 21  13 14 15 16 17 18 19  10 11 12 13 14 15 16
 18 | 22 23 24 25 26 27 28  20 21 22 23 24 25 26  17 18 19 20 21 22 23
 19 | 29 30                 27 28 29 30 31        24 25 26 27 28 29 30
 20 | 
 21 |         July                 August              September
 22 | Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
 23 |  1  2  3  4  5  6  7            1  2  3  4                     1
 24 |  8  9 10 11 12 13 14   5  6  7  8  9 10 11   2  3  4  5  6  7  8
 25 | 15 16 17 18 19 20 21  12 13 14 15 16 17 18   9 10 11 12 13 14 15
 26 | 22 23 24 25 26 27 28  19 20 21 22 23 24 25  16 17 18 19 20 21 22
 27 | 29 30 31              26 27 28 29 30 31     23 24 25 26 27 28 29
 28 |                                             30
 29 |       October               November              December
 30 | Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
 31 |     1  2  3  4  5  6               1  2  3                     1
 32 |  7  8  9 10 11 12 13   4  5  6  7  8  9 10   2  3  4  5  6  7  8
 33 | 14 15 16 17 18 19 20  11 12 13 14 15 16 17   9 10 11 12 13 14 15
 34 | 21 22 23 24 25 26 27  18 19 20 21 22 23 24  16 17 18 19 20 21 22
 35 | 28 29 30 31           25 26 27 28 29 30     23 24 25 26 27 28 29
 36 |                                             30 31
 37 | __OUTPUT__
 38 | 2000
 39 | __INPUT__
 40 |                               2000
 41 | 
 42 |       January               February               March
 43 | Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
 44 |                    1         1  2  3  4  5            1  2  3  4
 45 |  2  3  4  5  6  7  8   6  7  8  9 10 11 12   5  6  7  8  9 10 11
 46 |  9 10 11 12 13 14 15  13 14 15 16 17 18 19  12 13 14 15 16 17 18
 47 | 16 17 18 19 20 21 22  20 21 22 23 24 25 26  19 20 21 22 23 24 25
 48 | 23 24 25 26 27 28 29  27 28 29              26 27 28 29 30 31
 49 | 30 31
 50 |        April                  May                   June
 51 | Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
 52 |                    1      1  2  3  4  5  6               1  2  3
 53 |  2  3  4  5  6  7  8   7  8  9 10 11 12 13   4  5  6  7  8  9 10
 54 |  9 10 11 12 13 14 15  14 15 16 17 18 19 20  11 12 13 14 15 16 17
 55 | 16 17 18 19 20 21 22  21 22 23 24 25 26 27  18 19 20 21 22 23 24
 56 | 23 24 25 26 27 28 29  28 29 30 31           25 26 27 28 29 30
 57 | 30
 58 |         July                 August              September
 59 | Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
 60 |                    1         1  2  3  4  5                  1  2
 61 |  2  3  4  5  6  7  8   6  7  8  9 10 11 12   3  4  5  6  7  8  9
 62 |  9 10 11 12 13 14 15  13 14 15 16 17 18 19  10 11 12 13 14 15 16
 63 | 16 17 18 19 20 21 22  20 21 22 23 24 25 26  17 18 19 20 21 22 23
 64 | 23 24 25 26 27 28 29  27 28 29 30 31        24 25 26 27 28 29 30
 65 | 30 31
 66 |       October               November              December
 67 | Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
 68 |  1  2  3  4  5  6  7            1  2  3  4                  1  2
 69 |  8  9 10 11 12 13 14   5  6  7  8  9 10 11   3  4  5  6  7  8  9
 70 | 15 16 17 18 19 20 21  12 13 14 15 16 17 18  10 11 12 13 14 15 16
 71 | 22 23 24 25 26 27 28  19 20 21 22 23 24 25  17 18 19 20 21 22 23
 72 | 29 30 31              26 27 28 29 30        24 25 26 27 28 29 30
 73 |                                             31
 74 | __OUTPUT__
 75 | 2399
 76 | __INPUT__
 77 |                               2399
 78 | 
 79 |       January               February               March
 80 | Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
 81 |                 1  2      1  2  3  4  5  6      1  2  3  4  5  6
 82 |  3  4  5  6  7  8  9   7  8  9 10 11 12 13   7  8  9 10 11 12 13
 83 | 10 11 12 13 14 15 16  14 15 16 17 18 19 20  14 15 16 17 18 19 20
 84 | 17 18 19 20 21 22 23  21 22 23 24 25 26 27  21 22 23 24 25 26 27
 85 | 24 25 26 27 28 29 30  28                    28 29 30 31
 86 | 31
 87 |        April                  May                   June
 88 | Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
 89 |              1  2  3                     1         1  2  3  4  5
 90 |  4  5  6  7  8  9 10   2  3  4  5  6  7  8   6  7  8  9 10 11 12
 91 | 11 12 13 14 15 16 17   9 10 11 12 13 14 15  13 14 15 16 17 18 19
 92 | 18 19 20 21 22 23 24  16 17 18 19 20 21 22  20 21 22 23 24 25 26
 93 | 25 26 27 28 29 30     23 24 25 26 27 28 29  27 28 29 30
 94 |                       30 31
 95 |         July                 August              September
 96 | Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
 97 |              1  2  3   1  2  3  4  5  6  7            1  2  3  4
 98 |  4  5  6  7  8  9 10   8  9 10 11 12 13 14   5  6  7  8  9 10 11
 99 | 11 12 13 14 15 16 17  15 16 17 18 19 20 21  12 13 14 15 16 17 18
100 | 18 19 20 21 22 23 24  22 23 24 25 26 27 28  19 20 21 22 23 24 25
101 | 25 26 27 28 29 30 31  29 30 31              26 27 28 29 30
102 | 
103 |       October               November              December
104 | Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
105 |                 1  2      1  2  3  4  5  6            1  2  3  4
106 |  3  4  5  6  7  8  9   7  8  9 10 11 12 13   5  6  7  8  9 10 11
107 | 10 11 12 13 14 15 16  14 15 16 17 18 19 20  12 13 14 15 16 17 18
108 | 17 18 19 20 21 22 23  21 22 23 24 25 26 27  19 20 21 22 23 24 25
109 | 24 25 26 27 28 29 30  28 29 30              26 27 28 29 30 31
110 | 31
111 | __OUTPUT__
112 | 1753
113 | __INPUT__
114 |                               1753
115 | 
116 |       January               February               March
117 | Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
118 |     1  2  3  4  5  6               1  2  3               1  2  3
119 |  7  8  9 10 11 12 13   4  5  6  7  8  9 10   4  5  6  7  8  9 10
120 | 14 15 16 17 18 19 20  11 12 13 14 15 16 17  11 12 13 14 15 16 17
121 | 21 22 23 24 25 26 27  18 19 20 21 22 23 24  18 19 20 21 22 23 24
122 | 28 29 30 31           25 26 27 28           25 26 27 28 29 30 31
123 | 
124 |        April                  May                   June
125 | Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
126 |  1  2  3  4  5  6  7         1  2  3  4  5                  1  2
127 |  8  9 10 11 12 13 14   6  7  8  9 10 11 12   3  4  5  6  7  8  9
128 | 15 16 17 18 19 20 21  13 14 15 16 17 18 19  10 11 12 13 14 15 16
129 | 22 23 24 25 26 27 28  20 21 22 23 24 25 26  17 18 19 20 21 22 23
130 | 29 30                 27 28 29 30 31        24 25 26 27 28 29 30
131 | 
132 |         July                 August              September
133 | Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
134 |  1  2  3  4  5  6  7            1  2  3  4                     1
135 |  8  9 10 11 12 13 14   5  6  7  8  9 10 11   2  3  4  5  6  7  8
136 | 15 16 17 18 19 20 21  12 13 14 15 16 17 18   9 10 11 12 13 14 15
137 | 22 23 24 25 26 27 28  19 20 21 22 23 24 25  16 17 18 19 20 21 22
138 | 29 30 31              26 27 28 29 30 31     23 24 25 26 27 28 29
139 |                                             30
140 |       October               November              December
141 | Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
142 |     1  2  3  4  5  6               1  2  3                     1
143 |  7  8  9 10 11 12 13   4  5  6  7  8  9 10   2  3  4  5  6  7  8
144 | 14 15 16 17 18 19 20  11 12 13 14 15 16 17   9 10 11 12 13 14 15
145 | 21 22 23 24 25 26 27  18 19 20 21 22 23 24  16 17 18 19 20 21 22
146 | 28 29 30 31           25 26 27 28 29 30     23 24 25 26 27 28 29
147 |                                             30 31
148 | __OUTPUT__
149 | 


--------------------------------------------------------------------------------
/sample/aa.test:
--------------------------------------------------------------------------------
  1 | 18 14 95
  2 | 25 5 95
  3 | 22 11 47
  4 | 12 9 95
  5 | 23 14 95
  6 | 16 6 124
  7 | 31 5 47
  8 | 10 1 47
  9 | 32 13 47
 10 | 14 10 47
 11 | 16 4 58
 12 | 24 6 92
 13 | 5 9 95
 14 | 17 1 47
 15 | 11 9 95
 16 | 28 1 95
 17 | 34 10 92
 18 | 9 3 58
 19 | 15 1 95
 20 | 9 6 124
 21 | 15 3 46
 22 | 16 14 95
 23 | 22 1 92
 24 | 16 1 95
 25 | 27 6 47
 26 | 19 14 95
 27 | 29 0 95
 28 | 4 9 95
 29 | 6 1 95
 30 | 9 7 124
 31 | 16 7 124
 32 | 23 3 47
 33 | 20 0 95
 34 | 30 1 92
 35 | 8 9 124
 36 | 16 11 95
 37 | 15 7 124
 38 | 23 7 124
 39 | 25 10 95
 40 | 1 3 47
 41 | 8 7 124
 42 | 13 9 95
 43 | 15 4 58
 44 | 30 14 95
 45 | 16 8 124
 46 | 24 14 95
 47 | 26 8 47
 48 | 2 3 124
 49 | 26 14 95
 50 | 18 12 95
 51 | 15 6 124
 52 | 32 4 47
 53 | 15 14 95
 54 | 17 14 95
 55 | 21 0 95
 56 | 23 6 124
 57 | 8 2 95
 58 | 30 2 92
 59 | 4 10 95
 60 | 8 4 58
 61 | 27 2 95
 62 | 16 10 124
 63 | 8 6 124
 64 | 3 2 47
 65 | 16 3 46
 66 | 0 5 124
 67 | 7 1 95
 68 | 23 4 92
 69 | 28 8 47
 70 | 27 14 95
 71 | 26 10 95
 72 | 28 14 95
 73 | 7 2 92
 74 | 12 10 45
 75 | 15 0 95
 76 | 33 12 47
 77 | 15 8 124
 78 | 29 7 124
 79 | 18 11 95
 80 | 30 8 92
 81 | 30 5 95
 82 | 12 2 58
 83 | 16 0 95
 84 | 2 5 124
 85 | 2 2 95
 86 | 21 10 95
 87 | 24 2 47
 88 | 15 12 47
 89 | 24 10 47
 90 | 23 8 124
 91 | 23 10 124
 92 | 3 10 92
 93 | 15 5 124
 94 | 17 12 95
 95 | 23 1 95
 96 | 29 8 95
 97 | 29 2 95
 98 | 27 1 95
 99 | 25 9 47
100 | 34 11 47
101 | 33 9 92
102 | 12 3 58
103 | 26 5 95
104 | 8 5 58
105 | 27 11 92
106 | 29 14 95
107 | 16 12 95
108 | 19 10 95
109 | 26 1 95
110 | 17 11 92
111 | 11 10 95
112 | 11 0 95
113 | 26 2 95
114 | 14 1 92
115 | 25 14 95
116 | 28 0 95
117 | 27 10 47
118 | 20 13 92
119 | 9 8 124
120 | 21 14 92
121 | 9 1 95
122 | 17 0 95
123 | 14 0 95
124 | 24 5 92
125 | 32 3 92
126 | 19 12 95
127 | 12 0 95
128 | 16 9 124
129 | 10 10 92
130 | 18 0 95
131 | 21 11 95
132 | 2 8 124
133 | 27 0 95
134 | 28 5 95
135 | 14 13 47
136 | 26 0 95
137 | 20 10 95
138 | 0 6 124
139 | 31 14 47
140 | 9 2 47
141 | 20 11 45
142 | 30 6 124
143 | 25 1 47
144 | 27 5 95
145 | 14 14 92
146 | 31 7 92
147 | 19 11 45
148 | 6 9 95
149 | 16 5 124
150 | 15 9 124
151 | 23 9 124
152 | 18 10 95
153 | 0 4 124
154 | 5 10 45
155 | 5 1 95
156 | 28 2 95
157 | 13 10 95
158 | 20 14 95
159 | 9 4 58
160 | 9 9 124
161 | 2 7 124
162 | 25 2 47
163 | 27 7 47
164 | 28 9 47
165 | 6 10 95
166 | 13 0 95
167 | 8 8 124
168 | 2 6 124
169 | 2 9 124
170 | 19 0 95
171 | 4 1 95
172 | 2 4 124
173 | 18 1 47
174 | 7 10 47
175 | 24 1 95
176 | 8 1 95
177 | 29 5 95
178 | 22 14 95
179 | 29 1 95
180 | 1 7 92
181 | 9 5 124
182 | 32 8 92
183 | 22 5 92
184 | 31 2 92
185 | __INPUT__
186 |            ___________    ____
187 |     ______/   \__//   \__/____\
188 |   _/   \_/  :           //____\\
189 |  /|      :  :  ..      /        \
190 | | |     ::     ::      \        /
191 | | |     :|     ||     \ \______/
192 | | |     ||     ||      |\  /  |
193 |  \|     ||     ||      |   / | \
194 |   |     ||     ||      |  / /_\ \
195 |   | ___ || ___ ||      | /  /    \
196 |    \_-_/  \_-_/ | ____ |/__/      \
197 |                 _\_--_/    \      /
198 |                /____             /
199 |               /     \           /
200 |               \______\_________/
201 | __OUTPUT__
202 | 8 8 62
203 | 13 3 106
204 | 24 18 126
205 | 11 7 126
206 | 21 1 47
207 | 17 1 44
208 | 8 18 126
209 | 9 5 47
210 | 14 17 126
211 | 17 7 106
212 | 19 3 94
213 | 6 13 47
214 | 5 15 108
215 | 17 5 89
216 | 21 18 126
217 | 10 8 95
218 | 4 12 47
219 | 14 16 92
220 | 13 9 34
221 | 16 8 47
222 | 12 0 47
223 | 21 0 95
224 | 17 18 126
225 | 9 6 111
226 | 19 17 46
227 | 20 0 95
228 | 9 17 45
229 | 19 16 47
230 | 0 18 126
231 | 12 4 34
232 | 4 18 126
233 | 2 18 126
234 | 22 17 41
235 | 6 12 108
236 | 1 18 126
237 | 13 11 95
238 | 17 2 47
239 | 12 3 106
240 | 12 9 126
241 | 13 2 124
242 | 9 18 126
243 | 10 12 45
244 | 18 1 45
245 | 22 18 126
246 | 13 15 73
247 | 6 11 124
248 | 6 10 89
249 | 16 9 124
250 | 9 7 126
251 | 5 17 34
252 | 11 8 45
253 | 14 8 95
254 | 17 4 34
255 | 9 12 44
256 | 12 8 39
257 | 12 2 58
258 | 11 17 45
259 | 12 18 126
260 | 13 1 124
261 | 15 13 46
262 | 9 8 46
263 | 11 4 45
264 | 18 13 92
265 | 8 17 45
266 | 3 18 126
267 | 4 17 40
268 | 5 16 93
269 | 25 18 126
270 | 11 11 126
271 | 16 10 124
272 | 5 18 126
273 | 13 16 95
274 | 11 12 34
275 | 10 7 84
276 | 18 18 126
277 | 8 6 106
278 | 12 6 111
279 | 6 16 92
280 | 15 8 46
281 | 19 15 33
282 | 14 18 126
283 | 7 7 40
284 | 20 2 47
285 | 14 14 47
286 | 17 12 92
287 | 13 4 126
288 | 7 13 92
289 | 5 11 47
290 | 13 18 126
291 | 15 4 45
292 | 23 18 126
293 | 7 18 126
294 | 16 11 108
295 | 16 4 118
296 | 4 13 92
297 | 16 13 45
298 | 21 16 92
299 | 19 14 89
300 | 18 3 46
301 | 13 0 124
302 | 15 18 126
303 | 10 11 34
304 | 16 18 126
305 | 5 14 89
306 | 7 17 126
307 | 10 2 89
308 | 20 18 126
309 | 9 11 45
310 | 19 18 126
311 | 10 3 124
312 | 19 1 126
313 | 5 13 47
314 | 12 10 95
315 | 14 4 34
316 | 7 9 47
317 | 16 3 40
318 | 6 18 126
319 | 12 17 40
320 | 12 12 126
321 | 11 1 47
322 | 18 17 89
323 | 10 18 126
324 | 17 6 124
325 | 15 3 47
326 | 16 2 47
327 | 10 17 45
328 | 8 13 47
329 | 20 16 34
330 | 7 12 47
331 | 8 11 59
332 | 11 18 126
333 | 13 10 44
334 | 11 9 34
335 | 10 4 62
336 | __INPUT__
337 |             /|      __
338 |            / |   ,-~ /
339 |           Y :|  //  /
340 |           | jj /( .^
341 |           >-"~"-v"
342 |          /       Y
343 |         jo  o    |
344 |        ( ~T~     j
345 |         >._-' _./
346 |        /   "~"  |
347 |       Y     _,  |
348 |      /| ;-"~ _  l
349 |     / l/ ,-"~    \
350 |     \//\/      .- \
351 |      Y        /    Y
352 |      l       I     !
353 |      ]\      _\    /"\
354 |     (" ~----( ~   Y.  )
355 | ~~~~~~~~~~~~~~~~~~~~~~~~~~
356 | __OUTPUT__
357 | 3 2 92
358 | 5 8 95
359 | 3 4 40
360 | 7 5 92
361 | 9 9 95
362 | 8 7 92
363 | 5 1 86
364 | 8 6 41
365 | 10 9 41
366 | 3 6 95
367 | 8 8 47
368 | 5 9 42
369 | 3 3 40
370 | 7 3 41
371 | 6 3 114
372 | 7 2 47
373 | 0 9 40
374 | 6 6 109
375 | 8 1 124
376 | 8 9 95
377 | 1 9 95
378 | 6 0 47
379 | 9 8 95
380 | 3 5 47
381 | 7 6 95
382 | 2 7 47
383 | 2 1 40
384 | 5 4 34
385 | 6 9 92
386 | 2 9 95
387 | 1 8 95
388 | 4 0 92
389 | 2 6 40
390 | 7 9 95
391 | 4 9 47
392 | 4 6 109
393 | 4 3 114
394 | 3 0 47
395 | 7 4 41
396 | 2 8 92
397 | 7 0 92
398 | 3 9 95
399 | 5 2 124
400 | __INPUT__
401 |    /\ /\
402 |   (  V  |
403 |    \ | /
404 |    (r r)
405 |    ( " )
406 |    /   \
407 |   (_m m_)
408 |   /     \
409 |  _\  _  /_
410 | (___/*\___)
411 | __OUTPUT__
412 | 18 4 124
413 | 1 6 95
414 | 10 6 124
415 | 31 6 95
416 | 3 4 124
417 | 10 5 124
418 | 25 3 95
419 | 3 3 124
420 | 27 4 46
421 | 33 4 46
422 | 35 6 124
423 | 32 5 124
424 | 5 0 112
425 | 14 4 95
426 | 15 7 47
427 | 14 6 95
428 | 21 6 95
429 | 18 5 124
430 | 33 5 46
431 | 13 4 95
432 | 30 3 61
433 | 24 1 92
434 | 0 7 47
435 | 13 3 46
436 | 14 2 95
437 | 34 0 112
438 | 16 2 95
439 | 32 4 124
440 | 9 3 95
441 | 4 5 46
442 | 18 2 92
443 | 3 2 47
444 | 34 6 95
445 | 6 5 124
446 | 38 7 92
447 | 25 2 92
448 | 3 5 124
449 | 26 6 95
450 | 32 3 124
451 | 24 3 61
452 | 15 2 95
453 | 19 3 95
454 | 9 6 95
455 | 24 2 95
456 | 24 6 95
457 | 13 6 95
458 | 36 6 95
459 | 6 2 92
460 | 5 1 92
461 | 16 6 124
462 | 11 3 46
463 | 29 6 95
464 | 18 3 124
465 | 33 1 47
466 | 35 4 124
467 | 6 6 124
468 | 35 2 92
469 | 5 2 95
470 | 23 1 47
471 | 28 6 95
472 | 10 3 124
473 | 5 6 95
474 | 12 6 124
475 | 21 4 46
476 | 16 5 124
477 | 10 4 124
478 | 17 2 47
479 | 23 3 95
480 | 33 2 95
481 | 4 6 95
482 | 32 2 47
483 | 19 4 46
484 | 25 4 46
485 | 11 6 95
486 | 6 3 124
487 | 12 5 124
488 | 35 3 124
489 | 18 1 112
490 | 18 6 124
491 | 21 3 95
492 | 23 6 95
493 | 29 4 46
494 | 3 6 124
495 | 11 1 112
496 | 27 6 95
497 | 23 4 46
498 | 34 2 95
499 | 24 0 112
500 | 27 3 95
501 | 17 6 95
502 | 4 1 47
503 | 7 4 46
504 | 28 3 61
505 | 6 4 124
506 | 8 6 95
507 | 4 2 95
508 | 29 3 95
509 | 12 2 95
510 | 22 2 47
511 | 9 4 46
512 | 15 6 95
513 | 11 7 47
514 | 10 2 47
515 | 20 3 61
516 | 15 4 95
517 | 11 2 92
518 | 7 6 95
519 | 13 2 95
520 | 31 3 95
521 | 35 5 124
522 | 23 2 95
523 | 22 6 95
524 | 22 3 61
525 | 33 6 95
526 | 17 3 46
527 | 32 6 124
528 | 33 3 46
529 | 20 6 95
530 | 4 3 46
531 | 25 6 95
532 | 8 3 61
533 | 4 4 46
534 | 26 3 61
535 | 15 3 46
536 | 7 3 95
537 | 2 6 95
538 | 30 6 95
539 | 37 6 95
540 | 31 4 46
541 | 19 6 95
542 | 34 1 92
543 | __INPUT__
544 |      p                  p         p
545 |     /\     p      p    /\        /\
546 |    /__\   /\_____/\   /__\      /__\
547 |    |. |_=_|. . . .|_=_=_=_=_=_=_|. |
548 |    |. |. .|  ___  |. . . . . . .|. |
549 |    |. |   | |   | |             |. |
550 |  __|__|___|_|___|_|_____________|__|__
551 | /          /   /                      \
552 | __OUTPUT__
553 | 


--------------------------------------------------------------------------------
/cg/bottle1.output:
--------------------------------------------------------------------------------
  1 | 99 bottles of beer on the wall, 99 bottles of beer.
  2 | Take one down and pass it around, 98 bottles of beer on the wall.
  3 | 
  4 | 98 bottles of beer on the wall, 98 bottles of beer.
  5 | Take one down and pass it around, 97 bottles of beer on the wall.
  6 | 
  7 | 97 bottles of beer on the wall, 97 bottles of beer.
  8 | Take one down and pass it around, 96 bottles of beer on the wall.
  9 | 
 10 | 96 bottles of beer on the wall, 96 bottles of beer.
 11 | Take one down and pass it around, 95 bottles of beer on the wall.
 12 | 
 13 | 95 bottles of beer on the wall, 95 bottles of beer.
 14 | Take one down and pass it around, 94 bottles of beer on the wall.
 15 | 
 16 | 94 bottles of beer on the wall, 94 bottles of beer.
 17 | Take one down and pass it around, 93 bottles of beer on the wall.
 18 | 
 19 | 93 bottles of beer on the wall, 93 bottles of beer.
 20 | Take one down and pass it around, 92 bottles of beer on the wall.
 21 | 
 22 | 92 bottles of beer on the wall, 92 bottles of beer.
 23 | Take one down and pass it around, 91 bottles of beer on the wall.
 24 | 
 25 | 91 bottles of beer on the wall, 91 bottles of beer.
 26 | Take one down and pass it around, 90 bottles of beer on the wall.
 27 | 
 28 | 90 bottles of beer on the wall, 90 bottles of beer.
 29 | Take one down and pass it around, 89 bottles of beer on the wall.
 30 | 
 31 | 89 bottles of beer on the wall, 89 bottles of beer.
 32 | Take one down and pass it around, 88 bottles of beer on the wall.
 33 | 
 34 | 88 bottles of beer on the wall, 88 bottles of beer.
 35 | Take one down and pass it around, 87 bottles of beer on the wall.
 36 | 
 37 | 87 bottles of beer on the wall, 87 bottles of beer.
 38 | Take one down and pass it around, 86 bottles of beer on the wall.
 39 | 
 40 | 86 bottles of beer on the wall, 86 bottles of beer.
 41 | Take one down and pass it around, 85 bottles of beer on the wall.
 42 | 
 43 | 85 bottles of beer on the wall, 85 bottles of beer.
 44 | Take one down and pass it around, 84 bottles of beer on the wall.
 45 | 
 46 | 84 bottles of beer on the wall, 84 bottles of beer.
 47 | Take one down and pass it around, 83 bottles of beer on the wall.
 48 | 
 49 | 83 bottles of beer on the wall, 83 bottles of beer.
 50 | Take one down and pass it around, 82 bottles of beer on the wall.
 51 | 
 52 | 82 bottles of beer on the wall, 82 bottles of beer.
 53 | Take one down and pass it around, 81 bottles of beer on the wall.
 54 | 
 55 | 81 bottles of beer on the wall, 81 bottles of beer.
 56 | Take one down and pass it around, 80 bottles of beer on the wall.
 57 | 
 58 | 80 bottles of beer on the wall, 80 bottles of beer.
 59 | Take one down and pass it around, 79 bottles of beer on the wall.
 60 | 
 61 | 79 bottles of beer on the wall, 79 bottles of beer.
 62 | Take one down and pass it around, 78 bottles of beer on the wall.
 63 | 
 64 | 78 bottles of beer on the wall, 78 bottles of beer.
 65 | Take one down and pass it around, 77 bottles of beer on the wall.
 66 | 
 67 | 77 bottles of beer on the wall, 77 bottles of beer.
 68 | Take one down and pass it around, 76 bottles of beer on the wall.
 69 | 
 70 | 76 bottles of beer on the wall, 76 bottles of beer.
 71 | Take one down and pass it around, 75 bottles of beer on the wall.
 72 | 
 73 | 75 bottles of beer on the wall, 75 bottles of beer.
 74 | Take one down and pass it around, 74 bottles of beer on the wall.
 75 | 
 76 | 74 bottles of beer on the wall, 74 bottles of beer.
 77 | Take one down and pass it around, 73 bottles of beer on the wall.
 78 | 
 79 | 73 bottles of beer on the wall, 73 bottles of beer.
 80 | Take one down and pass it around, 72 bottles of beer on the wall.
 81 | 
 82 | 72 bottles of beer on the wall, 72 bottles of beer.
 83 | Take one down and pass it around, 71 bottles of beer on the wall.
 84 | 
 85 | 71 bottles of beer on the wall, 71 bottles of beer.
 86 | Take one down and pass it around, 70 bottles of beer on the wall.
 87 | 
 88 | 70 bottles of beer on the wall, 70 bottles of beer.
 89 | Take one down and pass it around, 69 bottles of beer on the wall.
 90 | 
 91 | 69 bottles of beer on the wall, 69 bottles of beer.
 92 | Take one down and pass it around, 68 bottles of beer on the wall.
 93 | 
 94 | 68 bottles of beer on the wall, 68 bottles of beer.
 95 | Take one down and pass it around, 67 bottles of beer on the wall.
 96 | 
 97 | 67 bottles of beer on the wall, 67 bottles of beer.
 98 | Take one down and pass it around, 66 bottles of beer on the wall.
 99 | 
100 | 66 bottles of beer on the wall, 66 bottles of beer.
101 | Take one down and pass it around, 65 bottles of beer on the wall.
102 | 
103 | 65 bottles of beer on the wall, 65 bottles of beer.
104 | Take one down and pass it around, 64 bottles of beer on the wall.
105 | 
106 | 64 bottles of beer on the wall, 64 bottles of beer.
107 | Take one down and pass it around, 63 bottles of beer on the wall.
108 | 
109 | 63 bottles of beer on the wall, 63 bottles of beer.
110 | Take one down and pass it around, 62 bottles of beer on the wall.
111 | 
112 | 62 bottles of beer on the wall, 62 bottles of beer.
113 | Take one down and pass it around, 61 bottles of beer on the wall.
114 | 
115 | 61 bottles of beer on the wall, 61 bottles of beer.
116 | Take one down and pass it around, 60 bottles of beer on the wall.
117 | 
118 | 60 bottles of beer on the wall, 60 bottles of beer.
119 | Take one down and pass it around, 59 bottles of beer on the wall.
120 | 
121 | 59 bottles of beer on the wall, 59 bottles of beer.
122 | Take one down and pass it around, 58 bottles of beer on the wall.
123 | 
124 | 58 bottles of beer on the wall, 58 bottles of beer.
125 | Take one down and pass it around, 57 bottles of beer on the wall.
126 | 
127 | 57 bottles of beer on the wall, 57 bottles of beer.
128 | Take one down and pass it around, 56 bottles of beer on the wall.
129 | 
130 | 56 bottles of beer on the wall, 56 bottles of beer.
131 | Take one down and pass it around, 55 bottles of beer on the wall.
132 | 
133 | 55 bottles of beer on the wall, 55 bottles of beer.
134 | Take one down and pass it around, 54 bottles of beer on the wall.
135 | 
136 | 54 bottles of beer on the wall, 54 bottles of beer.
137 | Take one down and pass it around, 53 bottles of beer on the wall.
138 | 
139 | 53 bottles of beer on the wall, 53 bottles of beer.
140 | Take one down and pass it around, 52 bottles of beer on the wall.
141 | 
142 | 52 bottles of beer on the wall, 52 bottles of beer.
143 | Take one down and pass it around, 51 bottles of beer on the wall.
144 | 
145 | 51 bottles of beer on the wall, 51 bottles of beer.
146 | Take one down and pass it around, 50 bottles of beer on the wall.
147 | 
148 | 50 bottles of beer on the wall, 50 bottles of beer.
149 | Take one down and pass it around, 49 bottles of beer on the wall.
150 | 
151 | 49 bottles of beer on the wall, 49 bottles of beer.
152 | Take one down and pass it around, 48 bottles of beer on the wall.
153 | 
154 | 48 bottles of beer on the wall, 48 bottles of beer.
155 | Take one down and pass it around, 47 bottles of beer on the wall.
156 | 
157 | 47 bottles of beer on the wall, 47 bottles of beer.
158 | Take one down and pass it around, 46 bottles of beer on the wall.
159 | 
160 | 46 bottles of beer on the wall, 46 bottles of beer.
161 | Take one down and pass it around, 45 bottles of beer on the wall.
162 | 
163 | 45 bottles of beer on the wall, 45 bottles of beer.
164 | Take one down and pass it around, 44 bottles of beer on the wall.
165 | 
166 | 44 bottles of beer on the wall, 44 bottles of beer.
167 | Take one down and pass it around, 43 bottles of beer on the wall.
168 | 
169 | 43 bottles of beer on the wall, 43 bottles of beer.
170 | Take one down and pass it around, 42 bottles of beer on the wall.
171 | 
172 | 42 bottles of beer on the wall, 42 bottles of beer.
173 | Take one down and pass it around, 41 bottles of beer on the wall.
174 | 
175 | 41 bottles of beer on the wall, 41 bottles of beer.
176 | Take one down and pass it around, 40 bottles of beer on the wall.
177 | 
178 | 40 bottles of beer on the wall, 40 bottles of beer.
179 | Take one down and pass it around, 39 bottles of beer on the wall.
180 | 
181 | 39 bottles of beer on the wall, 39 bottles of beer.
182 | Take one down and pass it around, 38 bottles of beer on the wall.
183 | 
184 | 38 bottles of beer on the wall, 38 bottles of beer.
185 | Take one down and pass it around, 37 bottles of beer on the wall.
186 | 
187 | 37 bottles of beer on the wall, 37 bottles of beer.
188 | Take one down and pass it around, 36 bottles of beer on the wall.
189 | 
190 | 36 bottles of beer on the wall, 36 bottles of beer.
191 | Take one down and pass it around, 35 bottles of beer on the wall.
192 | 
193 | 35 bottles of beer on the wall, 35 bottles of beer.
194 | Take one down and pass it around, 34 bottles of beer on the wall.
195 | 
196 | 34 bottles of beer on the wall, 34 bottles of beer.
197 | Take one down and pass it around, 33 bottles of beer on the wall.
198 | 
199 | 33 bottles of beer on the wall, 33 bottles of beer.
200 | Take one down and pass it around, 32 bottles of beer on the wall.
201 | 
202 | 32 bottles of beer on the wall, 32 bottles of beer.
203 | Take one down and pass it around, 31 bottles of beer on the wall.
204 | 
205 | 31 bottles of beer on the wall, 31 bottles of beer.
206 | Take one down and pass it around, 30 bottles of beer on the wall.
207 | 
208 | 30 bottles of beer on the wall, 30 bottles of beer.
209 | Take one down and pass it around, 29 bottles of beer on the wall.
210 | 
211 | 29 bottles of beer on the wall, 29 bottles of beer.
212 | Take one down and pass it around, 28 bottles of beer on the wall.
213 | 
214 | 28 bottles of beer on the wall, 28 bottles of beer.
215 | Take one down and pass it around, 27 bottles of beer on the wall.
216 | 
217 | 27 bottles of beer on the wall, 27 bottles of beer.
218 | Take one down and pass it around, 26 bottles of beer on the wall.
219 | 
220 | 26 bottles of beer on the wall, 26 bottles of beer.
221 | Take one down and pass it around, 25 bottles of beer on the wall.
222 | 
223 | 25 bottles of beer on the wall, 25 bottles of beer.
224 | Take one down and pass it around, 24 bottles of beer on the wall.
225 | 
226 | 24 bottles of beer on the wall, 24 bottles of beer.
227 | Take one down and pass it around, 23 bottles of beer on the wall.
228 | 
229 | 23 bottles of beer on the wall, 23 bottles of beer.
230 | Take one down and pass it around, 22 bottles of beer on the wall.
231 | 
232 | 22 bottles of beer on the wall, 22 bottles of beer.
233 | Take one down and pass it around, 21 bottles of beer on the wall.
234 | 
235 | 21 bottles of beer on the wall, 21 bottles of beer.
236 | Take one down and pass it around, 20 bottles of beer on the wall.
237 | 
238 | 20 bottles of beer on the wall, 20 bottles of beer.
239 | Take one down and pass it around, 19 bottles of beer on the wall.
240 | 
241 | 19 bottles of beer on the wall, 19 bottles of beer.
242 | Take one down and pass it around, 18 bottles of beer on the wall.
243 | 
244 | 18 bottles of beer on the wall, 18 bottles of beer.
245 | Take one down and pass it around, 17 bottles of beer on the wall.
246 | 
247 | 17 bottles of beer on the wall, 17 bottles of beer.
248 | Take one down and pass it around, 16 bottles of beer on the wall.
249 | 
250 | 16 bottles of beer on the wall, 16 bottles of beer.
251 | Take one down and pass it around, 15 bottles of beer on the wall.
252 | 
253 | 15 bottles of beer on the wall, 15 bottles of beer.
254 | Take one down and pass it around, 14 bottles of beer on the wall.
255 | 
256 | 14 bottles of beer on the wall, 14 bottles of beer.
257 | Take one down and pass it around, 13 bottles of beer on the wall.
258 | 
259 | 13 bottles of beer on the wall, 13 bottles of beer.
260 | Take one down and pass it around, 12 bottles of beer on the wall.
261 | 
262 | 12 bottles of beer on the wall, 12 bottles of beer.
263 | Take one down and pass it around, 11 bottles of beer on the wall.
264 | 
265 | 11 bottles of beer on the wall, 11 bottles of beer.
266 | Take one down and pass it around, 10 bottles of beer on the wall.
267 | 
268 | 10 bottles of beer on the wall, 10 bottles of beer.
269 | Take one down and pass it around, 9 bottles of beer on the wall.
270 | 
271 | 9 bottles of beer on the wall, 9 bottles of beer.
272 | Take one down and pass it around, 8 bottles of beer on the wall.
273 | 
274 | 8 bottles of beer on the wall, 8 bottles of beer.
275 | Take one down and pass it around, 7 bottles of beer on the wall.
276 | 
277 | 7 bottles of beer on the wall, 7 bottles of beer.
278 | Take one down and pass it around, 6 bottles of beer on the wall.
279 | 
280 | 6 bottles of beer on the wall, 6 bottles of beer.
281 | Take one down and pass it around, 5 bottles of beer on the wall.
282 | 
283 | 5 bottles of beer on the wall, 5 bottles of beer.
284 | Take one down and pass it around, 4 bottles of beer on the wall.
285 | 
286 | 4 bottles of beer on the wall, 4 bottles of beer.
287 | Take one down and pass it around, 3 bottles of beer on the wall.
288 | 
289 | 3 bottles of beer on the wall, 3 bottles of beer.
290 | Take one down and pass it around, 2 bottles of beer on the wall.
291 | 
292 | 2 bottles of beer on the wall, 2 bottles of beer.
293 | Take one down and pass it around, 1 bottle of beer on the wall.
294 | 
295 | 1 bottle of beer on the wall, 1 bottle of beer.
296 | Go to the store and buy some more, 99 bottles of beer on the wall.
297 | 


--------------------------------------------------------------------------------