/* Gode Golf (Rosetta code) in Picat. http://rosettacode.org/wiki/Code_Golf:_Code_Golf """ First, show the shortest possible program that will emit the nine-character string “Code Golf”, without the quotation marks and without anything after the final “f”. Then show the shortest possible program that does the same thing but without itself containing any string or character literals, and without requiring any input or any environment variables or command-line arguments, though the name of the running program can be used. Extra credit: how big is the executable required to perform the first task? Skip details about any prior compilation steps that might be involved. """ This program was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ % import v3_utils. % import util. % import cp. main => go. go ?=> % cl(c),print(C), % 18 chars % 12345678901234567890123456789012345678901234567890 print("Code Golf"), nl, % 55 chars % 10 20 30 40 50 % 123456789012345678901234567890123456789012345678901234567890 print([chr(I):I in [67,111,100,101,32,71,111,108,102]]), nl, % 50 chars % 10 20 30 40 50 % 123456789012345678901234567890123456789012345678901234567890 [67,111,100,101,32,71,111,108,102].map(chr).print. go2 => nl, % % 51 chars % % 10 20 30 40 50 % % 123456789012345678901234567890123456789012345678901234567890 print([chr(I+32):I in [35,79,68,69,0,39,79,76,70]]), % % No "'s: 54 chars % % 10 20 30 40 50 % % 123456789012345678901234567890123456789012345678901234567890 % print(map(chr,[0'C,0'o,0'd,0'e,0' ',0'G,0'o,0'l,0'f])), % nl, nl, % println([to_fstring("%x",I.ord):I in "Code Golf"]), % print(0x436f646520476f6c66.to_radix_string(36)), % Almost: CODEGOLF % print(to_radix_string(993423098499,36)), % Almost: [CODE,GOLF] % println([to_radix_string(I,36): I in [591458,778371].flatten]) nl, nl. c(I)=chr(I).