From b9ccf5254ed998b957d6d48b2bb10f09800bc603 Mon Sep 17 00:00:00 2001 From: Maxime Vorwerk Date: Fri, 25 Aug 2023 16:18:57 +0200 Subject: [PATCH] just realized there are no lists, only arrays :( --- julia/CubeShapeCounting.jl | 8 ++--- julia/ImmutableOrientedShape.jl | 12 ++++++- julia/Powerset.jl | 1 - julia/Shape.jl | 58 +++++++++++++++------------------ 4 files changed, 42 insertions(+), 37 deletions(-) diff --git a/julia/CubeShapeCounting.jl b/julia/CubeShapeCounting.jl index 3fc4736..04f216d 100644 --- a/julia/CubeShapeCounting.jl +++ b/julia/CubeShapeCounting.jl @@ -1,6 +1,6 @@ +include("ImmutableOrientedShape.jl") -function main(i::Int8) - S = Stack{Int}(); +function main(i::Int64) + D = Dict{ImmutableOrientedShape}() + S = Stack{Int64}(); end - -main(Int8(4)) diff --git a/julia/ImmutableOrientedShape.jl b/julia/ImmutableOrientedShape.jl index 2a5771d..6ab7d49 100644 --- a/julia/ImmutableOrientedShape.jl +++ b/julia/ImmutableOrientedShape.jl @@ -1,8 +1,18 @@ struct ImmutableOrientedShape - cubes::List{Tuple{Int8, Int8, Int8}} + cubes::Vector{Tuple{Int8, Int8, Int8}} hash::UInt end Base.hash(S::ImmutableOrientedShape) = S.hash Base.hash(S::ImmutableOrientedShape, h::UInt) = S.hash ⊻ h + +function Base.==(X::ImmutableOrientedShape, Y::ImmutableOrientedShape) + if hash != hash + return false + elseif X.cubes == Y.cubes + return false + else + return true + end +end \ No newline at end of file diff --git a/julia/Powerset.jl b/julia/Powerset.jl index 490ba48..c7770cb 100644 --- a/julia/Powerset.jl +++ b/julia/Powerset.jl @@ -1,4 +1,3 @@ - module Powerset global _calculatedPowerSets = Matrix{Int64}(undef, 1, 0) diff --git a/julia/Shape.jl b/julia/Shape.jl index 8edaf25..71bbcde 100644 --- a/julia/Shape.jl +++ b/julia/Shape.jl @@ -3,7 +3,7 @@ include("SortingModifiers.jl") struct Shape cubes::Set{Tuple{Int8, Int8, Int8}} recentCubes::Set{Tuple{Int8, Int8, Int8}} - orderedLists::Array{List{Tuple{Int8, Int8, Int8}}} + orderedLists::Vector{Vector{Tuple{Int8, Int8, Int8}}} end function trypush!(S::Shape, t::Tuple{Int8, Int8, Int8}) @@ -21,36 +21,32 @@ end function getCube() return Shape( - { - (0, 0, 0) - }, - { - (0, 0, 0) - }, + {(0, 0, 0)}, + {(0, 0, 0)}, [ - (0, 0, 0), - (0, 0, 0), - (0, 0, 0), - (0, 0, 0), - (0, 0, 0), - (0, 0, 0), - (0, 0, 0), - (0, 0, 0), - (0, 0, 0), - (0, 0, 0), - (0, 0, 0), - (0, 0, 0), - (0, 0, 0), - (0, 0, 0), - (0, 0, 0), - (0, 0, 0), - (0, 0, 0), - (0, 0, 0), - (0, 0, 0), - (0, 0, 0), - (0, 0, 0), - (0, 0, 0), - (0, 0, 0), - (0, 0, 0) + [(0, 0, 0)], + [(0, 0, 0)], + [(0, 0, 0)], + [(0, 0, 0)], + [(0, 0, 0)], + [(0, 0, 0)], + [(0, 0, 0)], + [(0, 0, 0)], + [(0, 0, 0)], + [(0, 0, 0)], + [(0, 0, 0)], + [(0, 0, 0)], + [(0, 0, 0)], + [(0, 0, 0)], + [(0, 0, 0)], + [(0, 0, 0)], + [(0, 0, 0)], + [(0, 0, 0)], + [(0, 0, 0)], + [(0, 0, 0)], + [(0, 0, 0)], + [(0, 0, 0)], + [(0, 0, 0)], + [(0, 0, 0)], ]) end