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 393dc3e commit baf6d9eCopy full SHA for baf6d9e
java/src/main/java/y2019/d24/Part1.java
@@ -43,15 +43,30 @@ public static void main(String[] args) {
43
}
44
45
mapString = mapToString(newMap);
46
+ map = newMap;
47
48
if (!seen.add(mapString)) {
49
break;
50
51
//System.out.println(mapString);
- map = newMap;
52
53
54
System.out.println(mapString);
55
+ System.out.println(biodiversityRating(map));
56
+ }
57
+
58
+ private static int biodiversityRating(boolean[][] inMap) {
59
+ int exponent = -1;
60
+ int biodiversityRating = 0;
61
+ for (boolean[] line: inMap) {
62
+ for (boolean field: line) {
63
+ exponent++;
64
+ if (field) {
65
+ biodiversityRating += Math.pow(2, exponent);
66
67
68
69
+ return biodiversityRating;
70
71
72
private static boolean willLive(int x, int y) {
0 commit comments