29
4
Very heavily inspired by this challenge Code Golf: Your own pet ASCII snake - I thought making it horizontal would add an extra layer of complexity.
An example horizontal snake:
0 0
0 0 0 000
00 0 00 000 0 0
000 0 0 0 00
0 000
And the rules are:
- Exactly 5 lines of characters are printed
- Each line is exactly 30 characters long, consisting of a combination of spaces and the character you choose to draw your snake with
- Your snake starts on line 3
- The next line to be used for drawing your snake must be randomly chosen from your current line, one line above (if you're not already on line 1) or one line below (if you're not already on line 5).
- These choices must be equally weighted. So if you are on line 1, you have a 50% chance to stay on line 1 and a 50% chance to move to line 2. If you are on line 2, you have a 33% chance to move to line 1, a 33% chance to stay on line 2 or a 33% chance to move to line 3
- Your snake does not need to visit every single line.
5Welcome to PPCG! This is a good first challenge. – Giuseppe – 2018-02-21T16:43:13.060
For clarification, if we're on the edge, do we have to uniformly pick (stay on the same line) and (go to a different line) or can we have non-uniform weights? – Giuseppe – 2018-02-21T16:47:00.747
And off the edges, do we have to uniformly pick up/down/same line? – Giuseppe – 2018-02-21T16:47:32.150
2Mmm... at least the 5-line limitation stops people from stealing answers from the other one with a transpose appended. – Magic Octopus Urn – 2018-02-21T16:48:36.473
Humm, I think it should be an even weight. I will clarify the question rules – Scoots – 2018-02-21T16:49:24.400
Can we output an array of lines? – Shaggy – 2018-02-21T17:58:15.930
Also, must we use
0
for the snake or can we use any non-whitespace character? – Shaggy – 2018-02-21T18:21:50.857@Shaggy "and the character you choose to draw your snake with" – Giuseppe – 2018-02-21T18:31:33.663
Thanks, @Giuseppe; missed that scanning through it on my phone. – Shaggy – 2018-02-21T18:33:04.137
@Shaggy I feel like allowing that now would be unfair to the other answers – Scoots – 2018-02-21T22:01:26.990
9Does physically rotating the monitor by 90° count as a byte? :D – Eric Duminil – 2018-02-22T11:22:52.720
...this is snek – Grant Miller – 2018-02-27T00:59:54.750