diff options
Diffstat (limited to 'challenge-117/abigail/java/ch-2.java')
| -rw-r--r-- | challenge-117/abigail/java/ch-2.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/challenge-117/abigail/java/ch-2.java b/challenge-117/abigail/java/ch-2.java new file mode 100644 index 0000000000..05ebce2e86 --- /dev/null +++ b/challenge-117/abigail/java/ch-2.java @@ -0,0 +1,31 @@ +// +// See ../README.md +// + +// +// Run as: ln ch-2.java ch2.java; javac ch2.java; java ch2 < input-file +// + +import java.util.*; + + +public class ch2 { + static void steps (int x, int y, String path) { + if (x == 0 && y == 0) { + System . out . println (path); + } + if (x > 0) { + steps (x - 1, y + 1, path + "L"); + steps (x - 1, y, path + "R"); + } + if (y > 0) { + steps (x, y - 1, path + "H"); + } + } + + public static void main (String [] args) { + Scanner scanner = new Scanner (System . in); + int size = scanner . nextInt (); + steps (size, 0, ""); + } +} |
