Skip to main content
5 of 5
Commonmark migration

Japt, 22 bytes

Japt is a shortened version of JavaScript. Interpreter

U¬r@X+~~Y*(Z-Ub'^),0 g 

Returns -1 for L, 0 for B, and 1 for R.

How it works

Uq r@X+~~Y*(Z-Ub'^),0 g // Implicit: U = input string Uq r@ ,0 // Reduce the input by this function, starting at 0: X+~~Y* // Return the previous value, plus the current value times (Z-Ub'^) // the current index minus the index of "^" in U. g // Take the sign of the resulting number. // Implicit: output last expression 
ETHproductions
  • 50.3k
  • 6
  • 96
  • 241