2.9 KiB
Notes
- i guess let's generate all possible? and short circuit when they are not matching mask
- wrong answer on input
- huh, nope this looks good:
- let's check this : for line ??????#???????? blocks [7 2] matches 21
- or this for line ?????.??#????? blocks [3 3 2 1] matches 3
- this for line ??..??#?????#?##? blocks [1 1 1 1 4] matches 15
- for line ?#??#??#???.??.??.? blocks [1 2 3 1 1 1] matches 20
- for line ???????#??.????####? blocks [1 1 1 1 1 6] matches 58
- well, maybe overnight will calculate.
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] #.#.#..#.#.######… #.#.#..#.#..######.. #.#.#..#.#…######. #.#.#..#.#….###### #.#.#..#…#.######. #.#.#..#…#..###### #.#.#..#….#.###### #.#..#.#.#.######… #.#..#.#.#..######.. #.#..#.#.#…######. #.#..#.#.#….###### #.#..#.#…#.######. #.#..#.#…#..###### #.#..#.#….#.###### #.#….#.#.#.######. #.#….#.#.#..###### #.#….#.#..#.###### #..#.#.#.#.######… #..#.#.#.#..######.. #..#.#.#.#…######. #..#.#.#.#….###### #..#.#.#…#.######. #..#.#.#…#..###### #..#.#.#….#.###### #..#…#.#.#.######. #..#…#.#.#..###### #..#…#.#..#.###### #…#..#.#.#.######. #…#..#.#.#..###### #…#..#.#..#.###### #….#.#.#.#.######. #….#.#.#.#..###### #….#.#.#..#.###### .#.#.#.#.#.######… .#.#.#.#.#..######.. .#.#.#.#.#…######. .#.#.#.#.#….###### .#.#.#.#…#.######. .#.#.#.#…#..###### .#.#.#.#….#.###### .#.#…#.#.#.######. .#.#…#.#.#..###### .#.#…#.#..#.###### .#..#..#.#.#.######. .#..#..#.#.#..###### .#..#..#.#..#.###### .#…#.#.#.#.######. .#…#.#.#.#..###### .#…#.#.#..#.###### ..#.#..#.#.#.######. ..#.#..#.#.#..###### ..#.#..#.#..#.###### ..#..#.#.#.#.######. ..#..#.#.#.#..###### ..#..#.#.#..#.###### …#.#.#.#.#.######. …#.#.#.#.#..###### …#.#.#.#..#.######
well, maybe overnight will calculate.
but i guess i needed to check whether blocks are 'always' taking full width then i'll only need to calculate once, and then multiply
for example
2023/12/12 20:40:41 699 : for line ??#?????#???.? ???#?????#???.????#?????#???.????#?????#???.????#?????#???.? blocks [3 1 2 1 3 1 2 1 3 1 2 1 3 1 2 1 3 1 2 1] matches 38294856
??#?? ???#?? ?.? 3,1,2,1 - 10+3 = 13
lowest s ###.#.##.#….. - plenty of space for additional