-
Notifications
You must be signed in to change notification settings - Fork 0
/
day1.html
132 lines (110 loc) · 3.05 KB
/
day1.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<!DOCTYPE html>
<html lang="en">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
<meta content="width=device-width, initial-scale=1, maximum-scale=1.0" name="viewport"/>
<title>Advent Of Code 2020 - Day 1</title>
<!-- CSS -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="css/materialize.css" media="screen,projection" rel="stylesheet" type="text/css"/>
<link href="css/style.css" media="screen,projection" rel="stylesheet" type="text/css"/>
<link rel="icon" type="image/png" sizes="96x96" href="img/favicon.ico">
</head>
<body>
<ul class="dropdown-content" id="dropdown1">
</ul>
<nav class="green darken-4" role="navigation">
<div class="nav-wrapper">
<a href="#" class="brand-logo center">Day 1</a>
<ul class="right hide-on-med-and-down">
<!-- Dropdown Trigger -->
<a class="dropdown-trigger" data-target="dropdown1" href="#!">Altri giorni<i class="material-icons right">arrow_drop_down</i></a>
</ul>
<ul class="sidenav" id="nav-mobile">
</ul>
<a class="sidenav-trigger" data-target="nav-mobile" href="#"><i class="material-icons">menu</i></a>
</div>
</nav>
<ul class="lightrope" id="lightrope">
</ul>
<div class="container">
<br>
<br>
<br>
<br>
<div class="section">
<div class="row center">
<div class="col input-field file-field s12">
<div class="btn light-green darken-3">
<span>Inserire l'input</span> <input id="inputfile" name="inputfile" type="file">
</div>
<div class="file-path-wrapper">
<input class="file-path validate" type="text">
</div>
</div>
</div>
<div class="row center">
<div class="col s6">
<h5>Parte 1: </h5>
<h6 id="Parte1"></h6>
</div>
<div class="col s6">
<h5>Parte 2: </h5>
<h6 id="Parte2"></h6>
</div>
</div>
</div>
</div>
<!-- Scripts-->
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="js/materialize.js"></script>
<script src="js/init.js"></script>
<script src="js/custom.js"></script>
<script>
let input
function findTwoNumbers() {
let numbers = input.split("\n")
numbers = numbers.map(x => parseInt(x))
numbers.sort();
for (let i = 0; i < numbers.length ; i++) {
let n=numbers[i]
for (let j = 0; j < numbers.length; j++) {
let m = numbers[j]
if (n+m == 2020) {
$("#Parte1").html(n * m)
return
}
}
}
}
function findThreeNumbers(){
let numbers = input.split("\n")
numbers = numbers.map(x => parseInt(x))
numbers.sort();
for (let i = 0; i < numbers.length ; i++) {
let n=numbers[i]
for (let j = 0; j < numbers.length; j++) {
let m = numbers[j]
for (let k = 0; k < numbers.length; k++) {
let l = numbers[k]
if (n+m+l == 2020) {
$("#Parte2").html((n * m * l))
return
}
}
}
}
}
function findNumers(){
findTwoNumbers();
findThreeNumbers();
}
$(document).ready(function () {
setUpNav($("#dropdown1"), $("#nav-mobile"))
$(".dropdown-trigger").dropdown();
setUpLights($("#lightrope"))
getInput(findNumers);
});
</script>
</body>
</html>