Skip to content

Instantly share code, notes, and snippets.

@brunoborges
Created November 7, 2025 20:26
Show Gist options
  • Save brunoborges/c9d2ba95262a8f077aaf31a891c9c43c to your computer and use it in GitHub Desktop.
Save brunoborges/c9d2ba95262a8f077aaf31a891c9c43c to your computer and use it in GitHub Desktop.
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