@@ 0,0 1,44 @@
+package ninja.scoopta.software.advent_of_code_12020;
+
+import java.util.List;
+import java.nio.file.*;
+import java.io.IOException;
+
+final class Day3 {
+ public static final void main(String[] args) {
+ try {
+ List<String> lines = Files.readAllLines(Paths.get("day3.txt"));
+ System.out.println("Part 1");
+ pt1(lines);
+ System.out.println("Part 2");
+ pt2(lines);
+ } catch(IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private static final int slopeCheck(List<String> lines, int x, int y) {
+ int chr = 0;
+ int trees = 0;
+ for(int count = 0; count < lines.size(); count += y) {
+ String line = lines.get(count);
+ if(line.charAt(chr) == '#') {
+ ++trees;
+ }
+ chr += x;
+ if(chr >= line.length()) {
+ chr %= line.length();
+ }
+ }
+ return trees;
+ }
+
+ private static final void pt1(List<String> lines) {
+ System.out.println(slopeCheck(lines, 3, 1));
+ }
+
+ private static final void pt2(List<String> lines) {
+ int answer = slopeCheck(lines, 1, 1) * slopeCheck(lines, 3, 1) * slopeCheck(lines, 5, 1) * slopeCheck(lines, 7, 1) * slopeCheck(lines, 1, 2);
+ System.out.println(answer);
+ }
+}