diff --git a/julia/main.jl b/julia/main.jl index 1108362..c18a695 100644 --- a/julia/main.jl +++ b/julia/main.jl @@ -1,6 +1,40 @@ +include("PolyCube.jl") -function main(maxsize::int): - +import JSON: json + +function main(maxsize::int) + root_pcube = PolyCube([(0, 0, 0)], [(0, 0, 0)]) + + todo = Vector{Coord}(undef, 0) + push!(todo, root_pcube) + + polycubes = Dict{Vector{Coord}, Vector{Coord}}() + polycubes[root_pcube.oriented_differences[0]] = root_pcube.cubes + + size_count = zeros(Int, maxsize) + size_count[1] = 1 + + while length(todo) > 0 + pcube = pop!(todo) + for child ∈ generate_children(pcube, maxsize) + if !child_exists_in(polycubes, child) + polycubes[child.oriented_differences[0]] = child.cubes + push!(todo, child) + size_count[length(child.cubes)] += 1 + end + end + end + write("out,dat", json(polycubes)) + write("out,dat", json(size_count)) +end + +function child_exists_in(dict::Dict, child::PolyCube) + for orientation ∈ child.oriented_differences + if haskey(dict, orientation) + return true + end + end + return false end main(7)