Skip to content

Instantly share code, notes, and snippets.

@dosbol
Created July 10, 2018 04:50
Show Gist options
  • Save dosbol/6849481947914a18d7085f6e79b66eac to your computer and use it in GitHub Desktop.
Save dosbol/6849481947914a18d7085f6e79b66eac to your computer and use it in GitHub Desktop.
draft solution(texting from smartphone)
https://algoprog.ru/material/p50
const iter = (first, second, n) => {
if(isEmpty(first)) return 'second'
if(isEmpty(second)) return 'first'
if(n === 1000000) return 'botva'
const firstCard = head(first)
const secondCard = head(second)
return iter(firstCard < secondCard ? headPoped(first) : tailPushed(first, secondCard, firstCard), firstCard > secondCard ? headPoped(second) : tailPushed(second, firstCard, secondCard), n+1)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment