Created
November 7, 2025 20:26
-
-
Save brunoborges/c9d2ba95262a8f077aaf31a891c9c43c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void main() { | |
| IO.println("rock/paper/scissors:"); | |
| var u = IO.readln(); | |
| if (u.equals("exit")) return; | |
| var c = "rock,paper,scissors".split(","); | |
| var i = List.of(c).indexOf(u); | |
| if (i < 0) return; | |
| var j = new Random().nextInt(3); | |
| IO.println("Computer: " + c[j]); | |
| IO.println(i == j ? "Tie!" : (i == (j + 1) % 3 ? "You win!" : "Computer wins!")); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment