Skip to content

Commit 72afbd0

Browse files
committed
[Day 11] Slight improvement
1 parent 6839616 commit 72afbd0

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ This Julia package contains my solutions for [Advent of Code 2024](https://adven
2020
| 8 | [:white_check_mark:](https://adventofcode.com/2024/day/8) | 316.122 μs | 671.41 KiB | [:white_check_mark:](https://github.com/goggle/AdventOfCode2024.jl/blob/main/src/day08.jl) |
2121
| 9 | [:white_check_mark:](https://adventofcode.com/2024/day/9) | 32.603 ms | 9.58 MiB | [:white_check_mark:](https://github.com/goggle/AdventOfCode2024.jl/blob/main/src/day09.jl) |
2222
| 10 | [:white_check_mark:](https://adventofcode.com/2024/day/10) | 578.868 μs | 633.67 KiB | [:white_check_mark:](https://github.com/goggle/AdventOfCode2024.jl/blob/main/src/day10.jl) |
23-
| 11 | [:white_check_mark:](https://adventofcode.com/2024/day/11) | 16.464 ms | 13.70 MiB | [:white_check_mark:](https://github.com/goggle/AdventOfCode2024.jl/blob/main/src/day11.jl) |
23+
| 11 | [:white_check_mark:](https://adventofcode.com/2024/day/11) | 15.732 ms | 12.60 MiB | [:white_check_mark:](https://github.com/goggle/AdventOfCode2024.jl/blob/main/src/day11.jl) |
2424
| 12 | [:white_check_mark:](https://adventofcode.com/2024/day/12) | 12.506 ms | 10.00 MiB | [:white_check_mark:](https://github.com/goggle/AdventOfCode2024.jl/blob/main/src/day12.jl) |
2525
| 13 | [:white_check_mark:](https://adventofcode.com/2024/day/13) | 3.423 ms | 1.15 MiB | [:white_check_mark:](https://github.com/goggle/AdventOfCode2024.jl/blob/main/src/day13.jl) |
2626
| 14 | [:white_check_mark:](https://adventofcode.com/2024/day/14) | 75.842 ms | 275.06 KiB | [:white_check_mark:](https://github.com/goggle/AdventOfCode2024.jl/blob/main/src/day14.jl) |

src/day11.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ function solve(data, runtime)
4848
end
4949

5050
function split_number(number::Int)
51-
n = length(digits(number))
52-
l = digits(number)[n÷2+1:end] .* [10^x for x 0:n÷2-1] |> sum
53-
r = digits(number)[1:n÷2] .* [10^x for x 0:n÷2-1] |> sum
51+
digs = digits(number)
52+
n = length(digs)
53+
l = @view(digs[n÷2+1:end]) .* [10^x for x 0:n÷2-1] |> sum
54+
r = @view(digs[1:n÷2]) .* [10^x for x 0:n÷2-1] |> sum
5455
return l, r
5556
end
5657

0 commit comments

Comments
 (0)