Skip to content

Commit

Permalink
[Day 25] Improve performance
Browse files Browse the repository at this point in the history
  • Loading branch information
goggle committed Jan 13, 2024
1 parent 66d0d25 commit b82253d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ This Julia package contains my solutions for [Advent of Code 2023](https://adven
| 22 | [:white_check_mark:](https://adventofcode.com/2023/day/22) | 790.712 ms | 631.26 MiB | [:white_check_mark:](https://github.com/goggle/AdventOfCode2023.jl/blob/master/src/day22.jl) |
| 23 | [:white_check_mark:](https://adventofcode.com/2023/day/23) | 2.979 s | 9.69 MiB | [:white_check_mark:](https://github.com/goggle/AdventOfCode2023.jl/blob/master/src/day23.jl) |
| 24 | [:white_check_mark:](https://adventofcode.com/2023/day/24) | 41.181 ms | 49.71 MiB | [:white_check_mark:](https://github.com/goggle/AdventOfCode2023.jl/blob/master/src/day24.jl) |
| 25 | [:white_check_mark:](https://adventofcode.com/2023/day/25) | 153.698 ms | 176.55 MiB | [:white_check_mark:](https://github.com/goggle/AdventOfCode2023.jl/blob/master/src/day25.jl) |
| 25 | [:white_check_mark:](https://adventofcode.com/2023/day/25) | 69.476 ms | 62.03 MiB | [:white_check_mark:](https://github.com/goggle/AdventOfCode2023.jl/blob/master/src/day25.jl) |


The benchmarks have been measured on this machine:
Expand Down
8 changes: 4 additions & 4 deletions src/day25.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ end
function parse_input(input::AbstractString)
i = 1
translations = Dict{String,Int}()
graph = Dict{Int, Set{Int}}()
graph = Dict{Int, Vector{Int}}()
for line eachsplit(rstrip(input), "\n")
nodes = split.(replace(line, ":" => ""), " ")
n = Int[]
Expand All @@ -22,7 +22,7 @@ function parse_input(input::AbstractString)
push!(n, translations[node])
else
translations[node] = i
graph[i] = Set{Int}()
graph[i] = Vector{Int}()
push!(n, i)
i += 1
end
Expand All @@ -36,8 +36,8 @@ function parse_input(input::AbstractString)
return graph, i - 1
end

function solve(graph::Dict{Int,Set{Int}}, total_size::Int)
for k = 1:total_size
function solve(graph::Dict{Int,Vector{Int}}, total_size::Int)
for k = shuffle(1:total_size)
not_connected = PriorityQueue{Int,Int}()
connected = Set{Int}()
for i 1:total_size
Expand Down

0 comments on commit b82253d

Please sign in to comment.