Åœʒ23yåP}€œ€`Ùε.¥¦¨}IиI.ÆÙεøyíø‚€€üQOO_P}O
J'ai presque trop honte de poster ceci, et il peut certainement être joué par A LOT avec une approche différente, mais comme il a fallu un certain temps pour terminer, j'ai décidé de le publier de toute façon et de le jouer à partir d'ici. Le défi semble plus facile qu'il ne l'est, mais j'utilise certainement une mauvaise approche ici et j'ai le sentiment que 05AB1E pourrait faire environ 25 octets ..
Essayez-le en ligne. REMARQUE: non seulement il est long, mais il est également inefficace, car le 9x4
scénario de test s'exécute en environ 40 secondes sur TIO.
Explication:
Ŝ # Get all possible ways to sum to the (first) implicit input
# i.e. 8 → [[1,1,1,1,1,1,1,1],[1,1,1,1,1,1,2],[1,1,1,1,1,3],[1,1,1,1,2,2],[1,1,1,1,4],[1,1,1,2,3],[1,1,1,5],[1,1,2,2,2],[1,1,2,4],[1,1,3,3],[1,1,6],[1,2,2,3],[1,2,5],[1,3,4],[1,7],[2,2,2,2],[2,2,4],[2,3,3],[2,6],[3,5],[4,4],[8]]
ʒ23yåP} # Only leave those consisting of 2s and/or 3s
# → [[2,2,2,2],[2,3,3]]
€œ # For each: get all permutations
€` # Flatten this list of lists once
Ù # And uniquify it (leaving all possible distinct rows of bricks)
# → [[2,2,2,2],[3,3,2],[3,2,3],[2,3,3]]
ε } # For each:
.¥ # Get the cumulative sum
¦¨ # With the leading 0 and trailing first input removed
# → [[2,4,6],[3,6],[3,5],[2,5]]
Iи # Repeat this list the second input amount of times
# i.e. 3 → [[2,4,6],[3,6],[3,5],[2,5],[2,4,6],[3,6],[3,5],[2,5],[2,4,6],[3,6],[3,5],[2,5]]
I.Æ # Get all combinations of lists the size of the second input
Ù # And uniquify the result (leaving all possible distinct walls)
# → [[[2,4,6],[3,6],[3,5]],[[2,4,6],[3,6],[2,5]],[[2,4,6],[3,6],[2,4,6]],[[2,4,6],[3,6],[3,6]],[[2,4,6],[3,5],[2,5]],[[2,4,6],[3,5],[2,4,6]],[[2,4,6],[3,5],[3,6]],[[2,4,6],[3,5],[3,5]],[[2,4,6],[2,5],[2,4,6]],[[2,4,6],[2,5],[3,6]],[[2,4,6],[2,5],[3,5]],[[2,4,6],[2,5],[2,5]],[[2,4,6],[2,4,6],[3,6]],[[2,4,6],[2,4,6],[3,5]],[[2,4,6],[2,4,6],[2,5]],[[2,4,6],[2,4,6],[2,4,6]],[[3,6],[3,5],[2,5]],[[3,6],[3,5],[2,4,6]],[[3,6],[3,5],[3,6]],[[3,6],[3,5],[3,5]],[[3,6],[2,5],[2,4,6]],[[3,6],[2,5],[3,6]],[[3,6],[2,5],[3,5]],[[3,6],[2,5],[2,5]],[[3,6],[2,4,6],[3,6]],[[3,6],[2,4,6],[3,5]],[[3,6],[2,4,6],[2,5]],[[3,6],[2,4,6],[2,4,6]],[[3,6],[3,6],[3,5]],[[3,6],[3,6],[2,5]],[[3,6],[3,6],[2,4,6]],[[3,6],[3,6],[3,6]],[[3,5],[2,5],[2,4,6]],[[3,5],[2,5],[3,6]],[[3,5],[2,5],[3,5]],[[3,5],[2,5],[2,5]],[[3,5],[2,4,6],[3,6]],[[3,5],[2,4,6],[3,5]],[[3,5],[2,4,6],[2,5]],[[3,5],[2,4,6],[2,4,6]],[[3,5],[3,6],[3,5]],[[3,5],[3,6],[2,5]],[[3,5],[3,6],[2,4,6]],[[3,5],[3,6],[3,6]],[[3,5],[3,5],[2,5]],[[3,5],[3,5],[2,4,6]],[[3,5],[3,5],[3,6]],[[3,5],[3,5],[3,5]],[[2,5],[2,4,6],[3,6]],[[2,5],[2,4,6],[3,5]],[[2,5],[2,4,6],[2,5]],[[2,5],[2,4,6],[2,4,6]],[[2,5],[3,6],[3,5]],[[2,5],[3,6],[2,5]],[[2,5],[3,6],[2,4,6]],[[2,5],[3,6],[3,6]],[[2,5],[3,5],[2,5]],[[2,5],[3,5],[2,4,6]],[[2,5],[3,5],[3,6]],[[2,5],[3,5],[3,5]],[[2,5],[2,5],[2,4,6]],[[2,5],[2,5],[3,6]],[[2,5],[2,5],[3,5]],[[2,5],[2,5],[2,5]]]
ε # Map all walls `y` to:
ø # Zip/transpose; swapping rows and columns
yí # Reverse each row in a wall `y`
ø # Also zip/transpose those; swapping rows and columns
‚ # Pair both
€ # For both:
€ # For each column:
ü # For each pair of bricks in a column:
Q # Check if they are equal to each other (1 if truthy; 0 if falsey)
O # Then take the sum of these checked pairs for each column
O # Take the sum of that entire column
_ # Then check which sums are exactly 0 (1 if 0; 0 if anything else)
P # And check for which walls this is only truthy by taking the product
}O # After the map: sum the resulting list
# (and output it implicitly as result)
2x1
ou3x1
? La sortie est-elle également à4x1
zéro?