This website works better with JavaScript.
Home
Help
Sign In
mehalter
/
AOC.jl
Watch
1
Star
0
Fork
0
Code
Issues
0
Pull Requests
0
Releases
0
Activity
Browse Source
Finished 2020 day 13
main
Micah Halter
1 month ago
parent
5ae171f536
commit
7d9f3e29d8
Signed by:
mehalter
GPG Key ID:
4224A6EA9A8CAAA8
4 changed files
with
23 additions
and
2 deletions
Split View
Diff Options
Show Stats
Download Patch File
Download Diff File
+2
-0
2020/data/day_13.txt
+1
-2
2020/src/day_12.jl
+19
-0
2020/src/day_13.jl
+1
-0
Project.toml
+ 2
- 0
2020/data/day_13.txt
View File
@ -0,0 +1,2 @@
1008832
23,x,x,x,x,x,x,x,x,x,x,x,x,41,x,x,x,x,x,x,x,x,x,449,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,13,19,x,x,x,x,x,x,x,x,x,29,x,991,x,x,x,x,x,37,x,x,x,x,x,x,x,x,x,x,17
+ 1
- 2
2020/src/day_12.jl
View File
@ -11,8 +11,7 @@ function step_ship(inst, pos, dir, part_2=false)
pos
+=
val
*
dir
elseif
comm
=
=
'R'
||
comm
=
=
'L'
s
,
c
=
map
(
x
-
>
Int
(
round
(
x
(
deg2rad
(
val
)
)
)
)
,
[
sin
,
cos
]
)
dir
*=
comm
=
=
'R'
?
[
c
-
s
;
s
c
]
:
[
c
s
;
-
s
c
]
dir
*=
comm
=
=
'R'
?
[
c
-
s
;
s
c
]
:
[
c
s
;
-
s
c
]
elseif
!
part_2
pos
+=
val
*
dirs
[
comm
]
else
+ 19
- 0
2020/src/day_13.jl
View File
@ -0,0 +1,19 @@
# https://adventofcode.com/2020/day/13
using
AdventOfCode
using
Mods
t_str
,
buses_str
=
readlines
(
"
2
0
2
0
/
d
a
t
a
/
d
a
y
_
1
3
.
t
x
t
"
)
time
=
parse
(
Int
,
t_str
)
buses
=
map
(
x
-
>
x
=
=
"
x
"
?
nothing
:
parse
(
Int
,
x
)
,
split
(
buses_str
,
','
)
)
function
part_1
(
)
wait
,
bus
=
min
(
map
(
x
-
>
(
x
*
ceil
(
time
/
x
)
,
x
)
,
filter
(
!
isnothing
,
buses
)
)
.
.
.
)
(
wait
-
time
)
*
bus
end
@info
part_1
(
)
function
part_2
(
)
mods
=
map
(
k
-
>
Mod
{
buses
[
k
]
}
(
-
(
k
-
1
)
)
,
filter
(
k
-
>
!
isnothing
(
buses
[
k
]
)
,
keys
(
buses
)
)
)
CRT
(
mods
.
.
.
)
.
val
end
@info
part_2
(
)
+ 1
- 0
Project.toml
View File
@ -2,3 +2,4 @@
AdventOfCode
=
"7ef4cfdd-3fec-4d8b-b242-bcc5161d01d5"
Combinatorics
=
"861a8166-3701-5b0c-9a16-15d98fcdc6aa"
MD5
=
"6ac74813-4b46-53a4-afec-0b5dc9d7885c"
Mods
=
"7475f97c-0381-53b1-977b-4c60186c8d62"
Write
Preview
Loading…
Cancel
Save