Skip to content

Instantly share code, notes, and snippets.

@krtek
Created February 20, 2013 00:23
Show Gist options
  • Select an option

  • Save krtek/4991591 to your computer and use it in GitHub Desktop.

Select an option

Save krtek/4991591 to your computer and use it in GitHub Desktop.
ZT - Unicorn puzzle solution
public class MagicalLand {
public static void main(String[] args) {
for (int i = 0; i < (Math.random() * 500) + 2; i++) {
if (Unicorn.pat()) {
System.out.println("UNICORN #1: PAT THIS UNICORN ONCE");
}
}
for (int i = 0; i < (Math.random() * 500) + 2; i++) {
if (Unicorn.pat()) {
System.out.println("UNICORN #2: PAT THIS UNICORN ONCE");
}
}
System.out.println("END OF PROGRAM");
}
}
class Unicorn {
static boolean pat() {
return true;
}
}
class Math {
static double random() {
return (double) -1/500;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment