Skip to main content
added 342 characters in body
Source Link
Confettimaker
  • 791
  • 2
  • 8
  • 20
too_big = False
for (x, y) in exp:
    if (x > 7) or (y > 7) or (x < -7) or (y < -7):
        too_big = True
        break
if too_big:
    continue

2.75) Don't add bad permutations

In the first for loop of possible_expansions, we can reject pieces that are too large:

for (x, y) in piece:
    for dx, dy in neighbor_offsets:
        if abs(x + dx) > 7 or abs(y + dy) > 7:
            continue
        positions.add((x + dx, y + dy))
too_big = False
for (x, y) in exp:
    if (x > 7) or (y > 7):
        too_big = True
        break
if too_big:
    continue
too_big = False
for (x, y) in exp:
    if (x > 7) or (y > 7) or (x < -7) or (y < -7):
        too_big = True
        break
if too_big:
    continue

2.75) Don't add bad permutations

In the first for loop of possible_expansions, we can reject pieces that are too large:

for (x, y) in piece:
    for dx, dy in neighbor_offsets:
        if abs(x + dx) > 7 or abs(y + dy) > 7:
            continue
        positions.add((x + dx, y + dy))
deleted 8 characters in body
Source Link
Confettimaker
  • 791
  • 2
  • 8
  • 20

Here are the changes I've madeis what I suggest so far:

Here are the changes I've made so far:

Here is what I suggest so far:

Added output comparison
Source Link
Confettimaker
  • 791
  • 2
  • 8
  • 20

Output sample comparison:

Number of Polyomino pieces up to size 63
    Output as-is                        Output after optimizations
Pieces with 10 blocks: 4645
0.36945559999730904         vs.     0.28241100000741426
Pieces with 11 blocks: 16929
1.572818599990569           vs.     1.208543800006737
Pieces with 12 blocks: 62149
6.77434189998894            vs.     5.203064699991955
Pieces with 13 blocks: 226701
28.675560999996378          vs.     22.347502399992663
Pieces with 14 blocks: 819508
116.19935209999676          vs.     91.290519400005

I will edit this if I find anything else!

I will edit this if I find anything else!

Output sample comparison:

Number of Polyomino pieces up to size 63
    Output as-is                        Output after optimizations
Pieces with 10 blocks: 4645
0.36945559999730904         vs.     0.28241100000741426
Pieces with 11 blocks: 16929
1.572818599990569           vs.     1.208543800006737
Pieces with 12 blocks: 62149
6.77434189998894            vs.     5.203064699991955
Pieces with 13 blocks: 226701
28.675560999996378          vs.     22.347502399992663
Pieces with 14 blocks: 819508
116.19935209999676          vs.     91.290519400005

I will edit this if I find anything else!

added 2 characters in body
Source Link
Confettimaker
  • 791
  • 2
  • 8
  • 20
Loading
added 273 characters in body
Source Link
Confettimaker
  • 791
  • 2
  • 8
  • 20
Loading
added 1 character in body
Source Link
Confettimaker
  • 791
  • 2
  • 8
  • 20
Loading
edited body
Source Link
Confettimaker
  • 791
  • 2
  • 8
  • 20
Loading
Source Link
Confettimaker
  • 791
  • 2
  • 8
  • 20
Loading