Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const reverseCaptcha = str =>
- str.split('').reduce((sum, x, i, a) =>
- ( x === a[i + 1] || (i === a.length - 1 && x === a[0]) ) ?
- sum + Number(x) :
- sum
- , 0)
- // Demo input
- let input = "12233545132218841"
- reverseCaptcha(input) // -> 16
Add Comment
Please, Sign In to add comment