2.7 ms

🦌 Advent Of Code 2020

The goals are:

  • Learn Julia

  • Write readable code (avoid golfing)

  • Write efficient code if possible

See Advent Of Code 2020 for more information.

3.4 ms

Day 1

6.3 μs
input_day1
69.6 ms
day1_part1 (generic function with 1 method)
29.5 μs
day1_part2 (generic function with 1 method)
45.7 μs

Result for part 1: 913824

Result for part 2: 240889536

60.1 ms

Day 2

4.2 μs
495 μs
nb_of_valid_passwords_part2 (generic function with 1 method)
40.2 μs
parse_day2 (generic function with 1 method)
47.3 μs
nb_of_valid_passwords_part1 (generic function with 1 method)
33.9 μs

Test 1, part 1: true

Test 1, part 2: true

116 ms
input_day2
7.5 ms

Result for part 1: 600

157 μs

Result for part 2: 245

130 μs

Day 3

4.6 μs
parse_day3 (generic function with 1 method)
51.6 μs
nb_trees_encountered (generic function with 2 methods)
127 μs
nb_trees_encountered_part2 (generic function with 1 method)
31.0 μs

Test 1, part 1: true

Test 1, part 2: true

421 ms
input_day3
323×31 LinearAlgebra.Adjoint{Bool,Array{Bool,2}}:
 0  0  1  0  0  0  0  0  0  1  1  1  0  0  …  0  0  1  1  0  0  1  0  1  0  0  0  0
 0  1  0  1  0  0  0  0  0  1  0  1  1  0     1  1  1  0  0  0  1  1  0  0  0  1  1
 0  0  1  0  1  0  0  1  0  0  0  0  0  0     0  1  0  1  0  0  1  0  0  0  0  0  0
 0  0  1  0  0  0  0  0  0  1  0  0  0  0     0  0  1  1  1  0  0  0  0  0  0  0  0
 0  0  0  1  0  0  1  1  1  0  0  1  1  0     0  0  0  0  0  0  0  1  1  0  0  1  1
 0  0  0  0  0  0  1  0  1  0  1  1  0  0  …  0  1  0  0  0  0  1  1  1  0  0  0  0
 0  0  0  0  0  0  0  0  0  0  1  1  0  0     1  0  0  1  1  0  0  0  0  0  0  1  0
 ⋮              ⋮              ⋮           ⋱        ⋮              ⋮              ⋮
 0  0  1  0  0  0  0  0  1  0  0  0  0  0     0  0  0  1  0  0  0  0  0  0  0  0  0
 0  1  0  0  0  0  0  0  0  0  0  0  0  0     0  0  0  0  0  1  1  1  0  0  0  0  1
 0  0  0  0  0  0  0  0  1  0  1  1  1  1     0  0  0  0  0  1  0  1  0  1  0  0  0
 1  0  0  0  0  0  0  0  0  0  0  0  1  1  …  0  0  0  0  0  0  0  0  0  1  0  0  1
 0  0  0  0  0  0  0  0  0  0  0  1  0  0     0  0  0  1  0  0  0  1  0  1  0  0  0
 0  0  0  0  1  1  0  0  0  1  1  0  0  0     0  0  0  0  1  0  0  0  0  0  0  0  0
113 ms

Result for part 1: 262

Result for part 2: 2698900776

10.5 ms

Day 4

4.9 μs
parse_day4 (generic function with 1 method)
45.5 μs
count_nb_valid_passport (generic function with 2 methods)
191 μs

Test 1, part 1: true

Test 1, part 2: true

Test 2, part 2: true

140 ms
input_day4
9.1 ms

Result for part 1: 264

Result for part 2: 224

1.3 ms

Day 5

4.5 μs
parse_day5 (generic function with 1 method)
52.3 μs

Test 1, part 1: true

147 ms
find_missing_id (generic function with 1 method)
35.2 μs
input_day5
9.3 ms

Result for part 1: 850

Result for part 2: 599

22.8 ms

Day 6

3.4 μs
parse_day6 (generic function with 1 method)
39.4 μs
sum_of_group_lengths (generic function with 1 method)
45.1 μs

Test 1, part 1: true

Test 1, part 2: true

631 ms

Number of groups read from data/day06.txt: 490

37.4 ms

Result for part 1: 6735

Result for part 2: 3221

2.0 ms

Day 7

6.3 μs
607 μs
parse_day7 (generic function with 1 method)
69.9 μs
bags_that_contain (generic function with 1 method)
42.4 μs
nb_bags_contained (generic function with 1 method)
59.2 μs

Test 1, part 1: true

Test 1, part 2: true

Test 2, part 2: true

385 ms
input_day7
17.3 ms

Result for part 1: 335

Result for part 2: 2431

1.6 ms

Day 8

5.4 μs
623 μs
parse_day8 (generic function with 1 method)
32.3 μs
execute (generic function with 1 method)
40.5 μs
fix_to_not_loop (generic function with 1 method)
56.4 μs

Test 1, part 1: true

Test 1, part 2: true

90.3 ms
input_day8
8.3 ms

Result for part 1: (false, 1928)

Result for part 2: 1319

1.1 ms

Day [9]

5.2 μs
parse_day9 (generic function with 1 method)
25.9 μs
first_number_without_valid_pair (generic function with 1 method)
79.7 μs
find_encryption_weakness (generic function with 1 method)
38.0 μs

Test 1, part 1: true

Test 1, part 2: true

40.7 μs
input_day9
9.9 ms

Result for part 1: 31161678

Result for part 2: 5453868

27.6 ms