13
1
Create a program that determines, given an input of the path, whether Mario can reach the end, denoted by E
, from the start, denoted by S
.
A path will look something like this:
S = E
=====
In a path, the various symbols and what they represent are:
=
: wall/floor/ceiling. Mario cannot walk through wall , and cannot fall past a floor, or jump past a ceiling (he would hit his head)S
: air, except showing where Mario starts. This will always appear in the left-most column of the input, at ground level.E
: air, except showing where Mario wants to get. This will always appear in the right-most column of the input, at ground level.
The input will have spaces at every place where Mario could walk.
Mario can only move forward; in this example Mario cannot get to the goal
S
===
===
E
====
nor can he in this one
E
==
==
#==
==
==
==
S ==
======
However, he can reach the space denoted by #
(which will not appear in input), because he can jump up to four cells high; Mario is superhuman. As another example of his superhumanity:
S
=
=
=
=
=
= #
= =
=
=
=
= E
=======
Mario can get to the E
by falling the great distance, surviving, and walking calmly to E
. Note that he cannot reach the #
, because Mario falls straight down.
Mario can jump really high, but not very far forward by comparison.
S E
== ==
= =
Mario may attempt to jump the gap, but he will fail, and fall straight in. he cannot reach the end.
Mario can reach the goal in all of these examples:
E
=
=
=
S=
==
=
= E
S= =
== =
= =
=====
S
=
= E
====
This is code golf, so fewest bytes wins!
This looks similar with MarioLANG. – None – 2016-07-08T17:02:58.680
Is the bounty for a solution in MarioLANG? – wizzwizz4 – 2016-07-23T11:57:30.180
2In the falling example, you mention that "he cannot reach the
#
, because Mario falls straight down." If I'm viewing this correctly, wouldn't he fall straight down onto the#
? Also, are jumps defined as a maximum of 4 spaces up and maximum of 1 space right? – GuitarPicker – 2016-07-23T21:58:16.253Presumably in your very first picture of a layout, it would be feasible if there were another line of spaces first. – Joffan – 2016-07-23T22:51:34.030
Can Mario jump to the lower of two platforms that start at the same X? – Joffan – 2016-07-23T22:59:04.427
4@GuitarPicker I thought that at first aswell but if you look closely you can see there is another column of spaces before the column with the
#
. As to the second question: I'm not OP but I'm guessing you are right. (that's what I assumed in my solution) – KarlKastor – 2016-07-23T22:59:42.080After the bounty ends I may put one up for the first valid answer in MarioLANG. – NoOneIsHere – 2016-07-23T23:08:32.547
Thanks, @KarlKastor. That's exactly what I was missing. – GuitarPicker – 2016-07-24T02:57:28.907
Do you permit leading spaces in input. Can I require being provided with leading spaces? – Rohan Jhunjhunwala – 2016-07-25T17:05:37.703
Is it assumed that the intput is simply a long string with newline characters? Or can we take input as a list of row strings? – Taylor Lopez – 2016-07-25T18:45:58.603
1In the third example (demonstrating Mario's jump height),
E
does not appear in the right-most column because the ground level extends one to the right from the rest of the map. – Taylor Lopez – 2016-07-25T18:49:12.820Can we assume a (reasonable) formatting of input desirable for our answers? If not: array of strings or newline-delimited string? trailing new line or not? trailing spaces in every line, lines trimmed, undefined, or free choice? windows, macos, unix linebreaks, or free choice? – Titus – 2016-07-25T23:25:05.987
@Joffan: an extra blank line in the first example would make it solvable, because Mario could jump over the wall in the middle. – Titus – 2016-07-25T23:25:12.973
1@Joffan:
Mario cannot walk through wall , and cannot fall past a floor, or jump past a ceiling
– Titus – 2016-07-25T23:28:12.5801@Titus I'm thinking about Mario jumping into clear air and having a choice of different floors to land on - can he get to the lower one? – Joffan – 2016-07-25T23:41:48.913
1
@TùxCräftîñg We need some clarification over here. What do you think?
– betseg – 2016-07-25T23:47:23.9471
@TùxCräftîñg: another link discussing the same ambiguity in your specification betseg linked.
– KarlKastor – 2016-07-25T23:58:49.303Mario must jump up
n
, then walk right; not jump upn-1
then 1 up+1 right in the same move. correct? – Titus – 2016-07-26T00:58:46.030@Joffan: Yes, Mario can chose. – Titus – 2016-08-08T09:05:08.690