Skip to main content
deleted 158 characters in body
Source Link
Qwertiy
  • 3k
  • 1
  • 12
  • 31
"` -> 0\r\n\0
^^ -> 0\r\n\0
^v -> -1\r\n\1
^ -> 1\r\n\1
v -> -1\r\n\1
v^ -> 1\r\n\1
vv -> 0\r\n\0
^^^ -> 1\r\n\1
vvv -> -1\r\n\1
^^^^ -> 0\r\n\0
vvvv -> 0\r\n\0
^^^^^ -> 1\r\n\1
vvvvv -> -1\r\n\1
^^^^^^ -> 0\r\n\0
vvvvvv -> 0\r\n\0
^^v -> -1\r\n\1
^v^ -> 1\r\n\1
^vv -> 0\r\n\0
vv^ -> 1\r\n\1
v^v -> -1\r\n\1
v^^ -> 0\r\n\0
^vvv^^vv^vv^v^ -> 1\r\n\1
^vvv^^vv^vv^v^^ -> 0\r\n\0
^vvv^^vv^vv^v^^^ -> 1\r\n\1
^vvv^^vv^vv^v^^v -> -1\r\n\1
^vvv^^vv^vv^v^^vv -> 0\r\n\0
^vvv^^vv^vv^v^^vvv -> -1\r\n\1
^vvvvvvvvvvvv -> 0\r\n\0
^^vvvvvvvvvvvv -> 0\r\n\0
^^^vvvvvvvvvvvv -> 0\r\n\0
vvv^^^^^^^^^^^^ -> 0\r\n\0
vv^^^^^^^^^^^^ -> 0\r\n\0
v^^^^^^^^^^^^ -> 0"0`
.split("\n").map(s => s.split(" -> "))
.every(([s,key]) => (s=>~~{'^':1,v:-1}[s.replace(/(.)\1/g).slice(-1)])(s)==key)
" -> 0\r\n\
^^ -> 0\r\n\
^v -> -1\r\n\
^ -> 1\r\n\
v -> -1\r\n\
v^ -> 1\r\n\
vv -> 0\r\n\
^^^ -> 1\r\n\
vvv -> -1\r\n\
^^^^ -> 0\r\n\
vvvv -> 0\r\n\
^^^^^ -> 1\r\n\
vvvvv -> -1\r\n\
^^^^^^ -> 0\r\n\
vvvvvv -> 0\r\n\
^^v -> -1\r\n\
^v^ -> 1\r\n\
^vv -> 0\r\n\
vv^ -> 1\r\n\
v^v -> -1\r\n\
v^^ -> 0\r\n\
^vvv^^vv^vv^v^ -> 1\r\n\
^vvv^^vv^vv^v^^ -> 0\r\n\
^vvv^^vv^vv^v^^^ -> 1\r\n\
^vvv^^vv^vv^v^^v -> -1\r\n\
^vvv^^vv^vv^v^^vv -> 0\r\n\
^vvv^^vv^vv^v^^vvv -> -1\r\n\
^vvvvvvvvvvvv -> 0\r\n\
^^vvvvvvvvvvvv -> 0\r\n\
^^^vvvvvvvvvvvv -> 0\r\n\
vvv^^^^^^^^^^^^ -> 0\r\n\
vv^^^^^^^^^^^^ -> 0\r\n\
v^^^^^^^^^^^^ -> 0"
.split("\n").map(s => s.split(" -> "))
.every(([s,key]) => (s=>~~{'^':1,v:-1}[s.replace(/(.)\1/g).slice(-1)])(s)==key)
` -> 0
^^ -> 0
^v -> -1
^ -> 1
v -> -1
v^ -> 1
vv -> 0
^^^ -> 1
vvv -> -1
^^^^ -> 0
vvvv -> 0
^^^^^ -> 1
vvvvv -> -1
^^^^^^ -> 0
vvvvvv -> 0
^^v -> -1
^v^ -> 1
^vv -> 0
vv^ -> 1
v^v -> -1
v^^ -> 0
^vvv^^vv^vv^v^ -> 1
^vvv^^vv^vv^v^^ -> 0
^vvv^^vv^vv^v^^^ -> 1
^vvv^^vv^vv^v^^v -> -1
^vvv^^vv^vv^v^^vv -> 0
^vvv^^vv^vv^v^^vvv -> -1
^vvvvvvvvvvvv -> 0
^^vvvvvvvvvvvv -> 0
^^^vvvvvvvvvvvv -> 0
vvv^^^^^^^^^^^^ -> 0
vv^^^^^^^^^^^^ -> 0
v^^^^^^^^^^^^ -> 0`
.split("\n").map(s => s.split(" -> "))
.every(([s,key]) => (s=>~~{'^':1,v:-1}[s.replace(/(.)\1/g).slice(-1)])(s)==key)
added 815 characters in body
Source Link
Qwertiy
  • 3k
  • 1
  • 12
  • 31

Explanation: undefined ends by d.

Test:

" -> 0\r\n\
^^ -> 0\r\n\
^v -> -1\r\n\
^ -> 1\r\n\
v -> -1\r\n\
v^ -> 1\r\n\
vv -> 0\r\n\
^^^ -> 1\r\n\
vvv -> -1\r\n\
^^^^ -> 0\r\n\
vvvv -> 0\r\n\
^^^^^ -> 1\r\n\
vvvvv -> -1\r\n\
^^^^^^ -> 0\r\n\
vvvvvv -> 0\r\n\
^^v -> -1\r\n\
^v^ -> 1\r\n\
^vv -> 0\r\n\
vv^ -> 1\r\n\
v^v -> -1\r\n\
v^^ -> 0\r\n\
^vvv^^vv^vv^v^ -> 1\r\n\
^vvv^^vv^vv^v^^ -> 0\r\n\
^vvv^^vv^vv^v^^^ -> 1\r\n\
^vvv^^vv^vv^v^^v -> -1\r\n\
^vvv^^vv^vv^v^^vv -> 0\r\n\
^vvv^^vv^vv^v^^vvv -> -1\r\n\
^vvvvvvvvvvvv -> 0\r\n\
^^vvvvvvvvvvvv -> 0\r\n\
^^^vvvvvvvvvvvv -> 0\r\n\
vvv^^^^^^^^^^^^ -> 0\r\n\
vv^^^^^^^^^^^^ -> 0\r\n\
v^^^^^^^^^^^^ -> 0"
.split("\n").map(s => s.split(" -> "))
.every(([s,key]) => (s=>~~{'^':1,v:-1}[s.replace(/(.)\1/g).slice(-1)])(s)==key)

Answer history:

s=>({'':0,'^':1,v:-1}[s.replace(/^(.)\1(\1\1)*(?=.?$)|.*(.)(((?!\3).)\5)+/,"").substr(-1)])
s=>~~{'^':1,v:-1}[s.replace(/^(.)\1(\1\1)*(?=.?$)|.*(.)(((?!\3).)\5)+/,"").substr(-1)]
s=>~~{'^':1,v:-1}[s.replace(/^.*(.)(((?!\1).)\3)+|(.)\4(\4\4)*/,"").substr(-1)]
s=>~~{'^':1,v:-1}[s.replace(/^.*(.)(((?!\1).)\3)+|(.)\4(\4\4)*/,"").slice(-1)]
s=>~~{'^':1,v:-1}[s.replace(/.*(.)(((?!\1).)\3)+|(.)\4(\4\4)*/,"").slice(-1)]
s=>~~{'^':1,v:-1}[s.replace(/.*(.)(((?!\1).)\3)+|((.)\5)*/,"").slice(-1)]
s=>~~{'^':1,v:-1}[s.replace(/((.)\2)+/g,"!").slice(-1)]
s=>~~{'^':1,v:-1}[s.replace(/(.)\1/g,"!").slice(-1)]
s=>~~{'^':1,v:-1}[s.replace(/(.)\1/g,0).slice(-1)]
s=>~~{'^':1,v:-1}[s.replace(/(.)\1/g).slice(-1)]

Test:

" -> 0\r\n\
^^ -> 0\r\n\
^v -> -1\r\n\
^ -> 1\r\n\
v -> -1\r\n\
v^ -> 1\r\n\
vv -> 0\r\n\
^^^ -> 1\r\n\
vvv -> -1\r\n\
^^^^ -> 0\r\n\
vvvv -> 0\r\n\
^^^^^ -> 1\r\n\
vvvvv -> -1\r\n\
^^^^^^ -> 0\r\n\
vvvvvv -> 0\r\n\
^^v -> -1\r\n\
^v^ -> 1\r\n\
^vv -> 0\r\n\
vv^ -> 1\r\n\
v^v -> -1\r\n\
v^^ -> 0\r\n\
^vvv^^vv^vv^v^ -> 1\r\n\
^vvv^^vv^vv^v^^ -> 0\r\n\
^vvv^^vv^vv^v^^^ -> 1\r\n\
^vvv^^vv^vv^v^^v -> -1\r\n\
^vvv^^vv^vv^v^^vv -> 0\r\n\
^vvv^^vv^vv^v^^vvv -> -1\r\n\
^vvvvvvvvvvvv -> 0\r\n\
^^vvvvvvvvvvvv -> 0\r\n\
^^^vvvvvvvvvvvv -> 0\r\n\
vvv^^^^^^^^^^^^ -> 0\r\n\
vv^^^^^^^^^^^^ -> 0\r\n\
v^^^^^^^^^^^^ -> 0"
.split("\n").map(s => s.split(" -> "))
.every(([s,key]) => (s=>~~{'^':1,v:-1}[s.replace(/(.)\1/g).slice(-1)])(s)==key)

Explanation: undefined ends by d.

Test:

" -> 0\r\n\
^^ -> 0\r\n\
^v -> -1\r\n\
^ -> 1\r\n\
v -> -1\r\n\
v^ -> 1\r\n\
vv -> 0\r\n\
^^^ -> 1\r\n\
vvv -> -1\r\n\
^^^^ -> 0\r\n\
vvvv -> 0\r\n\
^^^^^ -> 1\r\n\
vvvvv -> -1\r\n\
^^^^^^ -> 0\r\n\
vvvvvv -> 0\r\n\
^^v -> -1\r\n\
^v^ -> 1\r\n\
^vv -> 0\r\n\
vv^ -> 1\r\n\
v^v -> -1\r\n\
v^^ -> 0\r\n\
^vvv^^vv^vv^v^ -> 1\r\n\
^vvv^^vv^vv^v^^ -> 0\r\n\
^vvv^^vv^vv^v^^^ -> 1\r\n\
^vvv^^vv^vv^v^^v -> -1\r\n\
^vvv^^vv^vv^v^^vv -> 0\r\n\
^vvv^^vv^vv^v^^vvv -> -1\r\n\
^vvvvvvvvvvvv -> 0\r\n\
^^vvvvvvvvvvvv -> 0\r\n\
^^^vvvvvvvvvvvv -> 0\r\n\
vvv^^^^^^^^^^^^ -> 0\r\n\
vv^^^^^^^^^^^^ -> 0\r\n\
v^^^^^^^^^^^^ -> 0"
.split("\n").map(s => s.split(" -> "))
.every(([s,key]) => (s=>~~{'^':1,v:-1}[s.replace(/(.)\1/g).slice(-1)])(s)==key)

Answer history:

s=>({'':0,'^':1,v:-1}[s.replace(/^(.)\1(\1\1)*(?=.?$)|.*(.)(((?!\3).)\5)+/,"").substr(-1)])
s=>~~{'^':1,v:-1}[s.replace(/^(.)\1(\1\1)*(?=.?$)|.*(.)(((?!\3).)\5)+/,"").substr(-1)]
s=>~~{'^':1,v:-1}[s.replace(/^.*(.)(((?!\1).)\3)+|(.)\4(\4\4)*/,"").substr(-1)]
s=>~~{'^':1,v:-1}[s.replace(/^.*(.)(((?!\1).)\3)+|(.)\4(\4\4)*/,"").slice(-1)]
s=>~~{'^':1,v:-1}[s.replace(/.*(.)(((?!\1).)\3)+|(.)\4(\4\4)*/,"").slice(-1)]
s=>~~{'^':1,v:-1}[s.replace(/.*(.)(((?!\1).)\3)+|((.)\5)*/,"").slice(-1)]
s=>~~{'^':1,v:-1}[s.replace(/((.)\2)+/g,"!").slice(-1)]
s=>~~{'^':1,v:-1}[s.replace(/(.)\1/g,"!").slice(-1)]
s=>~~{'^':1,v:-1}[s.replace(/(.)\1/g,0).slice(-1)]
s=>~~{'^':1,v:-1}[s.replace(/(.)\1/g).slice(-1)]
deleted 18 characters in body
Source Link
Qwertiy
  • 3k
  • 1
  • 12
  • 31

Javascript ES6, 91 55 5248 chars

s=>~~{'^':1,v:-1}[s.replace(/(.)\1/g,"!").slice(-1)]

Test:

" -> 0\r\n\
^^ -> 0\r\n\
^v -> -1\r\n\
^ -> 1\r\n\
v -> -1\r\n\
v^ -> 1\r\n\
vv -> 0\r\n\
^^^ -> 1\r\n\
vvv -> -1\r\n\
^^^^ -> 0\r\n\
vvvv -> 0\r\n\
^^^^^ -> 1\r\n\
vvvvv -> -1\r\n\
^^^^^^ -> 0\r\n\
vvvvvv -> 0\r\n\
^^v -> -1\r\n\
^v^ -> 1\r\n\
^vv -> 0\r\n\
vv^ -> 1\r\n\
v^v -> -1\r\n\
v^^ -> 0\r\n\
^vvv^^vv^vv^v^ -> 1\r\n\
^vvv^^vv^vv^v^^ -> 0\r\n\
^vvv^^vv^vv^v^^^ -> 1\r\n\
^vvv^^vv^vv^v^^v -> -1\r\n\
^vvv^^vv^vv^v^^vv -> 0\r\n\
^vvv^^vv^vv^v^^vvv -> -1\r\n\
^vvvvvvvvvvvv -> 0\r\n\
^^vvvvvvvvvvvv -> 0\r\n\
^^^vvvvvvvvvvvv -> 0\r\n\
vvv^^^^^^^^^^^^ -> 0\r\n\
vv^^^^^^^^^^^^ -> 0\r\n\
v^^^^^^^^^^^^ -> 0"
.split("\n").map(s => s.split(" -> "))
.every(([s,key]) => (s=>~~{'^':1,v:-1}[s.replace(/(.)\1/g,"!").slice(-1)])(s)==key)

Javascript ES6, 91 55 52 chars

s=>~~{'^':1,v:-1}[s.replace(/(.)\1/g,"!").slice(-1)]

Test:

" -> 0\r\n\
^^ -> 0\r\n\
^v -> -1\r\n\
^ -> 1\r\n\
v -> -1\r\n\
v^ -> 1\r\n\
vv -> 0\r\n\
^^^ -> 1\r\n\
vvv -> -1\r\n\
^^^^ -> 0\r\n\
vvvv -> 0\r\n\
^^^^^ -> 1\r\n\
vvvvv -> -1\r\n\
^^^^^^ -> 0\r\n\
vvvvvv -> 0\r\n\
^^v -> -1\r\n\
^v^ -> 1\r\n\
^vv -> 0\r\n\
vv^ -> 1\r\n\
v^v -> -1\r\n\
v^^ -> 0\r\n\
^vvv^^vv^vv^v^ -> 1\r\n\
^vvv^^vv^vv^v^^ -> 0\r\n\
^vvv^^vv^vv^v^^^ -> 1\r\n\
^vvv^^vv^vv^v^^v -> -1\r\n\
^vvv^^vv^vv^v^^vv -> 0\r\n\
^vvv^^vv^vv^v^^vvv -> -1\r\n\
^vvvvvvvvvvvv -> 0\r\n\
^^vvvvvvvvvvvv -> 0\r\n\
^^^vvvvvvvvvvvv -> 0\r\n\
vvv^^^^^^^^^^^^ -> 0\r\n\
vv^^^^^^^^^^^^ -> 0\r\n\
v^^^^^^^^^^^^ -> 0"
.split("\n").map(s => s.split(" -> "))
.every(([s,key]) => (s=>~~{'^':1,v:-1}[s.replace(/(.)\1/g,"!").slice(-1)])(s)==key)

Javascript ES6, 91 48 chars

s=>~~{'^':1,v:-1}[s.replace(/(.)\1/g).slice(-1)]

Test:

" -> 0\r\n\
^^ -> 0\r\n\
^v -> -1\r\n\
^ -> 1\r\n\
v -> -1\r\n\
v^ -> 1\r\n\
vv -> 0\r\n\
^^^ -> 1\r\n\
vvv -> -1\r\n\
^^^^ -> 0\r\n\
vvvv -> 0\r\n\
^^^^^ -> 1\r\n\
vvvvv -> -1\r\n\
^^^^^^ -> 0\r\n\
vvvvvv -> 0\r\n\
^^v -> -1\r\n\
^v^ -> 1\r\n\
^vv -> 0\r\n\
vv^ -> 1\r\n\
v^v -> -1\r\n\
v^^ -> 0\r\n\
^vvv^^vv^vv^v^ -> 1\r\n\
^vvv^^vv^vv^v^^ -> 0\r\n\
^vvv^^vv^vv^v^^^ -> 1\r\n\
^vvv^^vv^vv^v^^v -> -1\r\n\
^vvv^^vv^vv^v^^vv -> 0\r\n\
^vvv^^vv^vv^v^^vvv -> -1\r\n\
^vvvvvvvvvvvv -> 0\r\n\
^^vvvvvvvvvvvv -> 0\r\n\
^^^vvvvvvvvvvvv -> 0\r\n\
vvv^^^^^^^^^^^^ -> 0\r\n\
vv^^^^^^^^^^^^ -> 0\r\n\
v^^^^^^^^^^^^ -> 0"
.split("\n").map(s => s.split(" -> "))
.every(([s,key]) => (s=>~~{'^':1,v:-1}[s.replace(/(.)\1/g).slice(-1)])(s)==key)
deleted 68 characters in body
Source Link
Qwertiy
  • 3k
  • 1
  • 12
  • 31
Loading
Source Link
Qwertiy
  • 3k
  • 1
  • 12
  • 31
Loading