FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
adventofcode/src/main/java/AoC2019_09.java at main · pareronia/adventofcode · GitHub
pareronia
/
adventofcode
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
2
Code
Issues
0
Pull requests
0
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
adventofcode
/
src
/
main
/
java
/
AoC2019_09.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
52 lines (42 loc) · 1.46 KB
Breadcrumbs
adventofcode
/
src
/
main
/
java
/
AoC2019_09.java
Copy path
File metadata and controls
52 lines (42 loc) · 1.46 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import
java
.
util
.
ArrayDeque
;
import
java
.
util
.
Deque
;
import
java
.
util
.
List
;
import
com
.
github
.
pareronia
.
aoc
.
intcode
.
IntCode
;
import
com
.
github
.
pareronia
.
aocd
.
Aocd
;
import
com
.
github
.
pareronia
.
aocd
.
Puzzle
;
public
class
AoC2019_09
extends
AoCBase
{
private
final
List
<
Long
>
program
;
private
AoC2019_09
(
final
List
<
String
>
input
,
final
boolean
debug
) {
super
(
debug
);
assert
input
.
size
() ==
1
;
this
.
program
=
IntCode
.
parse
(
input
.
get
(
0
));
}
public
static
AoC2019_09
create
(
final
List
<
String
>
input
) {
return
new
AoC2019_09
(
input
,
false
);
}
public
static
AoC2019_09
createDebug
(
final
List
<
String
>
input
) {
return
new
AoC2019_09
(
input
,
true
);
}
private
Long
solve
(
final
long
input
) {
final
IntCode
intCode
=
new
IntCode
(
this
.
program
,
this
.
debug
);
final
Deque
<
Long
>
output
=
new
ArrayDeque
<>();
intCode
.
run
(
input
,
output
);
return
output
.
getLast
();
}
@
Override
public
Long
solvePart1
() {
return
solve
(
1
);
}
@
Override
public
Long
solvePart2
() {
return
solve
(
2
);
}
public
static
void
main
(
final
String
[]
args
)
throws
Exception
{
final
Puzzle
puzzle
=
Aocd
.
puzzle
(
2019
,
9
);
final
List
<
String
>
inputData
=
puzzle
.
getInputData
();
puzzle
.
check
(
() ->
lap
(
"Part 1"
,
AoC2019_09
.
create
(
inputData
)::
solvePart1
),
() ->
lap
(
"Part 2"
,
AoC2019_09
.
create
(
inputData
)::
solvePart2
)
);
}
}
Back
|
FazBrowse Home
|
New Git URL