15
\$\begingroup\$

Introduction

For the ones wondering what Befunge exactly is, it is a two-dimensional stack based language made in 1993 by Chris Pressy. I made 7 brain teasers that need to be solved in Befunge-93. This is quite an experimental challenge, but I thought it's worth a shot :). A full list of all commands used in Befunge-93 can be found here.

How to play?

The task is a bit like a cops-and-robbers without the cops. It's just basically cracking submissions in order to get points. Every puzzle contains question marks. These must be replaced by any printable ascii character in the range 32 - 127, that includes whitespace. See the following example:

??????@

Given is that the output must be hi. After some puzzling, we can find out that the solution was:

"ih",,@

But! You do not give the solution. That is for the prevention of cheating. You don't post the solution, but the hash. The hash is generated with the following snippet:

String.prototype.hashCode = function() { var namevalue = document.getElementById("inputname").value;  var namenumber = 123;for (var character = 0; character < namevalue.length; character++) {namenumber += namevalue.substring(0, 1).charCodeAt(0);}var hash = 123 + namenumber, i, chr, len;if (this.length === 0) {return 0;}for (i = 0, len = this.length; i < len; i++) {chr = this.charCodeAt(i);hash = ((hash << 5) - hash) + chr; hash |= 0; }hash = Math.abs(hash);if ((hash).toString(16).length < 20) {for (var rand = 123; rand < 199; rand++) {hash = hash * rand;if ((hash).toString(16).length >= 20) {  break; }}}return (hash).toString(16).substring(2, 12);};function placeHash() { var pretext = document.getElementById("inputhash").value; var resultinghash = pretext.hashCode(); document.getElementById("resulthash").innerHTML = 'Your hash: <span class="hashtext">' + resultinghash + "</span>";}
p {font-family: monospace;color: black;} .hashtext{color: red;font-weight:bold}
<div class="container"><p>Personal hash generator:<p><textarea id="inputhash" placeholder="Your submission" cols="40" rows="4"></textarea><br><textarea id="inputname" placeholder="Your name" cols="40" rows="1"></textarea><br><button class="hashbutton" onclick="placeHash()">Generate Hash!</button><br><p id="resulthash">Your hash:</p></div><!-- Created by Adnan -->

How to use the snippet?

  • First, paste the solution into the submission section
  • Second, enter your username (nothing else, this will actually be verified after the time limit)
  • Third, press Generate Hash! to obtain your personal hash.
  • Copy and paste the hash into your submission.

The puzzles

Puzzle 1 (Score: 3)

 ??
???      ?
??????????
         @

Output (note the trailing whitespace):

1 2 3 4 5 6 7 8 9 10 

Puzzle 2 (Score: 3)

 ????    ?
??????????
??       ?
         @

Output:

abcdefghijklmnopqrstuvwxyz

Puzzle 3 (Score: 5)

  ?????????
    ?????  ???
    ?     ?
    ? ?   ?  ?
          ?
          ?  ?
  ??????  ?  ?
    ?     ?  ?
       ?  ?  @
  ??????? ?
    ?  ?
????  ??
?  ??

Output:

Hello World!

Puzzle 4 (Score: 2)

??????@

Output (note the trailing whitespace):

123 

Puzzle 5 (Score: 5)

    ?
  ?????
???@?????
 ??????
?????????

Output:

Befunge

Puzzle 6 (Score: 5)

?    ?   ?
     ?
??????????
     ?
     ?
     ????????                         ??????????????
     ?????"floG edoC dna selzzuP gnimmargorP "??????
     @

Output:

###################################
 Programming Puzzles and Code Golf
###################################

Puzzle 7 (Score: 3)

???? ?????
   ???????
  @???????

Output:

012345678910

  • This is , the person with the most amount of points wins!
  • In case of a tie, the person who submitted all submissions first, wins.
  • The last day for submission is January 10 UTC. After that, you have 2 days to post the full solution, with the hashes already included. These will be verified :).

How to post?

Use the following snippet to post your submission:

#N solutions:

Puzzle 1: `[hash 1]`

Puzzle 2: `[hash 2]`

etc.

It is not necessary to solve the puzzles in order. All programs have been tested here and will be used for verification.

Good luck!

\$\endgroup\$
  • \$\begingroup\$ I suppose it's fine if we remove trailing whitespace (in case we replace any of the trailing ? with spaces)? \$\endgroup\$ – Martin Ender Jan 3 '16 at 18:25
  • \$\begingroup\$ Are you sure there's a unique solution for each puzzle? \$\endgroup\$ – KSFT Jan 3 '16 at 18:29
  • \$\begingroup\$ @KSFT Does it matter if the solutions are unique? \$\endgroup\$ – Martin Ender Jan 3 '16 at 18:30
  • \$\begingroup\$ @MartinBüttner If it isn't unique and someone gives a different solution, the hash won't match. \$\endgroup\$ – KSFT Jan 3 '16 at 18:32
  • \$\begingroup\$ @KSFT The hashes won't match anyway, because the user name is part of the hash. The purpose of the hash is only to verify who found a working solution first. \$\endgroup\$ – Martin Ender Jan 3 '16 at 18:32
5
\$\begingroup\$

7 solutions, 26 points

I'm typing this on my phone, because I don't have access to my computer currently. I actually had to work out Puzzle 6 by pen & paper.

Puzzle 1 (Score 3): 4f52d5b243

 1v
v:<      <
>.1+:56+-|
         @

This one is fairly straight forward. Get a 1 on the stack, then print-increment-compare-loop until 11 is hit.

Puzzle 2 (Score 3): 85226eba20

 "`"     v
v"z":,:+1<
>-       |
         @

Basically the same as the previous one, just with characters instead of numbers. Used a different IP route though.

Puzzle 3 (Score 5): 1ff5bcb1d9

  "!dlroW"v
    >,,,,  ,,v
    ,     "
    , ?      ,
          o
          l   
  ??,???  l   
    ,     e   
       ?  "  @
  ??^,"H" <
    ?  ?
????  ??
?  ??

Here I cheaped out a little bit. Push the string to the stack and print characters manually, navigating through the spaces. I had loads of extra room, so I just left most of the question marks in. Note the trailing spaces on rows 6 to 8, I didn't remove them when calculating the hash.

Puzzle 4 (Score 2): f8b7bdf741

"{".  @

Really simple, just get the character with the correct code and print as a number, with two free spaces.

Puzzle 5 (Score 5): c4db4b6af9

    v
  ??"??
#,_@e">>:
 <"B"<^
ung"<^"ef

This was a fun one to get right. May not work correctly on some interpreters due to wrapping strings & jumps, works on the linked one. Basically, the code pushes the output string and then enters the standard printing loop, wrapping on the sides.

Puzzle 6 (Score 5): 356e912eec

1        v
     #
     v??v_

     5
      75<^                              p15:-1g15,:*
     >5+:,"floG edoC dna selzzuP gnimmargorP ">:#,_@
     @

Now this was the "masterpiece". I actually took a piece of paper and spent some time on this. (Actually, I did some extra work by missing the space in the string when copying.) Note the trailing spaces on row 4, I didn't remove them when calculating the hash.

The code works by first pushing a one to enter the main loop. The loop uses the # on the second line as a counter, and both prints and pushes a # on every iteration. After that a newline is printed and pushed. Next, the given string is pushed. Finally, the code enters a printing loop, which prints everything on the stack in reverse, which means the string, then the newline, and finally the remaining #s.

Puzzle 7 (Score 3): 0881fc2619

"0"> :,1+v
   |-":":<
  @>"10",,

This is almost the same as Puzzle 2, but with a different route, different output characters, an additional 01 in the end and a quick wrap to finish it off.

\$\endgroup\$
  • \$\begingroup\$ Haha, I should have thought a bit longer for the puzzle 3 and 4. Everything looks good :) \$\endgroup\$ – Adnan Jan 11 '16 at 19:52
3
\$\begingroup\$

4 solutions, 15 points

I hope I didn't mess up the trailing whitespace anywhere when generating the hashes.

Puzzle 1 (Score 3): de1de4c4c8

 v
v<       >
>1+:.:9`!|
         @

Puzzle 3 (Score 5): 071cad0879

  "!dlroW"v
    >,,,,  ,,v
    ,     "
    ,        ,
          o
          l
    ,     l
    ,     e
          "  @
    ^,"H" <

Puzzle 4 (Score 2): 531940bc43

"{".  @

Puzzle 5 (Score 5): 5bafaed8e9

    ^
  v >,,
n"<@,, ,"
 "e"^>,
uge"<^"Bf
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.