Skip to main content
Commonmark migration
Source Link

#05AB1E, 14 12 11 bytes

05AB1E, 14 12 11 bytes

Îvy'^QDŠ‹+<

Port of @Sp3000's Gol><> answer.

NOTE: @Grimy already posted a shorter 8 bytes alternative for 05AB1E, so make sure to upvote him!

Try it online or verify all test cases.

Explanation:

Î            # Push 0 (later mentioned as `r`) and the input-string
 v           # Loop over the characters of the input:
  y'^Q      '#  Does the current character equal "^"?
             #  (results in 1 for truthy; 0 for falsey - later mentioned as `b`)
      D      #  Duplicate this result `b`
       Š     #  Triple swap (`r`,`b`,`b`) to (`b`,`r`,`b`)
        ‹    #  Check if the boolean `b` is smaller than the result-integer `r`
             #  (again results in 1 for truthy; 0 for falsey)
         +   #  Add them together
          <  #  Decrease this by 1
             # (Implicitly output the result-integer `r` after the loop)

#05AB1E, 14 12 11 bytes

Îvy'^QDŠ‹+<

Port of @Sp3000's Gol><> answer.

NOTE: @Grimy already posted a shorter 8 bytes alternative for 05AB1E, so make sure to upvote him!

Try it online or verify all test cases.

Explanation:

Î            # Push 0 (later mentioned as `r`) and the input-string
 v           # Loop over the characters of the input:
  y'^Q      '#  Does the current character equal "^"?
             #  (results in 1 for truthy; 0 for falsey - later mentioned as `b`)
      D      #  Duplicate this result `b`
       Š     #  Triple swap (`r`,`b`,`b`) to (`b`,`r`,`b`)
        ‹    #  Check if the boolean `b` is smaller than the result-integer `r`
             #  (again results in 1 for truthy; 0 for falsey)
         +   #  Add them together
          <  #  Decrease this by 1
             # (Implicitly output the result-integer `r` after the loop)

05AB1E, 14 12 11 bytes

Îvy'^QDŠ‹+<

Port of @Sp3000's Gol><> answer.

NOTE: @Grimy already posted a shorter 8 bytes alternative for 05AB1E, so make sure to upvote him!

Try it online or verify all test cases.

Explanation:

Î            # Push 0 (later mentioned as `r`) and the input-string
 v           # Loop over the characters of the input:
  y'^Q      '#  Does the current character equal "^"?
             #  (results in 1 for truthy; 0 for falsey - later mentioned as `b`)
      D      #  Duplicate this result `b`
       Š     #  Triple swap (`r`,`b`,`b`) to (`b`,`r`,`b`)
        ‹    #  Check if the boolean `b` is smaller than the result-integer `r`
             #  (again results in 1 for truthy; 0 for falsey)
         +   #  Add them together
          <  #  Decrease this by 1
             # (Implicitly output the result-integer `r` after the loop)
added 214 characters in body
Source Link
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384

#05AB1E, 14 12 12 11 bytes

0svy'^QDŠ‹+<Îvy'^QDŠ‹+<

Try it online NOTE: @Grimy already posted a shorter 8 bytes alternative for 05AB1E, so make sure to upvote him!

Try it online or verify all test casesverify all test cases.

                # Implicitly take the input-list
0               # Result-integer `r`, starting at 0
 s              # Swap, so the input-list is at the top of the stack
  v             # Loop over the input-list:
   y'^Q         #  Does the current item equal "^"? (0 or 1 as result) (`a`)
       D        #  Duplicate this value `a`
        Š       #  Triple swap (`r`,`a`,`a`) to (`a`,`r`,`a`)
         ‹      #  Is the result-integer `r` larger than the value `a` (0 or 1 as result)
          +     #  Add them together
           <    #  Decrease this by 1
                # Implicitly output the result-integer `r` after the loop
Î            # Push 0 (later mentioned as `r`) and the input-string
 v           # Loop over the characters of the input:
  y'^Q      '#  Does the current character equal "^"?
             #  (results in 1 for truthy; 0 for falsey - later mentioned as `b`)
      D      #  Duplicate this result `b`
       Š     #  Triple swap (`r`,`b`,`b`) to (`b`,`r`,`b`)
        ‹    #  Check if the boolean `b` is smaller than the result-integer `r`
             #  (again results in 1 for truthy; 0 for falsey)
         +   #  Add them together
          <  #  Decrease this by 1
             # (Implicitly output the result-integer `r` after the loop)

#05AB1E, 14 12 bytes

0svy'^QDŠ‹+<

Try it online or verify all test cases.

                # Implicitly take the input-list
0               # Result-integer `r`, starting at 0
 s              # Swap, so the input-list is at the top of the stack
  v             # Loop over the input-list:
   y'^Q         #  Does the current item equal "^"? (0 or 1 as result) (`a`)
       D        #  Duplicate this value `a`
        Š       #  Triple swap (`r`,`a`,`a`) to (`a`,`r`,`a`)
         ‹      #  Is the result-integer `r` larger than the value `a` (0 or 1 as result)
          +     #  Add them together
           <    #  Decrease this by 1
                # Implicitly output the result-integer `r` after the loop

#05AB1E, 14 12 11 bytes

Îvy'^QDŠ‹+<

NOTE: @Grimy already posted a shorter 8 bytes alternative for 05AB1E, so make sure to upvote him!

Try it online or verify all test cases.

Î            # Push 0 (later mentioned as `r`) and the input-string
 v           # Loop over the characters of the input:
  y'^Q      '#  Does the current character equal "^"?
             #  (results in 1 for truthy; 0 for falsey - later mentioned as `b`)
      D      #  Duplicate this result `b`
       Š     #  Triple swap (`r`,`b`,`b`) to (`b`,`r`,`b`)
        ‹    #  Check if the boolean `b` is smaller than the result-integer `r`
             #  (again results in 1 for truthy; 0 for falsey)
         +   #  Add them together
          <  #  Decrease this by 1
             # (Implicitly output the result-integer `r` after the loop)
added 112 characters in body
Source Link
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384

#05AB1E, 1414 12 bytes

0©svy'^QD®›+<©0svy'^QDŠ‹+<

Port of @Sp3000's Gol><> answer.

Try it online or verify all test casesverify all test cases.

Explanation:

                # SaveImplicitly take the input-list
0 to the global variable (default is         # Result-1)
integer `r`, starting sat 0
 s              # Swap it, withso the input-list
  is at vthe top of the stack
  v             # Loop over the input-list:
    y'^Q          #  Does the current item equal "^"? (0 or 1 as result) (`a`)
        D         #  Duplicate this resultvalue `a`
        Š ®›      #  Triple swap (`r`,`a`,`a`) to (`a`,`r`,`a`)
            #  Is thisthe result-integer `r` larger than the globalvalue variable`a` (0 or 1 as result)
           +      #  Add the resultsthem together
            <     #  Decrease this by 1
             ©    #  AndImplicitly replaceoutput the global variableresult-integer with`r` thisafter iterationthe resultloop

#05AB1E, 14 bytes

0©svy'^QD®›+<©

Port of @Sp3000's Gol><> answer.

Try it online or verify all test cases.

Explanation:

                # Save 0 to the global variable (default is -1)
  s               # Swap it with the input-list
    v              # Loop over the input-list:
    y'^Q          #  Does the current item equal "^"? (0 or 1 as result) (`a`)
        D         #  Duplicate this result
         ®›       #  Is this result larger than the global variable (0 or 1 as result)
           +      #  Add the results together
            <     #  Decrease this by 1
             ©    #  And replace the global variable with this iteration result

#05AB1E, 14 12 bytes

0svy'^QDŠ‹+<

Port of @Sp3000's Gol><> answer.

Try it online or verify all test cases.

Explanation:

                # Implicitly take the input-list
0               # Result-integer `r`, starting at 0
 s              # Swap, so the input-list is at the top of the stack
  v             # Loop over the input-list:
   y'^Q         #  Does the current item equal "^"? (0 or 1 as result) (`a`)
       D        #  Duplicate this value `a`
        Š       #  Triple swap (`r`,`a`,`a`) to (`a`,`r`,`a`)
            #  Is the result-integer `r` larger than the value `a` (0 or 1 as result)
          +     #  Add them together
           <    #  Decrease this by 1
                # Implicitly output the result-integer `r` after the loop
Source Link
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384
Loading