-
-
Save anonymous/06fb05818ba77ec26295011196109dc2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- my friend tweeted about wordsearches and this possessed | |
-- me to calculate the number of possible positions for a | |
-- word of a given length so here we are | |
-- given a length l and a wordsearch of n by m characters, | |
-- returns the number of possible vectors that a word of | |
-- length l can inhabit. | |
v l n m | |
| l <= min n m = (iw * ih * 8) + 2*(iw * s * 5) + 2*(ih * s * 5) + 4 * (s * s * 3) | |
| (l > sb) | |
&& (l <= lb) = sb * (lb - l + 1) * 2 | |
| otherwise = 0 | |
where | |
s = l - 1 | |
iw = n - 2*s | |
ih = m - 2*s | |
sb = min n m | |
lb = max n m |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment