95 lines
2.4 KiB
Org Mode
95 lines
2.4 KiB
Org Mode
#+title: Notes
|
|
* i guess let's generate all possible? and short circuit when they are not matching mask
|
|
how do i generate all possible?
|
|
|
|
i take length of the mask, that's max size
|
|
then for each step, either put . or put n # from the input.
|
|
|
|
add to current string, and do 2 recursive calls, one with diminished 'queue', one with same
|
|
* wrong answer on input
|
|
it's too high
|
|
|
|
and log shows:
|
|
|
|
2023/12/12 15:07:52 for line ???#?.?#?#.?#???#..? blocks [4 4 5 1] matches 2
|
|
|
|
and it should be 0
|
|
** huh, nope this looks good:
|
|
testMask := "???#?.?#?#.?#???#..?"
|
|
testBlocks := []int{4,4,5,1}
|
|
testVariants := generatePermutations("", len(testMask), testBlocks, 14, testMask)
|
|
fmt.Printf("for mask %s and blocks %+v\n", testMask, testBlocks)
|
|
fmt.Println(testVariants)
|
|
|
|
for mask ???#?.?#?#.?#???#..? and blocks [4 4 5 1]
|
|
[####..####..#####..# .####.####..#####..#]
|
|
** let's check this : for line ??????#???????? blocks [7 2] matches 21
|
|
** or this for line ?????.??#????? blocks [3 3 2 1] matches 3
|
|
looks ok
|
|
** this for line ??..??#?????#?##? blocks [1 1 1 1 4] matches 15
|
|
looks good
|
|
** for line ?#??#??#???.??.??.? blocks [1 2 3 1 1 1] matches 20
|
|
seems ok
|
|
** for line ???????#??.????####? blocks [1 1 1 1 1 6] matches 58
|
|
bingo?
|
|
|
|
for mask ???????#??.????####? and blocks [1 1 1 1 1 6]
|
|
#.#.#..#.#.######...
|
|
#.#.#..#.#..######..
|
|
#.#.#..#.#...######.
|
|
#.#.#..#.#....######
|
|
#.#.#..#...#.######.
|
|
#.#.#..#...#..######
|
|
#.#.#..#....#.######
|
|
#.#..#.#.#.######...
|
|
#.#..#.#.#..######..
|
|
#.#..#.#.#...######.
|
|
#.#..#.#.#....######
|
|
#.#..#.#...#.######.
|
|
#.#..#.#...#..######
|
|
#.#..#.#....#.######
|
|
#.#....#.#.#.######.
|
|
#.#....#.#.#..######
|
|
#.#....#.#..#.######
|
|
#..#.#.#.#.######...
|
|
#..#.#.#.#..######..
|
|
#..#.#.#.#...######.
|
|
#..#.#.#.#....######
|
|
#..#.#.#...#.######.
|
|
#..#.#.#...#..######
|
|
#..#.#.#....#.######
|
|
#..#...#.#.#.######.
|
|
#..#...#.#.#..######
|
|
#..#...#.#..#.######
|
|
#...#..#.#.#.######.
|
|
#...#..#.#.#..######
|
|
#...#..#.#..#.######
|
|
#....#.#.#.#.######.
|
|
#....#.#.#.#..######
|
|
#....#.#.#..#.######
|
|
.#.#.#.#.#.######...
|
|
.#.#.#.#.#..######..
|
|
.#.#.#.#.#...######.
|
|
.#.#.#.#.#....######
|
|
.#.#.#.#...#.######.
|
|
.#.#.#.#...#..######
|
|
.#.#.#.#....#.######
|
|
.#.#...#.#.#.######.
|
|
.#.#...#.#.#..######
|
|
.#.#...#.#..#.######
|
|
.#..#..#.#.#.######.
|
|
.#..#..#.#.#..######
|
|
.#..#..#.#..#.######
|
|
.#...#.#.#.#.######.
|
|
.#...#.#.#.#..######
|
|
.#...#.#.#..#.######
|
|
..#.#..#.#.#.######.
|
|
..#.#..#.#.#..######
|
|
..#.#..#.#..#.######
|
|
..#..#.#.#.#.######.
|
|
..#..#.#.#.#..######
|
|
..#..#.#.#..#.######
|
|
...#.#.#.#.#.######.
|
|
...#.#.#.#.#..######
|
|
...#.#.#.#..#.######
|