summaryrefslogtreecommitdiff
path: root/sites/pmikkelsen.com/APL-and-J
diff options
context:
space:
mode:
Diffstat (limited to 'sites/pmikkelsen.com/APL-and-J')
-rw-r--r--sites/pmikkelsen.com/APL-and-J/Date-puzzle-solver.md28
1 files changed, 14 insertions, 14 deletions
diff --git a/sites/pmikkelsen.com/APL-and-J/Date-puzzle-solver.md b/sites/pmikkelsen.com/APL-and-J/Date-puzzle-solver.md
index d58ea01..16dea25 100644
--- a/sites/pmikkelsen.com/APL-and-J/Date-puzzle-solver.md
+++ b/sites/pmikkelsen.com/APL-and-J/Date-puzzle-solver.md
@@ -10,7 +10,7 @@ We decided to write a program to find solutions.
## The program
-The program is written using Dyalog APL, and it finds all possible solutions (for all days) in about 14 seconds on my laptop.
+The program is written using Dyalog APL, and it finds all possible solutions (for all days) in about 30 seconds on my laptop.
The `Solve` function finds all solutions and stores them in the global variable `SOLUTIONS`. The `Date` function finds all solutions for a given date (by finding all possible solutions and filtering them).
@@ -27,7 +27,7 @@ The `Solve` function finds all solutions and stores them in the global variable
variants←{
v←,⍵∘{size↑⍵↓(-size)↑⍺}¨⍳1+size-⍴⍵
v,←⌽¨v
- v←∪(⌽⍉¨v),(⍉⌽¨v),(⌽⊖¨v),v
+ v←∪(⌽⍤⍉¨v),(⍉⍤⌽¨v),(⌽⍤⊖¨v),v
v←↑,¨v
v⌿⍨~∨/v∧⍤1⊢board≠' '
}
@@ -72,18 +72,18 @@ The `Solve` function finds all solutions and stores them in the global variable
## Example run
- Date 7 12
- ┌───────┬───────┬───────┬───────┐
- │CCAAAAx│CCFFFHx│AACEEEx│AACEEEx│
- │ CAHBBx│ CFDFHx│ ACCCEx│ ACCCEx│
- │DCCHBBB│BCCDHHE│DABBCEH│DAGGCEB│
- │DDHH GG│BBDD HE│DABB HH│DAGG BB│
- │EDFHFGG│BBDAEEE│DDBGGGH│DDGGHBB│
- │EDFFFGG│GGGAAAA│FDFGGGH│FDFHHHH│
- │EEExxxx│GGGxxxx│FFFxxxx│FFFxxxx│
- └───────┴───────┴───────┴───────┘
-
-Each nested array represents one solution. An `x` indicates the parts of the board that doesn't exist, and each piece is represented by an uppercase letter from `A` to `H`. So, today has 4 different solutions :)
+ Date 10 6
+┌───────┬───────┬───────┬───────┬───────┬───────┬───────┐
+│HHHHBBx│GGAAAAx│GGAAAAx│GGAAAAx│GGAAAAx│GGAAAAx│GGAAAAx│
+│DDH BBx│GGF FAx│GGF FAx│GGA DDx│GGA DDx│GGA DDx│GGA DDx│
+│CDDDB A│GGFFF H│GGFFF H│GGDDD C│GGDDD C│GGDDD H│GGDDD H│
+│CCCAAAA│EEECBHH│EEEDBHH│HHHHCCC│HEEECCC│CEEEFFH│CCBBFFH│
+│EFCFGGG│ECCCBBH│ECCDBBH│EFHFCBB│HFFECBB│CCCEFHH│ECBBFHH│
+│EFFFGGG│ECDDBBH│ECDDBBH│EFFFBBB│HHFEBBB│BBCEFFH│ECCBFFH│
+│EEExxxx│DDDxxxx│CCDxxxx│EEExxxx│HFFxxxx│BBBxxxx│EEExxxx│
+└───────┴───────┴───────┴───────┴───────┴───────┴───────┘
+
+Each nested array represents one solution. An `x` indicates the parts of the board that doesn't exist, and each piece is represented by an uppercase letter from `A` to `H`. So, October 6th has different solutions :)
[1]: https://images.pmikkelsen.com/date-puzzle.png