Will Jimmy fall off his platform?
Jelly, 6 bytes
n⁶Sċ2Ẓ
Try it online!
Explanation:
n⁶Sċ2Ẓ args: z (e.g. [['/', 'o', '\\'], [' ', '-']] => 0)
implicit return value: z ([['/', 'o', '\\'], [' ', '-']])
n⁶ dyad-nilad pair ([[1, 1, 1], [0, 1]])
⁶ 4th command-line argument or space [4th CLA assumed absent] (' ')
n vectorized inequality ([[1, 1, 1], [0, 1]])
S reduction by addition with base case 0 ([1, 2, 1])
ċ2 dyad-nilad pair (1)
2 literal (2)
ċ number of occurrences of right in left (1)
Ẓ primality (0)
JavaScript (ES6), 38 bytes
Takes input as (a)(b)
. Returns \$0\$ or \$1\$.
a=>b=>b[a.search`o`]=='-'&/--/.test(b)
Try it online!
How?
We look for the position of the middle part "o"
of Jimmy's body in the first string and test wether there's a dash in the second string at the same position.
b[a.search`o`] == '-'
The only case where Jimmy would be unsafe in this situation is with a single-dash platform:
/o\
-
So we additionally make sure that the platform has a width of at least \$2\$:
/--/.test(b)
JavaScript (ES6), 36 bytes
Alternate version if we assume that there's always either dashes or spaces below Jimmy (i.e. the input is rectangular).
a=>b=>b[a.search`o`]!=0&/--/.test(b)
Try it online!
Takes advantage of the fact that the coercion to a numeric value is \$0\$ for a space and NaN for a dash.
Excel, 67 45 44 bytes
=(MID(A2,FIND("o",A1),1)="-")*(TRIM(A2)>"-")
Put Jimmy in A1
, on a platform in A2
.
2 conditions checked:
- Is Jimmy's torso (
o
) on the platform? - Is the platform more than just
-
?