Created
December 9, 2020 19:22
-
-
Save gitaficionado/7c47452323d687d48af19e5e43f7c28b to your computer and use it in GitHub Desktop.
AOC 2020 day 1 for demo. Thanks to TurkeyDev for the file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package dev.theturkey.aoc2020; | |
import java.util.List; | |
public class Day1 extends AOCPuzzle | |
{ | |
public Day1() | |
{ | |
super("1"); | |
} | |
@Override | |
void solve(List<String> input) | |
{ | |
for(int i = 0; i < input.size(); i++) | |
{ | |
for(int j = i + 1; j < input.size(); j++) | |
{ | |
for(int k = j + 1; k < input.size(); k++) | |
{ | |
Integer int1 = Integer.parseInt(input.get(i)); | |
Integer int2 = Integer.parseInt(input.get(j)); | |
Integer int3 = Integer.parseInt(input.get(k)); | |
if(int1 + int2 + int3 == 2020) | |
{ | |
System.out.println("Answer: " + int1 * int2 * int3); | |
return; | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment