Date created: Friday, March 8, 2013 6:32:19 PM. Last modified: Sunday, March 10, 2013 10:49:08 PM
DFTBA
Dont Forget To Be Awesome!
I used BF to try my hand at a code golf puzzle;
http://codegolf.stackexchange.com/questions/10532/write-ascii-art-obfuscated-code-read-as-and-resulting-in-dftba
Challenge:
The challenge is to write the most elaborate code, embedded in ASCII art that reads and prints "DFTBA". For example, the following reads DFTBA: oooooooooo. oooooooooooo ooooooooooooo oooooooooo. .o. `888' `Y8b `888' `8 8' 888 `8 `888' `Y8b .888. 888 888 888 888 888 888 .8"888. 888 888 888oooo8 888 888oooo888' .8' `888. 888 888 888 " 888 888 `88b .88ooo8888. 888 d88' 888 888 888 .88P .8' `888. o888bood8P' o888o o888o o888bood8P' o88o o8888o And the following, in bash prints DFTBA echo "DFTBA" The challenge is to write one that does both. Winning conditions Valid answers, (all conditions at my discretion) Can be clearly read as DFTBA Print DFTBA when executed Must be functional with no Internet connection have letters of equal height must not have more than 80 columns must not have more than 10 rows Points (highest sum wins) Rows * Columns / 32 Readability: 25 for legible, 50 for very clear 1 point for each different non-whitespace character used
My Submission
Start by roughly writing DFTBA in ASCII (this doesn't fill the max limit of 80 columns by 10 rows so I have some 'play' room):
@@@@@@ @@@@@@@ @@@@@@@ @@@@@@ @@ @@@@@@ @@@@@@@ @@@@@@@ @@@@@@ @@ @@ @@ @@ @@ @@@ @@ @@ @@ @@ @@ @@ @@@@@@@ @@@ @@ @@ @@ @@ @@ @@ @@@@@@@ @@@ @@@@@@ @@@@@@@@ @@ @@ @@ @@@ @@@@@@ @@ @@ @@ @@ @@ @@@ @@ @@ @@ @@ @@ @@ @@ @@@ @@ @@ @@ @@ @@@@@@ @@ @@@ @@@@@@ @@ @@ @@@@@@ @@ @@@ @@@@@@ @@ @@
A very basic BF program can write the required 5 letters in order to the screen. This is by no means the best BF program, but I wrote it in 60 seconds as that wasn't the difficult part in this challenge:
+++++ +++++ [ > +++++ ++ > +++++ +++ << - ] > -- . ++ . > ++++ . < ---- . - .
Here it is again with some notes about ASCII values:
// D : 68 // F : 70 // T : 84 // B : 66 // A : 65 +++++ +++++ [ > +++++ ++ // F : 70 > +++++ +++ // P : 80 << - ] > -- . // D : 68 ++ . // F : 70 > ++++ . // T : 84 < ---- . // B : 66 - . // A : 65
Now we can remove my comments and squash that code into one line of commands, and embed it into the ASCII art I drew before. I have alternated between AT symbols (@) and BF commands (the squashed line of code I have embedded throughout is at the end):
+@+@+@ +@+@+@+ @+@+@+@ @[@>@+ @+ @+@+@+ @+@+@>@ +@+@+@+ @+@+@+ @+ @< @< @- @] @>@ -@ -@ .@ +@ +@ .@ >@+@+@+ @+@ .@ <@ -@ -@ -@ -@ .@-@.@@ @@@ @@@@@@ @@@@@@@@ @@ @@ @@ @@@ @@@@@@ @@ @@ @@ @@ @@ @@@ @@ @@ @@ @@ @@ @@ @@ @@@ @@ @@ @@ @@ @@@@@@ @@ @@@ @@@@@@ @@ @@ @@@@@@ @@ @@@ @@@@@@ @@ @@ ++++++++++[>+++++++>++++++++<<-]>--.++.>++++.<----.-.
Now I need to bulk this out with more @ symbols to get as close to 80x10 as I can without using gratuitous spacing (I achieved 80x10):
+@+@+@@@@@ @+@+@+@+@@@ @@@+@+@+@@@ @@[@>@+@@ @@+@ @+@+@+@@@@ @@+@+@>@@@@ @@+@+@+@+@@ @@+@+@+@@ @@+ @<@ @<@ @-@ @@] @>@ @-@ -@@@ @.@ +@@ +@@ .@@@ @>@+@+@+@@@ @+@ @.@ <@@@ @-@ -@@ -@@ -@@@ @.@-@.@@@@@ @@@ @@@@@@@@@ @@@@@@@@@@ @@@ @@@@ @@@ @@@ @@@@@@@@@ @@@@@@@@@@ @@@ @@@@ @@@ @@@ @@@ @@@@ @@@ @@@ @@@ @@@ @@@ @@@ @@@ @@@@ @@@ @@@ @@@@@@@@@@ @@@ @@@ @@@@@@@@@ @@@ @@@ @@@@@@@@@@ @@@ @@@ @@@@@@@@@ @@@ @@@
Now I must mingle in all the ASCII characters between 32 and 127 for more points, excluding ASCII value 127 which is DELETE and the 8 BF commands:
[ ] , . < > + -Which means: 127 standard ASCII characters -32 (0 to 31 are "non-printable"), 127 which is delete and these 8, leaves 87 characters for me to embed. This gives the following result:
+l+A+O#@e@ /+@+|+2+@@X @*3+}+@+@YZ q4[@>@+@@ @:+@ @+B+"+~@@N @p+K+%>@@v@ dJ+w+@+@+@@ I@+@+@+@@ (@+ @<@ @<@ @-@ @@] U>@ @-@ -@@f @.r +@E +@@ .@@0 @>@+@+@+@@@ @+@ @.@ <@@@ @-' -@@ -@R -9@@ @.@-@.@$c@@ @@@ @@g&@@6@H @h@@7@i@@@ @u@ Q@1@ M@L )nG @?@@@x@@@ `@@@j@@{D@ !@@ @P@@ @bm ¬@@ @@@ @@\@ @@F @8@ @S@ @@@ @V@ @T@ @@k _@@@ @@@ @@@ @a@;@C@@s@ @@@ @o@ @@=@5@@@@ @@@ @@@ @t@@@^@@@@ W@@ @@@ @@@@y@@@@ @@z @@, abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890 {space character} !"#$%&'()*/ :;=?@\^_`{}|~ 87 standard characters (95 minus the 8 bf characters/commands) 80x10=800/32=25+25+87=137 87 standard characters (95 minus the 8 bf characters/commands) & 7 of the 8 BF characters 80x10=800/32=25+25+87+7=144 87 standard characters (95 minus the 8 bf characters/commands) & 8 of the 8 BF characters 80x10=800/32=25+25+87+8=145
Note that in the above, I have replaced the last @ with a comma ','. This is the BF command to wait for user input, so my program will run and print DFTBA as required by the rules but then hang indefinably waiting for user input or the user to stop the program. There is nothing in the rules about what the program should do after printing DFTBA. This allows for the maximum possible points using only the standard ASCII characters from 32 to 126.
At a later date the op confirmed that extended ASCII characters can be used. I can include the characters from 128 up to ASCII decimal value 255. Now my answer looks like this:
+l+A+O#@e@ /+@+|+2+@@X @*3+}+@+@YZ q4[@>@+@@ @:+@ @+B+"+~@@N @p+K+%>@@v@ dJ+w+@+@+@@ I@+@+@+@@ (@+ @<@ @<@ @-@ @@] U>@ @-@ -@@f @.r +@E +@@ .@@0 @>@+@+@+@@@ @+@ @.@ <@@@ @-' -@@ -€R -9‚ ƒ.„-….†$c‡ˆ ‰Š‹ Œg&Ž6H ‘h’“7”i•–— ˜u™ Qš1› MœL )nG ?žŸ x¡¢£ `¤¥¦j@§{D¨ !©ª «P¬ ®bm ¬¯° ±²³ ´µ\¶ ·¸F ¹8º »S¼ ½¾¿ ÀVÁ ÂTà ÄÅk _ÆÇÈ ÉÊË ÌÍÎ ÏaÐ;ÑCÒÓsÔ ÕÖ× ØoÙ ÚÛ=Ü5ÝÞßà áâã äåæ çtèéê^ëìíî Wïð ñòó ôõö÷yøùúû üýz þÿ, The extended characters from 128 to 255 are: €‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ 87 standard characters (95 minus the 8 bf characters/commands) and 127 extended characters and 7 of the 8 bf characters 80x10=800/32=25+25+87+127+7=271 87 standard characters (95 minus the 8 bf characters/commands) and 127 extended characters and 8 of the 8 bf characters 80x10=800/32=25+25+87+127+8=272
A row through the output above is not quite lined up with the rest of the output (roughly the middle row). This picture shows that its just this site not displaying it properly. Notepad will display it correct where as Wordpad wont. Fixed width font issue I guess.
Writing this in Windows XP (in 2013?!) causes problems because none of the built in fonts seem to have all the extended ASCII characters. The only way to prove all extended ASCII characters are included is with a Hex editor/viewer. This is from Notepad++ with the "HEX-Editor" plugin:
Files:
DFTBA.bf - BF code to print "DFTBA" to the screen
DFTBA_Golf.bf - Arrangement of @ symbols for ASCII DFTBA template
DFTBA_Golf_Test1.bf - Embed BF code into ASCII art
DFTBA_Golf_Test2.bf - Grow ASCII art to fill 80x10 grid
DFTBA_Golf_Test3.bf - Embed additional standard ASCII characters
DFTBA_Golf_Test5.bf - Embed extended ASCII characters
Previous page: RoboCopy and Delete Old Backups
Next page: My Name