Created
December 30, 2025 15:34
-
-
Save brunoborges/84f833e37bed471cfe666852b659dfd0 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