Can Jimmy hang on his rope?

Python 2 or 3,  33  30 bytes

-3 thanks to Maxwell

lambda l:'o'in map(max,l[:-1])

An unnamed function accepting a list of lines

Try it online!


There needs to be a section of rope obscured by Jimmy that is not the bottom one.

lambda l:'o'in map(max,l[:-1])
lambda l:                      # a function taking l (the lines as strings)
                       l[:-1]  # strip off the last line
               map(max,      ) # maximum of each line (where '|'>'o'>'\'>'/'>' ')
         'o'in                 # was 'o' one of them? (hence Jimmy obscured all the rope)

Python 2, 28 bytes

lambda x:"o', '|"in`zip(*x)`

Try it online!

How does it work? It takes input as a list of strings, and zip joins the string. Jimmy stays on the rope if there is a "|" below an "o", so this code joins all the lines and checks if there is an "o" followed by a "|".

Annotated code:

lambda x: # Creates an anonymous function that takes one argument
  "o', '|" # If this substring is in the zip object, then Jimmy's "o" is above a "|"
    `    # Back quotes change the object into its string representation
    zip(*x)` # Joins the lines together

(Old Answer) Python 2 or 3, 39 bytes

lambda x:1-all("|"in i for i in x[:-1])

A function that takes input as a list of strings, each string being a different line.

-11 bytes thanks to xnor! -2 bytes thanks to Jonathan Allan!

Try it online! (If you want to try more test cases, just put a "." after each set of lines in the input box.)

How does this work? Well, if Jimmy is fully on the rope, then that line will not have any "|" characters. Therefore, we can check each line, and if we find any with no "|" characters, then we know that Jimmy can stay on the rope. However, Jimmy can not hang on to the bottom of the rope; therefore, we don't include the final line in our check. If the final line is just another part of the rope, than it won't matter, because we'll still find a valid row higher up, but if the final line is the one with Jimmy, then it won't find a line without "|" anywhere, and will return False.

Japt, 5 bytes

I think this is right; I've been working for 16 hours straight and barely know my own name so I wouldn't be surprised if it's not!


Try it

Õø|io     :Implicit input
Õ         :Transpose
 ø        :Contains?
  |io     :  "|" prepended with "o"