4 ms·
This is a fun problem to play with. Like others, I've been trying the general approach of generating random configurations, then iterating by swapping pairs of
by jffry 8y ago
This is a fun problem to play with. Like others, I've been trying the general approach of generating random configurations, then iterating by swapping pairs of elements (each time choosing the pair that yields the best local improvement).
Lowest value found, has vertical symmetry (notice how (1,24), (2,23), (3,22), (4,21) and so on are paired)
[[14 7 19 12 5 17]
[21 9 2 24 22 10]
[ 4 16 23 1 3 15]
[11 18 6 13 20 8]]
375.923809971073
Highest value found, has rotational symmetry (see how the path from 1-24 is almost like a squished Hilbert curve)
[[ 6 7 10 11 23 24]
[ 5 8 9 12 22 21]
[ 4 3 13 16 17 20]
[ 1 2 14 15 18 19]]
529.6200384399018
Code is at https://gist.github.com/jffry/fab43b5b65499c3f513fea701597806b https://gist.github.com/jffry/fab43b5b65499c3f513fea70159780.... Probably full of new-to-Rust mistakes, so please let me know where I've strayed from the light if you're particular about Rust!
As mentioned elsewhere I'm very curious about how this generalizes to grid sizes other than 6x4
- zimpenfish 8y agoNoticed that my best was almost horizontally symmetrical apart from two slots - except swapping those slots changes the score from 375.99867 to 376.19293. Most perplexing.