We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0faabf9 commit eb1fd20Copy full SHA for eb1fd20
Day5.java
@@ -0,0 +1,29 @@
1
+/**
2
+ * --- Day 5: A Maze of Twisty Trampolines, All Alike ---
3
+ */
4
+public class Day5 {
5
+
6
+ public static int part1(int[] maze) {
7
+ int steps = 0;
8
+ int i = 0;
9
+ while (i < maze.length) {
10
+ i = i + maze[i]++;
11
+ steps++;
12
+ }
13
14
+ return steps;
15
16
17
+ public static int part2(int[] maze) {
18
19
20
21
+ int next = i + maze[i];
22
+ maze[i] += (maze[i] >= 3 ? -1 : 1);
23
+ i = next;
24
25
26
27
28
29
+}
0 commit comments