whale
commit
9b46510667
@ -0,0 +1,50 @@
|
|||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class DayOne {
|
||||||
|
public static void main( String[] args) {
|
||||||
|
int count = 0;
|
||||||
|
int count2 = 0;
|
||||||
|
int[] numbers;
|
||||||
|
int[] solutions;
|
||||||
|
solutions = new int[20];
|
||||||
|
numbers = new int[500];
|
||||||
|
try {
|
||||||
|
File inputFile = new File("input.txt");
|
||||||
|
Scanner readFile = new Scanner(inputFile);
|
||||||
|
while (readFile.hasNextLine()) {
|
||||||
|
numbers[count] = readFile.nextInt();
|
||||||
|
count ++;
|
||||||
|
}
|
||||||
|
readFile.close();
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
System.out.println("crap");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < count; i++){
|
||||||
|
for (int j = 0; j < count; j++){
|
||||||
|
for (int k = 0; k < count; k++){
|
||||||
|
if (numbers[i] + numbers[j] + numbers[k] == 2020) {
|
||||||
|
solutions[count2] = numbers[i];
|
||||||
|
solutions[count2+1] = numbers[j];
|
||||||
|
solutions[count2+2] = numbers[k];
|
||||||
|
count2 = count2 + 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println(solutions[0] * solutions[1] * solutions[2]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,200 @@
|
|||||||
|
1975
|
||||||
|
1446
|
||||||
|
1902
|
||||||
|
1261
|
||||||
|
1783
|
||||||
|
1535
|
||||||
|
1807
|
||||||
|
1606
|
||||||
|
1685
|
||||||
|
1933
|
||||||
|
1930
|
||||||
|
1813
|
||||||
|
1331
|
||||||
|
1986
|
||||||
|
1379
|
||||||
|
1649
|
||||||
|
1342
|
||||||
|
1206
|
||||||
|
1832
|
||||||
|
1464
|
||||||
|
1840
|
||||||
|
1139
|
||||||
|
1316
|
||||||
|
1366
|
||||||
|
593
|
||||||
|
1932
|
||||||
|
1553
|
||||||
|
1065
|
||||||
|
2004
|
||||||
|
1151
|
||||||
|
1345
|
||||||
|
1026
|
||||||
|
1958
|
||||||
|
1778
|
||||||
|
1987
|
||||||
|
1425
|
||||||
|
1170
|
||||||
|
1927
|
||||||
|
1487
|
||||||
|
1116
|
||||||
|
1612
|
||||||
|
2005
|
||||||
|
1977
|
||||||
|
1691
|
||||||
|
1964
|
||||||
|
398
|
||||||
|
1621
|
||||||
|
1542
|
||||||
|
1929
|
||||||
|
1102
|
||||||
|
1993
|
||||||
|
1426
|
||||||
|
1349
|
||||||
|
1280
|
||||||
|
1775
|
||||||
|
849
|
||||||
|
1344
|
||||||
|
1940
|
||||||
|
1707
|
||||||
|
1562
|
||||||
|
1979
|
||||||
|
1325
|
||||||
|
1610
|
||||||
|
559
|
||||||
|
1812
|
||||||
|
1938
|
||||||
|
1572
|
||||||
|
1949
|
||||||
|
1136
|
||||||
|
161
|
||||||
|
1893
|
||||||
|
1207
|
||||||
|
1363
|
||||||
|
1551
|
||||||
|
1333
|
||||||
|
1904
|
||||||
|
1332
|
||||||
|
1450
|
||||||
|
1773
|
||||||
|
1216
|
||||||
|
1185
|
||||||
|
1881
|
||||||
|
1835
|
||||||
|
1460
|
||||||
|
1277
|
||||||
|
1374
|
||||||
|
1568
|
||||||
|
1731
|
||||||
|
1365
|
||||||
|
1719
|
||||||
|
1749
|
||||||
|
1371
|
||||||
|
1602
|
||||||
|
1108
|
||||||
|
1030
|
||||||
|
1859
|
||||||
|
1875
|
||||||
|
1976
|
||||||
|
1837
|
||||||
|
1768
|
||||||
|
1873
|
||||||
|
1226
|
||||||
|
1533
|
||||||
|
1601
|
||||||
|
1394
|
||||||
|
1422
|
||||||
|
1219
|
||||||
|
1269
|
||||||
|
1793
|
||||||
|
1195
|
||||||
|
1234
|
||||||
|
1575
|
||||||
|
1882
|
||||||
|
1223
|
||||||
|
1826
|
||||||
|
521
|
||||||
|
1161
|
||||||
|
1738
|
||||||
|
1506
|
||||||
|
1574
|
||||||
|
1337
|
||||||
|
1509
|
||||||
|
1430
|
||||||
|
1496
|
||||||
|
1318
|
||||||
|
1400
|
||||||
|
1852
|
||||||
|
1670
|
||||||
|
1898
|
||||||
|
1858
|
||||||
|
1950
|
||||||
|
1870
|
||||||
|
1920
|
||||||
|
868
|
||||||
|
1814
|
||||||
|
1853
|
||||||
|
1911
|
||||||
|
1907
|
||||||
|
1713
|
||||||
|
1281
|
||||||
|
1759
|
||||||
|
1210
|
||||||
|
1350
|
||||||
|
1035
|
||||||
|
1585
|
||||||
|
1765
|
||||||
|
1220
|
||||||
|
1125
|
||||||
|
1714
|
||||||
|
1810
|
||||||
|
1002
|
||||||
|
1356
|
||||||
|
1192
|
||||||
|
1452
|
||||||
|
1236
|
||||||
|
1482
|
||||||
|
1716
|
||||||
|
1681
|
||||||
|
1323
|
||||||
|
1923
|
||||||
|
1876
|
||||||
|
1792
|
||||||
|
1346
|
||||||
|
1891
|
||||||
|
1721
|
||||||
|
1056
|
||||||
|
1675
|
||||||
|
1518
|
||||||
|
1540
|
||||||
|
1068
|
||||||
|
1563
|
||||||
|
1942
|
||||||
|
1668
|
||||||
|
1653
|
||||||
|
1357
|
||||||
|
1632
|
||||||
|
1128
|
||||||
|
1726
|
||||||
|
1586
|
||||||
|
1998
|
||||||
|
1138
|
||||||
|
1510
|
||||||
|
1022
|
||||||
|
1480
|
||||||
|
1434
|
||||||
|
1305
|
||||||
|
1861
|
||||||
|
1623
|
||||||
|
1009
|
||||||
|
1339
|
||||||
|
1159
|
||||||
|
1085
|
||||||
|
1578
|
||||||
|
1689
|
||||||
|
1091
|
||||||
|
1874
|
||||||
|
1043
|
||||||
|
1737
|
||||||
|
1704
|
||||||
|
1515
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
class DayTwo {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
int count1 = 0;
|
||||||
|
try {
|
||||||
|
File inputFile = new File("input.txt");
|
||||||
|
Scanner readFile = new Scanner(inputFile);
|
||||||
|
while (readFile.hasNextLine()) {
|
||||||
|
int count2 = 0;
|
||||||
|
String whale = readFile.nextLine();
|
||||||
|
int lowerBound = Integer.parseInt(whale.substring(0, whale.indexOf("-")));
|
||||||
|
int upperBound = Integer.parseInt(whale.substring(whale.indexOf("-") + 1, whale.indexOf(":") - 2));
|
||||||
|
char inputKey = whale.charAt(whale.indexOf(":") - 1);
|
||||||
|
String password = whale.substring(whale.indexOf(":") + 1);
|
||||||
|
char[] passwordChar;
|
||||||
|
passwordChar = password.toCharArray();
|
||||||
|
for (int i = 0; i < passwordChar.length; i++) {
|
||||||
|
if (inputKey == passwordChar[i]) {
|
||||||
|
count2++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (passwordChar[lowerBound] == inputKey ^ passwordChar[upperBound] == inputKey) {
|
||||||
|
count1++;
|
||||||
|
}
|
||||||
|
System.out.println(lowerBound);
|
||||||
|
System.out.println(upperBound);
|
||||||
|
System.out.println(inputKey);
|
||||||
|
System.out.println(password);
|
||||||
|
System.out.println(count1);
|
||||||
|
}
|
||||||
|
readFile.close();
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
System.out.println("crap");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue