Alternative (simpler?) solution to checking the X pattern in part 2: extract the diagonals into a 2x3 matrix, laminate it with its reverse, then check if exactly 2 rows are equal to 'MAS'.
Super cool 😁 fun to see how differently this can be approached. I was also inspired by dzaima's solution, I have a video of mine on my channel if that's interesting
The fact that the windows function in BQN signals an error if the list is shorter than the length of the list is a clear design bug. The definition should be "returns the list of all k element contiguous sublists", which of course implies it returns an empty list if k is bigger than the length. Instead the current definition seems to be "returns the list of all k element contiguous sublists if there are any and raises an error otherwise". The fact that the definition is given by cases is a bad sign, if you ask me. In fact, I'd go as far as suggesting that of the current definition of windows is kept as is, the find function should also error if the search string is longer than the string you search in, you know, for consistency.
Just wrote this up, hope it helps: mlochbaum.github.io/BQN/try.html#code=TG9nIOKGkCB74oCiU2hvdyDwnZWo4oC/8J2VqX0KCiJtIiBMb2cgbSDihpAgM+KAvzPipYrihpU5CkQg4oaQICgr4oycwrTihpXCqOKImOKJoiniirjiipQKCiMgU3RlcCBieSBTdGVwCiJyYW5nZSBvZiBlYWNoIGRpbWVuc3Rpb24iIExvZyDihpXCqOKJoiBtCiJvdXRlciBwcm9kIHN1bSIgTG9nICgr4oycwrTihpXCqOKImOKJoiltCiJncm91cCIg4oC/ICgoK+KMnMK04oaVwqjiiJjiiaIp4oq44oqUIG0p
Alternative (simpler?) solution to checking the X pattern in part 2: extract the diagonals into a 2x3 matrix, laminate it with its reverse, then check if exactly 2 rows are equal to 'MAS'.
Super cool 😁 fun to see how differently this can be approached. I was also inspired by dzaima's solution, I have a video of mine on my channel if that's interesting
The fact that the windows function in BQN signals an error if the list is shorter than the length of the list is a clear design bug. The definition should be "returns the list of all k element contiguous sublists", which of course implies it returns an empty list if k is bigger than the length. Instead the current definition seems to be "returns the list of all k element contiguous sublists if there are any and raises an error otherwise". The fact that the definition is given by cases is a bad sign, if you ask me.
In fact, I'd go as far as suggesting that of the current definition of windows is kept as is, the find function should also error if the search string is longer than the string you search in, you know, for consistency.
Where can I find more about that diagonals function, while not bqn I tried solving it declaratively but the diagonals broke me.
Just wrote this up, hope it helps: mlochbaum.github.io/BQN/try.html#code=TG9nIOKGkCB74oCiU2hvdyDwnZWo4oC/8J2VqX0KCiJtIiBMb2cgbSDihpAgM+KAvzPipYrihpU5CkQg4oaQICgr4oycwrTihpXCqOKImOKJoiniirjiipQKCiMgU3RlcCBieSBTdGVwCiJyYW5nZSBvZiBlYWNoIGRpbWVuc3Rpb24iIExvZyDihpXCqOKJoiBtCiJvdXRlciBwcm9kIHN1bSIgTG9nICgr4oycwrTihpXCqOKImOKJoiltCiJncm91cCIg4oC/ICgoK+KMnMK04oaVwqjiiJjiiaIp4oq44oqUIG0p