Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Rock, Scissors, Paper in a circular array.

All you have to do to test for win condition is check if the other player has the next item in the array.

Equality is a tie.

Base case is a loss.

It's also my favorite case of structuring data in a way that makes the algorithm self-evident.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: