# Backstory

Meet my friend Jimmy:

/o\


Jimmy is a little character who likes to stand on platforms. Here's Jimmy safely standing on a platform:

         /o\
-------------


Now, Jimmy has a good sense of balance, so he can safely stand with one leg off of the platform, like so:

   /o\
-------------------


Although if he stands with two or more body parts off of the platform, he will fall. Both of these are examples where Jimmy will fall:

/o\                                       /o\
----------        ----------------------


# The challenge

Your challenge is to write a program to determine, given a string with Jimmy's platform and position, if Jimmy can stand on the platform without falling off.

• Input: Two lines showing Jimmy's position and the position of the platform under him. This can be from two separate inputs, a single input, or an array of some sort.
1. You may take input through any reasonable form, includings functions and standard input. Only resort to hard-coding if your language does not support the other input methods.
• Output: The boolean values true and false, or the integers 1 or 0 to represent true/false respectively.
1. The boolean value is based off of whether Jimmy can stay on the platform or not - true if Jimmy can stay on the platform, or false if he will fall off.
• The platform size is arbitrary and can be changed at will. Your program should account for that.
1. The platform cannot be a length of zero, and the platform must be complete (no holes in the platform).

2. Remember that Jimmy falls off when two of his body parts are hanging off the platform. A body part is one ASCII character of his body.

3. Trailing whitespace at the end of the platform is not required, but your program should account for both situations, where there is whitespace after the platform and where there is not.

# Test cases

         /o\               ✔️ TRUE
-------------

/o\                        ✔️ TRUE
----------

/o\    ❌ FALSE
------------------

/o\         ❌ FALSE
-------

/o\                    ❌ FALSE
-


# Scoring

This is , so lowest byte count wins.

# 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=187586" 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>

• Can we assume trailing whitespace after Jimmy? Also if you’re allowing arrays of characters, in some languages those will have to be padded with whitespace. – Nick Kennedy Jul 2 '19 at 23:07
• @NickKennedy You need to account for trailing whitespace or no trailing whitespace. I didn't set strict rules on that. – connectyourcharger Jul 2 '19 at 23:09
• Title is "will jimmy fall of the platform" and you required to output "will jimmy stay on the platform". Is this expected behavior? – tsh Jul 3 '19 at 3:29
• Can you reformat your test cases to make them easier to copy & paste, please? – Shaggy Jul 3 '19 at 6:53
• Is swapping truthy-falsy values allowed? (i.e. output true when Jimmy falls and false when that doesn't happen?) – Mr. Xcoder Jul 3 '19 at 9:48

# Python 3.7, 71 56 Bytes

lambda s:sum(j in'/o\\'and p=='-'for j,p in zip(*s))>1


Very simple version and the shortest I could think of using this approach. Input s is a list of two strings, the first one for the Jimmy-row, the second one for the platform. Zip the characters which are above one another and then check whether - is below a part of Jimmy in at least two instances.

EDIT: Reduced by quite a few Bytes thanks to Blue!

• Hi, welcome to Code Golf! Couple things: you might want to specify the input format in your answer (looks like s should be two lists, one for jimmy and one for the platform?). Also, there are a few places you can save bytes: instead of summing a list, you can sum the raw iterator (remove the brackets); instead of checking >=2, check >1; you can sum True and False like 1 and 0, no need for the if-else. Finally, before posting a new answer in the same language, you should look at the previous ones to see if you can improve. – Blue Aug 6 '19 at 21:30
• @Blue Hi, thanks a lot! And yeah I will keep that in mind in the future. :) – Michael Aug 9 '19 at 16:57

# C (gcc), 103 bytes

i,j,l;f(char*s){for(i=0;*s-10;j=*s++-47?j:i)++i;l=strlen(s)>j+1;s+=j;return l&&*s+s[1]+(s[2]?:32)>109;}


Try it online!

Would be much shorter (75 bytes), if it could be assumed that there is trailing whitespace after the platform.

# Japt -¡, 9 bytes

-1 byte if the input can be reversed.

VtUao)è-²


Try it online

• @SriotchilismO'Zaic Updated – Oliver Jul 3 '19 at 3:02

# V, 18 bytes

0vt/"_dj.d3lVkp0#x


Try it online!

Output whitespace only if jimmy fall of the platform. Output something non-whitespace if jimmy stay on the platform.

• Not using Ctrl or Esc in Vim is funny. – tsh Jul 3 '19 at 6:07

# Japt-!, 7 bytes

ÕèSi.)z


Try it

ÕèSi.)z     :Implicit input of multi-line string
Õ           :Transpose
è          :Count the occurrences of
S         :  Space
i.       :  Prepended with ".", giving the regex /. /g
)      :End count
z     :Floor divide by 2
:Implicit output as Boolean


# Pyth, 9 bytes

!!tt#rL6C


Try it here! (Note: This is a temporary interpreter, hosted on pythtemp.herokuapp.com; the official pyth.herokuapp.com can't be used for now)

If swapping truthy-falsy values were allowed, this would become 8 bytes by dropping one of the !s (awaiting confirmation). Moreover, if outputting an empty list for the case when Jimmy falls and a non-empty list otherwise would be an option, both !s could be dropped.

### How it works

!!tt#rL6C – Full program. Receives a list of two strings through STDIN.
C – Transpose / Zip (switch from rows to columns)
rL6  – Strip the whitespace on both sides of each column.
t#     – Filter-keep those that have a tail (i.e. that are length-2).
t       – Tail. The result will be non-empty iff Jimmy doesn't fall.
!!        – Double negation (to output as a boolean...).


# Retina, 31 29 bytes

^(.)*/.*¶(?<-1>.)*(?(1)!) ?--


Try it online!

Saved 2 bytes thanks to Neil!

A simple regex that determines whether at least two pieces of the platform are directly beneath Jimmy. Assumes that the input will contain no ! characters.

• I don't think you need the trailing -?. – Neil Jul 3 '19 at 10:30
• @Neil Quite right, I don't know what case I thought I was covering with that. – FryAmTheEggman Jul 3 '19 at 15:50

# Attache, 38 bytes

{2>Sum!~&Sum[Ord@Grid@_-39]=>1'46'65}


Try it online!

## Explanation

We convert the input string to a grid of ASCII codepoints, subtract 39 from each, then take the Sum, columnwise. (Sum[Ord@Grid@_-32]). Then, we bind this array to the ~ operator, which in this case counts the number of times the argument occurs in the bound array. We apply this function to each member of the array 1'46'65 with =>, which correspond to various body parts not above a platform. We then take the sum of this resulting array with Sum!. This is the count of body parts not above the platform. Finally, we check to see that 2 exceeds this sum; if it does, then we return false, for Jimmy has fallen. If it does not, we return true, for Jimmy is quite safe on his perch.

# 40 column Commodore BASIC (C64, C16/+4, C128, PET, C64Mini) - non-competing* - 98 tokenized and BASIC bytes used

 0a=rN(.)*36:b=rN(.)*39:c=-rN(.)*(b-39):fOi=0tob:a$=a$+"-":nE:?tAa)"/o\
1?tAc)a$:?-(a>c-2anda<c+b+2)  Here is the unobfuscated listing for explanation purposes  0 let a=rnd(0) * 36 1 let b=rnd(0) * 39 2 let c=-rnd(0) * (b - 39) 3 for i=0 to b 4 let a$=a$+"-" 5 next i 6 print tab(a);"/o\" 7 print tab(c);a$
8 print -(a>c - 2 and a<c + b + 2)


The variable a is used for positioning Jimmy (using PRINT TAB(A) which is zero-indexed).

The varaible b is used for the length of the platform.

And finally the variable c is used for the position of the platform.

The loop in lines 3 through to 5 inclusive builds the platform for Jimmy, with line 6 printing Jimmy at his pre-determined position, and 7 for the pre-determined position of the platform. Finally, 1 or 0 is outputted to represent our TRUE or FALSE value.

Note, the listing includes keyword abbreviations to ensure we break the 80 character limit per line on standard Commodore C64 BASIC.

* Assumed non-competing because PETSCII is not ASCII. Jimmy looks better in PETSCII though, of course.

# Charcoal, 19 bytes

η⸿Ｐθ…θ⌕θo≔№ＫＭ-ζ⎚›ζ¹


Try it online! Link is to verbose version of code. Outputs - if the Jimmy will balance, nothing if he will fall off. Explanation:

η


Print the platform.

⸿


Move down a line. (Reversed gravity turned out to be golfier.)

Ｐθ


Print Jimmy without moving the cursor.

…θ⌕θo


Print Jimmy's leg leaving the cursor over his body.

≔№ＫＭ-ζ


Count the number of adjacent -s from the platform.

⎚


Clear the canvas.

›ζ¹


Output a - if the platform was large enough.

• The challenge asks for boolean output rather than the two distinct value sort of output that tends to be common. – Wheat Wizard Jul 6 '19 at 2:03
• @SriotchilismO'Zaic That's just the default output of a boolean expression in Charcoal. – Neil Jul 6 '19 at 9:36

# Brain-Flak, 210 bytes

{({}<>)<>}<>{({}[(()()()()()){}]<>)<>}<>({<(<({}[((()()()()()){}()){}])>{()(<{}>)}{}<{({}<>)<>}{}({}[((((()()()()()))){}{}){}{}])>[()()]{()(<{}>)}<<>{({}<>)<>}<>>)>[()]{()(<{}>)}{}}<>)(()[{<({}())>{()<{}>}}]{})


Try it online!

String parsing is hard in Brain-Flak. It considers anything on the first line other than space to be Jimmy and anything on the second line other than - to be open air. The reason we test for - instead of space is that Brain-Flak pads the input indefinitely to the right with nulls (ASCII codepoint 0) which we need to consider open air. This luckily means we don't have to worry about needing trailing whitespace in the input.

# Elm 0.19, 99 bytes

f j p=List.sum(List.map2(\a b->if a/=' '&&b/=' 'then 1 else 0)(String.toList j)(String.toList p))>1


Port of Maxwell's Python 3 answer. Verify all test cases here.

# PHP, 90 80 bytes

Code

<?=substr_count(substr(($v=explode(" ",$argv[1]))[1],strpos($v[0],"/"),3),"--");  Try it online! Mistakenly coded allowwing jimmy with just a leg on the edge <?=count($v=explode("
",$argv[1]))>1&&substr_count(substr($v[1],strpos($v[0],"/"),3),"-");  Explanation <?= substr_count( substr(($v=explode("\n",$argv[1]))[1],// explode and get Jimmy body strpos($v[0],"/"),  // find "/" position (position start)
3),                 // substring of the platform length
"--");              // platform has to contain "--" somewhere
//
//

• The puzzle states that the input is two lines, and the second one is not empty, so you can remove that check – Einacio Jul 8 '19 at 11:05
• I tested the code on the TIO, and it fails with two spaces before the platform, or if jimmy is only with it's left leg (test case 3). it also fails the last test case – Einacio Jul 8 '19 at 11:09
• Thank you @Einacio, i mistakenly coded allowing jimmy to have 1 leg and nothing else on the platform, also ty for the advice on removing the condition for 2 lines as input. – Francisco Hahn Jul 8 '19 at 14:17

## Pip, 29 bytes

sN(STbALsRL#a)@>(a@?"/")@<3<2


The padding with spaces part took a while to figure out.

The second argument must have atleast one space before it, otherwise the program will error. Add a space to the first argument as well for testing.

### Explanation:

sN(STbALsRL#a)@>(a@?"/")@<3>1
(STbALsRL#a)                pad second line with spaces, convert to a simple string
(a@?"/")      Find index of jimmy's right hand in first line
@>              Get substring of second line after index taken in prev step
@<3   cut it to the three planks under Jimmy
sN                            Find number of spaces in substring i.e.
"---" => 0, " - " => 2
<2 find out if Jimmy is standing on thin air(hopefully not)
`

Try it online!