Skip to content

Instantly share code, notes, and snippets.

@waterlink
Created October 15, 2018 15:49
Show Gist options
  • Select an option

  • Save waterlink/16c803dde5dbb8ca49d5f37bb5a6dac7 to your computer and use it in GitHub Desktop.

Select an option

Save waterlink/16c803dde5dbb8ca49d5f37bb5a6dac7 to your computer and use it in GitHub Desktop.
step - 8
interface Throw {
val winsAgainst: List<Throw>
fun beats(other: Throw) = winsAgainst.contains(other)
object SCISSORS : Throw {
override val winsAgainst = listOf(PAPER, LIZARD)
}
object PAPER : Throw {
override val winsAgainst = listOf(ROCK, SPOCK)
}
object ROCK : Throw {
override val winsAgainst = listOf(SCISSORS, LIZARD)
}
object LIZARD : Throw {
override val winsAgainst = listOf(SPOCK, PAPER)
}
object SPOCK : Throw {
override val winsAgainst = listOf(SCISSORS, ROCK)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment