29
\$\begingroup\$

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.

  • Be mindful of the standard loopholes that are forbidden.

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 @xMikee1 on Github -->    <iframe src="https://xmikee1.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>

\$\endgroup\$
  • \$\begingroup\$ 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. \$\endgroup\$ – Nick Kennedy Jul 2 at 23:07
  • \$\begingroup\$ @NickKennedy You need to account for trailing whitespace or no trailing whitespace. I didn't set strict rules on that. \$\endgroup\$ – connectyourcharger Jul 2 at 23:09
  • 12
    \$\begingroup\$ Title is "will jimmy fall of the platform" and you required to output "will jimmy stay on the platform". Is this expected behavior? \$\endgroup\$ – tsh Jul 3 at 3:29
  • 6
    \$\begingroup\$ Can you reformat your test cases to make them easier to copy & paste, please? \$\endgroup\$ – Shaggy Jul 3 at 6:53
  • 2
    \$\begingroup\$ Is swapping truthy-falsy values allowed? (i.e. output true when Jimmy falls and false when that doesn't happen?) \$\endgroup\$ – Mr. Xcoder Jul 3 at 9:48

41 Answers 41

20
\$\begingroup\$

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)
\$\endgroup\$
  • 26
    \$\begingroup\$ Sometimes I wonder how far humankind has advanced to see that in 6 bytes you can check if someone is going to fall off of a platform to their doom. \$\endgroup\$ – IMustBeSomeone Jul 3 at 1:36
  • 4
    \$\begingroup\$ @IMustBeSomeone, if I'm going to fall off a platform to my doom, I'd want someone to be quick in telling me! \$\endgroup\$ – Shaggy Jul 3 at 7:02
  • 18
    \$\begingroup\$ @Shaggy I always thought it was funny when people made challenges with an introduction: "Because we don't want to spend too much time on X, the code has to be as short as possible.", even though code-golf and performance are in most cases opposites. If we can save a byte going from \$O(\log(n))\$ to \$O(n^n)\$, who cares about performance, we got a byte off! ;p \$\endgroup\$ – Kevin Cruijssen Jul 3 at 7:10
  • 1
    \$\begingroup\$ I don't know Jelly, but why does the S sum the columns instead of the rows? :S If I looked at the wiki correctly the code does: n⁶ check for each character that it's not equal to a space (i.e. ['/o\\', ' -'] -> [[1,1,1],[0,1]]); S sum list (but for some reason this sums columns instead of rows.. so [[1,1,1],[0,1]] -> [1,2,1]); ċ2 count the amount of 2s; check if this is a prime (so 2 or 3), after the result is output implicitly. But I would have expected [[1,1,1],[0,1]] to sum to [3,1].. \$\endgroup\$ – Kevin Cruijssen Jul 3 at 7:42
  • 1
    \$\begingroup\$ @KevinCruijssen S is equivalent to 0;+/Ɗ, that is, reduce by addition (which vectorizes) with initial value 0. § does what you expected S to do. \$\endgroup\$ – Erik the Outgolfer Jul 3 at 8:08
19
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ Wow. Could you explain how that works? \$\endgroup\$ – connectyourcharger Jul 2 at 23:01
  • \$\begingroup\$ @connectyourcharger I've added an explanation. \$\endgroup\$ – Arnauld Jul 2 at 23:10
  • 3
    \$\begingroup\$ Genius! JS answers usually aren't that short. \$\endgroup\$ – connectyourcharger Jul 2 at 23:12
  • \$\begingroup\$ Would this work for 35 bytes? \$\endgroup\$ – Oliver Jul 3 at 2:13
  • \$\begingroup\$ @Oliver will fail for "/o\\\n__" \$\endgroup\$ – tsh Jul 3 at 3:43
10
\$\begingroup\$

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 -?
\$\endgroup\$
  • 1
    \$\begingroup\$ @Keeta Edits within the first five minutes aren't shown in the edit history. \$\endgroup\$ – Nic Hartley Jul 3 at 16:27
  • \$\begingroup\$ From the limited testing I did, I think that you can change <> to > \$\endgroup\$ – Taylor Scott Jul 19 at 17:54
9
\$\begingroup\$

Python 3, 88 43 bytes

Input is given in the form of a list containing two strings: the first string is the first line; the second string is the second line.

lambda a:sum(1-(" "in i)for i in zip(*a))>1

Try it online!

Another version, tying for 43 bytes (I haven't been able to get it shorter than 43):

lambda a,b:b[a.find("/"):][:3].count("-")>1

Try it online!

Down by 42 bytes thanks to a tip from Jo King.

Old Version:

lambda s:sum((s.split("\n")[1]+" "*len(s))[i]=="-"and s[i]!=" "for i in range(len(s)))>1

-2 bytes thanks to Sriotchilism O'Zaic.

This works by taking two separate inputs, then pairing up corresponding letters. It counts the number of pairs where neither character is a space, then returns True if that number is greater than 1.

\$\endgroup\$
8
\$\begingroup\$

Perl 6, 18 bytes

{?/''B|Bq/}o&[~^]

Try it online!

Takes a two parameters and returns a boolean of whether Jimmy will stay on the platform. This works by XORing the two lines together and checking if either part of Jimmy is still on the platform.

Explanation:

             &[~^]   # String XOR operator
{          }o        # Combined with the anonymous function
 ?/       /          # That checks for the regex match
   ''B              # Unprintable, B, which is "/o" ~^ "--"
       |Bq           # Or B, q, which is "o\" ~^ "--"
\$\endgroup\$
8
\$\begingroup\$

Python 2, 42 37 bytes

lambda j,p:'--'in p[j.find('/'):][:3]

Try it online!

5 bytes thx to negative seven

\$\endgroup\$
  • 1
    \$\begingroup\$ "--"in [...] for -5 bytes \$\endgroup\$ – negative seven Jul 3 at 5:57
  • \$\begingroup\$ @negative seven: nice; thanks! \$\endgroup\$ – Chas Brown Jul 3 at 6:00
6
\$\begingroup\$

Haskell, 34 bytes

a#b=[1|(p,'-')<-zip a b,p>' ']>[1]

Try it online!

I got this one by combining my below technique with the other haskell answer.

Haskell, 45 bytes

x#'-'|x/=' '=1
x#y=0
(((>1).sum).).zipWith(#)

Try it online!

This counts the number of body parts (non-space characters) that are on top of the platform and then checks it is greater than 1. The reason we count body parts on the platform rather than body parts off is that zipWith will chop the top line to be the length of the bottom and thus can chop off Jimmy's body parts. This prevents us from having to do something like cycle" " to pad the list.

\$\endgroup\$
  • 1
    \$\begingroup\$ Can't you reduce by 2 bytes by converting to infix? \$\endgroup\$ – cole Jul 3 at 2:49
  • 1
    \$\begingroup\$ @cole Yep I was just doing the edit when you commented :) \$\endgroup\$ – Wheat Wizard Jul 3 at 2:49
4
\$\begingroup\$

MathGolf, 6 14 bytes

`^@╞^αmÆû-oñ╧╙

Try it online!

8 bytes had to be added to account for the edge case presented by Nick Kennedy.

Checks if "-o-" is a substring of the zipped string of both lines, and the zipped string where the first input line has the first character removed. Takes input as two separate strings, with the only change being that the character is input as /o\\, since \\ is the correct way to input a backslash in a string in MathGolf.

Explanation

`                duplicate the top two items
 ^               zip top two elements on stack
  @              rrot3
   ╞             discard from left of string/array
    ^            zip top two elements on stack
     α           wrap last two elements in array
      mÆ         explicit map using 5 operators
        û-oñ     push "-o" and palindromize to make "-o-"
            ╧    pop a, b, a.contains(b)
                 map block ends here
             ╙   max of list
\$\endgroup\$
  • \$\begingroup\$ Oh, that's a better approach than my MathGolf answer.. After the interleave I split it into parts of size 2 again instead of directly checking for "-o-". \$\endgroup\$ – Kevin Cruijssen Jul 3 at 8:52
  • 1
    \$\begingroup\$ Fails for tio.run/##y00syUjPz0n7/z/u8G7d/MMbH01d/v@/un5@TIy6grqurvp/3RQA \$\endgroup\$ – Nick Kennedy Jul 3 at 10:31
  • \$\begingroup\$ @NickKennedy good catch! I'll see how I can fix the code, and update the post once it passes. It'll probably add a few bytes though, which is unfortunate. \$\endgroup\$ – maxb Jul 3 at 11:16
3
\$\begingroup\$

05AB1E (legacy), 9 8 7 bytes

ζðм2ùgp

-1 byte thanks to @Mr.Xcoder with the approach of ðм2ù.

Input as a list of two strings.

Only works in the legacy version of 05AB1E, because ζ can transpose a list of strings as well as a 2D list of characters, whereas the ζ in the new 05AB1E version only works with the 2D list of characters.

Try it online or verify all test cases.

Explanation:

ζ        # Zip/transpose; swapping rows/columns, with space as default filler
 ðм      # Remove all spaces from each string
   2ù    # Only leave strings of size 2
     g   # Count how many there are left
      p  # Check if this is a prime (2 or 3)
         # (after which the result is output implicitly)
\$\endgroup\$
  • 1
    \$\begingroup\$ Your title breaks the leaderboard, smh :) \$\endgroup\$ – connectyourcharger Jul 3 at 13:37
  • \$\begingroup\$ @connectyourcharger Ah, probably because I always link the bytes to the code-page so you know it isn't encoded in UTF-8 but uses a custom encoding instead. ;) If you want I can edit my answer to put the encoding below the title, but honestly the leaderboard code should be able to handle it imho. \$\endgroup\$ – Kevin Cruijssen Jul 3 at 13:44
  • \$\begingroup\$ I feel like I need to add a special case for 05AB1E - it is one of the only languages that has issues with the codepage. Fix incoming soon-ish. \$\endgroup\$ – connectyourcharger Jul 3 at 13:47
  • 1
    \$\begingroup\$ Struggling to come up with a modified regex. For now that will be a persisting bug. If you'd like to contribute here's the script: github.com/xMikee1/ppcg-leaderboard/edit/master/docs/script.js. I may have to refactor the bytes parsing entirely. \$\endgroup\$ – connectyourcharger Jul 3 at 14:12
  • \$\begingroup\$ Can't you modify the URL to https://github.com/Adriandmen/05AB1E/wiki/Codepage?7 to make 7 the last number without invalidating the URL? \$\endgroup\$ – L. F. Jul 18 at 3:26
3
\$\begingroup\$

Ruby, 28 bytes

->a,b{!(/--/!~b[a=~/\//,3])}

Try it online!

\$\endgroup\$
3
\$\begingroup\$

Dyalog APL Extended, 11 10 8 bytes

2≤1⊥∧⌿⍤<

Try it online!

Explanation:

2≤1⊥∧⌿⍤<  a monadic train
       <  Compare the input with the implicit prototype element - a space.
          Returns a boolean matrix of characters that are greater than 0x20
    ∧⌿⍤   and-reduce that, i.e. places where both Jimmy and a platform is
  1⊥      base 1 decode, aka sum - the amount of body parts over the platform
2≤        is that greater-or-equal to 2?

-2 thanks to Adám.

\$\endgroup\$
3
\$\begingroup\$

Excel, 36 bytes

=LEN(TRIM(MID(A2,FIND("/",A1),3)))>1

Jimmy in A1, on a platform in A2.

Finds the position of Jimmy, and takes the 3 bytes of the platform and trims off spaces. If the resulting platform length is long enough, Jimmy stands.

\$\endgroup\$
3
\$\begingroup\$

EXCEL, 94 71 bytes . VBA (Excel), 87 bytes

A1 = Jimmy , A2 = platform

-23 bytes. Thank you @Wernisch.

=(FIND("-",A2)-FIND("/",A1)<2)*(FIND("\",A1)-LEN(A2)<2)*(TRIM(A2)<>"-")

?[(FIND("-",A2)-FIND("/",A1)<2)*(FIND("\",A1)-LEN(A2)<2)]*(len(replace([A2]," ",""))>1)

\$\endgroup\$
  • 1
    \$\begingroup\$ Can't you use trim instead of len(replace? \$\endgroup\$ – Wernisch Jul 3 at 10:59
  • \$\begingroup\$ oh! that never sink in my head. haha Thanks @Wernisch :) \$\endgroup\$ – remoel Jul 4 at 6:19
3
\$\begingroup\$

///, 85 93 87 bytes

/~/\/\///\/o\\/(o)~ 
/
~
~/ (o) /(o)~ (o)-/(o)~- -/--~(o) - ~/) ~/)-~/o~/(-/1~-~/(~/)~ 

Try it online!

Output's a 1 if Jimmy is safe. Otherwise outputs nothing. (Unary 1 and 0.) Because there is no other way to take input in ///, it needs to be hard-coded:

/~/\/\///\/o\\/(o)~ 
/
~
~/ (o) /(o)~ (o)-/(o)~- -/--~(o) - ~/) ~/)-~/o~/(-/1~-~/(~/)~ //<INPUT HERE> 

For example:

/\/o\\/(o)// 
/
//
/// (o) /(o)// (o)-/(o)//- -/--//(o) - ///) ///)-///o///(-/1//-///(///)//         /o\
  ------------- 

(Try it online!)

Note the space after the <INPUT HERE>.

Explanation:

NOTE! The explanation code cannot be run due to the comments. The comments are enclosed in curly braces. Also, the original code uses a golf where // is replaced with ~. This code is omitted from the explanation.

/\/o\\/(o)/            {replace Jimmy with a Jimmy with curvy arms, because slashes are hard to manipulate in this language}
/ 
/
/                      {remove unneeded spaces after Jimmy, but before the floor}

/
//                     {get rid of the line break

/ (o) /(o)/            {remove all the spaces before both Jimmy and the floor}
/ (o)-/(o)/            {for each floor tile, remove it and one space before Jimmy. This detects whether Jimmy lines up with the floor.}
                       {If Jimmy is before the floor, then there will be extra floor.}
                       {If Jimmy is behind the floor, then there will be extra spaces before Jimmy.}
/- -/--/               {Handle the case where there is a hole beneath Jimmy but he is still well-supported}

/(o) - //              {Handle the case where only Jimmy's head is on the floor. The space at the end of the code is necessary for this.}
/) //                  {The rest of the substitutions clean up the result and handle each of the possible results that could exist at this point}
/)-//
/o//
/(-/1/
/-//
/(//
/)//


              /o\   
               --
 {there is a space right before this comment. The comment is only here to make the space visible and explain itself.}

  • +8 bytes to fix a bug
  • -6 bytes by applying a standard /// golf trick.
\$\endgroup\$
  • 1
    \$\begingroup\$ The source code looks like some strange emoji. \\(o)-(o)// \$\endgroup\$ – tsh Jul 4 at 3:52
2
\$\begingroup\$

R, 35 bytes

function(x)sum(colSums(x!=" ")>1)>1

Try it online!

Based on @EriktheOutgolfer’s excellent Jelly answer so please upvote that one too!

Input is a 2-d matrix of characters.

\$\endgroup\$
2
\$\begingroup\$

Haskell, 59 bytes

f a b=sum[1|(p,q)<-zip a$b++cycle" ",elem p"/o\\",q==' ']<2

Try it online!

The function is called like so: f "/o\\ " " -- "

How it works (for f "/o\\" " -"):

b++cycle" " - Adds an infinite number of spaces after b to ensure that Jimmy is always above a - or (" -"" - ..."

zip a$b++cycle" " - Zips the two strings together ([('/',' '), ('o','-'), ('\\',' ')])

(p,q)<-zip a$b++cycle - For each pair in the zipped list

[1|(p,q)<-zip a$b++cycle" ",elem p"/o\\",q==' '] - Generates a list of 1s, whose length is the number of pairs satisfying the conditions:

elem p"/o\\" - The character in the top string is one of Jimmy's body parts. (Satisfied by all three pairs in this example)

q==' ' - The character in the bottom string is a space. (Satisfied by ('/', ' ') and ('\\', ' '))

So, the pair has to be one where one of Jimmy's body parts is above a space.

Because in this example, two pairs satisfy both conditions, the list is [1,1]

sum[1|(p,q)<-zip a$b++cycle" ",elem p"/o\\",q==' '] - Take the sum of those 1s (i.e. the length of the list), which in this example is 2.

sum[1|(p,q)<-zip a$b++cycle" ",elem p"/o\\",q==' ']<2 - Check if the number of body parts above a space is less than 2. In this example, it's not, so Jimmy will fall off. :(

\$\endgroup\$
  • \$\begingroup\$ I just thought I would let you know that your answer helped me to shorten my own answer. So thanks! \$\endgroup\$ – Wheat Wizard Jul 3 at 2:51
2
\$\begingroup\$

C (gcc), 73 bytes

f(s,t,c)char*s,*t;{for(t=strchr(s,c=10);*s%5**t;)c-=*++t%2**s++%8;c=c<0;}

Try it online!

\$\endgroup\$
  • \$\begingroup\$ Suggest index() instead of strchr() \$\endgroup\$ – ceilingcat Jul 6 at 20:39
2
\$\begingroup\$

Kotlin, 60 bytes

fun String.c(b:String)=zip(b){i,j->i>' '&&j>' '}.count{it}>1

Explanation:

fun String.c  # Define an extension function on string, so we don't have to provide a first argument (and we also have string method calls for free)
(b:String)    # Pass the second string as argument
=             # Shorthand syntax for fun body
zip(b)        # Essentially a.zip(b). Creates a List<Pair> by joining both arrays. 
              # Takes care of trailing whitespace, because it will be the size of the smaller array
{i,j->        # Declare a transformer lambda as second function argument
i>' '&&j>' '} # This essentially translates to: If i!=' ' and j=='-'
.count{it}    # Count the true values
>1
\$\endgroup\$
  • \$\begingroup\$ Welcome to Code Golf! That's certainly a very nice first answer. \$\endgroup\$ – connectyourcharger Jul 5 at 17:02
2
\$\begingroup\$

///, 57 bytes

/|/\/\///\/o\\/J| J/J*|
/|* /|  -/  | /|*-/|--/!|-/|*/|J|

Try it online!

Append the input to the end of the program in order to run. Returns the empty string if Jimmy falls off the platform, a string of exclamation points otherwise.

  • /|/\/\// replaces | with //, which makes the code both shorter and more readable (| is used to demarcate each replacement)
  • /\/o\\/J| J/J*/ replaces Jimmy with J for brevity and changes the space to the left of him to * to the right of him
  • The next replacement gets rid of newlines.
  • /* /| -/ | // cancels out *s and with the space to the left of the platform. If there are two or more spaces left, Jimmy is falling off to the left, and the platform is deleted. This part also removes any whitespace to the right of the platform.
  • /*-/|--/!/ cancels out *s and with length of the platform. If there are at least two - left, Jimmy isn't falling off to the right, so they are replaced with a !.
  • /-/|*/|J// deletes every remaining character that isn't !
\$\endgroup\$
1
\$\begingroup\$

Japt, 8 bytes

Õ·kèS Êz

Try it

\$\endgroup\$
  • \$\begingroup\$ Sorry, didn't see this before posting mine last night :\ \$\endgroup\$ – Shaggy Jul 3 at 17:00
1
\$\begingroup\$

Retina 0.8.2, 16 bytes

 (.*¶).
$1
¶ ?--

Try it online! Link includes test suite. Explanation:

+`^ (.*¶).
$1

While there is still a space on the first line, and both lines still have more than one character, delete the space and the first character of the next line. Note: This assumes that there is no trailing space after Jimmy. +1 byte needed if trailing space needs to be allowed.

¶ ?--

Check that there are at least two pieces of platform under Jimmy.

\$\endgroup\$
1
\$\begingroup\$

Perl 5 -pl, 42 bytes

/o/g;$_=(($_=<>)=~/./g)[-1+pos]eq'-'&&/--/

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Ruby 2.5.3, 44 bytes

->a,b{a.zip(b).map(&:join).grep(/\S-/).size>1}

Input taken as two arrays. Definitely not the most golf-friendly approach (see G B's answer), but I like any excuse to use the zip function.

\$\endgroup\$
1
\$\begingroup\$

PowerShell, 63..55 53 bytes

-1 byte thanks to mazzy

param($j,$f)''+($f|% t*y|?{$j[$i++]-gt32})-match'- -'

Try it online!

Takes input as two lines.

Unrolled:

param($j,$f)            #Take $jimmy and $floor
''+                     #Implicitly converts next part to string
($f |% ToCharArray      #Convert $f to a char[] and...
    |?{                 #Only take the chars where...
        $j[$i++]-gt32   #The same indexed char in $j's ASCII # is > ' ' i.e. only get /o\
     }
)-match'- -'            #Arrays.ToString are joined with a space and we need 2 -'s
\$\endgroup\$
  • \$\begingroup\$ Huh. I never considered PowerShell a great golfing language, but I guess it's actually not that bad. \$\endgroup\$ – connectyourcharger Jul 3 at 17:39
  • \$\begingroup\$ @connectyourcharger It can do some pretty neat stuff with the pipeline but there's definitely a few areas where it's a huge pain in the ass. \$\endgroup\$ – Veskah Jul 3 at 17:43
  • \$\begingroup\$ I never bothered to learn it because of those pain-in-the-ass reasons. \$\endgroup\$ – connectyourcharger Jul 3 at 17:45
  • 1
    \$\begingroup\$ nice! step back and save one more :) \$\endgroup\$ – mazzy Jul 3 at 23:32
1
\$\begingroup\$

C# (Visual C# Interactive Compiler), 44 40 39 bytes

-4 bytes thanks to Jo King

a=>b=>a.Zip(b,(x,y)=>x>y?y:0).Sum()>109

Try it online!

\$\endgroup\$
  • \$\begingroup\$ 40 bytes that works \$\endgroup\$ – Jo King Jul 4 at 3:01
  • \$\begingroup\$ Does not quite work; tio.run/##Sy7WTS7O/… \$\endgroup\$ – CharlesS Jul 5 at 17:14
  • \$\begingroup\$ @CharlesS I believe I fixed it and saved a byte in the process \$\endgroup\$ – Expired Data Jul 5 at 17:25
  • \$\begingroup\$ @ExpiredData yep, nice! \$\endgroup\$ – CharlesS Jul 5 at 21:45
1
\$\begingroup\$

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!

\$\endgroup\$
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – Blue Aug 6 at 21:30
  • \$\begingroup\$ @Blue Hi, thanks a lot! And yeah I will keep that in mind in the future. :) \$\endgroup\$ – Michael Aug 9 at 16:57
1
\$\begingroup\$

Chevron, 84 87 bytes

>^__>^j
^i<<0
^i<<^i+1
^h<^i>^j
->+2??^h=/
->-3
>^__>^p
^q<^i|2>^p
->+2??^q<--
><0
><1

This is a fairly new language of my own creation - prototype interpreter, documentation, and example programs can be found at https://github.com/superloach/chevron.

Explanation:

  • >^__>^j - take jimmy as TXT input
  • ^i<<0 - initialise index to 0
  • ^i<<^i+1 - increment index
  • ^h<^i>^j - get character of jimmy at index
  • ->+2??^h=/ - jump out of loop at jimmy's left leg
  • ->-3 - hop back to beginning of loop
  • >^__>^p - take platform as TXT input
  • ^q<^i|2>^p - cut out 3 characters under jimmy
  • ->+2??^q<-- - if 2 dashes under jimmy, jump to truthy exit
  • ><0 - falsy exit
  • ><1 - truthy exit
\$\endgroup\$
  • \$\begingroup\$ I am aware that my code fails to handle single-character platform cases - updated version will be edited soon. \$\endgroup\$ – Superloach Jul 29 at 19:58
0
\$\begingroup\$

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.

\$\endgroup\$
0
\$\begingroup\$

Japt , 9 bytes

-1 byte if the input can be reversed.

VtUao)è-²

Try it online

\$\endgroup\$
  • 1
    \$\begingroup\$ @SriotchilismO'Zaic Updated \$\endgroup\$ – Oliver Jul 3 at 3:02
0
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ Not using Ctrl or Esc in Vim is funny. \$\endgroup\$ – tsh Jul 3 at 6:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.