18
4
Yet another Jimmy challenge by his original father. See these other lovely challenges.
As you all know, recently we've been seeing challenges related to Jimmy on platforms. Now, Jimmy is an acrobat as I mentioned before, and he's got other tricks up his sleeve.
One of these tricks is hanging by ropes. Here's an example of a rope Jimmy could hang from:
||
||
||
||
||
||
When Jimmy hangs on a rope, it looks like this:
||
||
/o\
||
||
||
He can hang on the left or the right of the rope, so this:
||
||
||
/o\
||
||
is also valid. But he cannot hang by just one body part, so anything like this:
||
||
||
/o\|
||
||
is invalid. Note that when he is hanging by one body part the other half of the rope is visible because Jimmy does not cover it up.
Also, Jimmy does not like hanging on the bottom of the rope - it scares him - so this:
||
||
||
||
||
/o\
is invalid.
The challenge
Take input of a Jimmy situation like the ones above, and output whether Jimmy will hang on to the rope or not through a truthy or falsy value.
The specifics
Write a program that takes input. This can be through a function or any other appropriate input method.
- The input should be a scene of one Jimmy and a rope as exemplified above.
The program should output a truthy or falsy value to the console based on whether Jimmy can hang on to the rope or if he would fall off the rope, respectively.
The criteria for Jimmy being able to hang on the rope:
Two of his body parts are on the rope.
He is not on the bottom of the rope.
He is not floating in mid-air.
You can assume the rope will be straight, made up of
||
segments, and will be longer than one character in height.You can assume one whole rope and one singular Jimmy will be present in your scene, no more and no less.
You can assume there will be no trailing newlines at the bottom of the rope.
You must cover any amount of leading or trailing spaces before and after the rope.
Test cases
||
||
|| TRUTHY
/o\
||
||
||
||
/o\| FALSY
||
||
||
/o\ TRUTHY
||
||
/o\ FALSY
/o\
|| TRUTHY
||
||
/o\ || FALSY
||
||
Scoring
This is code-golf, so lowest score in bytes wins after about a week.
Leaderboard
You can view the leaderboard for this post by expanding the widget/snippet below. In order for your post to be included in the rankings, you need a header (# header text
) with the following info:
The name of the language (end it with a comma
,
or dash-
), followed by...The byte count, as the last number to appear in your header.
For example, JavaScript (ES6), 72 bytes
is valid, but Fortran, 143 bytes (8-bit)
is invalid because the byte count is not the last number in the header (your answer will be recognized as 8 bytes - don't take advantage of this).
<!-- Run the snippet to see the leaderboard. Report any bugs to @ozewski on Github. --> <iframe src="https://ozewski.github.io/ppcg-leaderboard/?id=187759" width="100%" height="100%" style="border:none;">Oops, your browser is too old to view this content! Please upgrade to a newer version of your browser that supports HTML5.</iframe><style>html,body{margin:0;padding:0;height:100%;overflow:hidden}</style>
1Is the rope always going to have the same number of spaces before it, or can that vary? – mprogrammer – 2019-07-06T15:53:44.247
@Maxwell That can vary. – connectyourcharger – 2019-07-06T15:58:32.823
Can we take the input as something like a list, where each line is a separate string, or does it have to be one single string? – mprogrammer – 2019-07-06T16:02:04.247
@Maxwell A list is fine. – connectyourcharger – 2019-07-06T16:03:07.603
19Jimmy should really take a holiday – Luis Mendo – 2019-07-06T16:20:25.407
7@LuisMendo Jimmy is dedicated to what he does! – connectyourcharger – 2019-07-06T16:25:06.263
"You can assume there will be no trailing newlines at the bottom of the rope." Can we assume that there will be exactly one? – Doorknob – 2019-07-07T04:46:51.723
@Doorknob Yeah, I really meant extra lines past the bottom of the rope when I said that. – connectyourcharger – 2019-07-07T09:07:11.673
Is there an implicit rule that prevents the input jimmy+blank line(s)+rope? – Ben Jackson – 2019-07-07T20:56:09.843
Taking a page right of of your book here @connectyourcharger, Jimmy's not happy with you.
– Quinn – 2019-07-08T13:17:52.530