15
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 code-challenge, 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!
I suppose it's fine if we remove trailing whitespace (in case we replace any of the trailing
?
with spaces)? – Martin Ender – 2016-01-03T18:25:43.483Are you sure there's a unique solution for each puzzle? – KSFT – 2016-01-03T18:29:35.627
@KSFT Does it matter if the solutions are unique? – Martin Ender – 2016-01-03T18:30:06.787
@MartinBüttner If it isn't unique and someone gives a different solution, the hash won't match. – KSFT – 2016-01-03T18:32:19.717
@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. – Martin Ender – 2016-01-03T18:32:55.090
@KSFT No, but that is not relevant. The hash will only be used to verify submission and the submission itself will be verified here.
– Adnan – 2016-01-03T18:43:50.597@Adnan Yes, replacing
?
with spaces is find, but what I'm asking is whether I can omit trailing spaces after doing so. (As well as trailing empty lines.) – Martin Ender – 2016-01-03T18:44:22.750@MartinBüttner Yes, trailing whitespaces (and trailing empty lines) may be deleted as they are considered to be no ops. – Adnan – 2016-01-03T18:48:14.970
Should the hashes be salted with additional random text that the people posting solutions keep secret? As it is, it doesn't seem hard to brute-force to find other people's posted solutions. – KSFT – 2016-01-03T19:19:03.650
@KSFT That doesn't seem necessary. You can try to brute-force it, but I'm pretty confident it would take a long time for just one hash. – Adnan – 2016-01-03T19:25:44.010
Just clarifying, there is no trailing space on puzzle 7? – Martin Ender – 2016-01-03T21:05:12.610
@MartinBüttner Nope. – Adnan – 2016-01-03T21:06:04.920
May I replace
?
s by?
s? I'm coding on a phone and I'm lazy. :P – PurkkaKoodari – 2016-01-04T19:57:48.393@Pietu1998 Yes, that is possible :). (note that the
?
is a random operator in Befunge) – Adnan – 2016-01-04T20:00:01.350Do any of your solutions make use of interpreter's non-standard behaviour that it reflects the IP when encountering unknown commands? – Martin Ender – 2016-01-05T08:56:18.393
@MartinBüttner If I remember correctly, that is not used. – Adnan – 2016-01-05T08:59:24.120
If I understood correctly, now is the time to reveal our solutions, right? You might also want to notify @MartinBüttner about that. – PurkkaKoodari – 2016-01-11T19:12:22.493
@Pietu1998 Yes, that is correct – Adnan – 2016-01-11T19:28:24.623