public class RandomWalker { public static void main(String[] args) { int x = 0; int y = 0; int passi = 0; int limite = Integer.parseInt(args[0]); System.out.println("(" + x + "," + y + ")"); while (Math.abs(x) + Math.abs(y) < limite) { double r = Math.random(); if (r < 0.25) { x++; } else if (r < 0.5) { x--; } else if (r < 0.75) { y++; } else { y--; } passi++; System.out.println("(" + x + "," + y + ")"); } System.out.println("steps = " + passi); } }