Last active
April 17, 2024 21:44
-
-
Save kaapstorm/7abab0bd1cbdccec9846f62046e0f174 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
#!/usr/bin/env python3 | |
import sys | |
from collections import Counter | |
num_to_word = { | |
3: 'three', | |
4: 'four', | |
5: 'five', | |
6: 'six', | |
7: 'seven', | |
} | |
def get_arrow(ee_int, nn_int, rr_int): | |
ee = num_to_word[ee_int] | |
nn = num_to_word[nn_int] | |
rr = num_to_word[rr_int] | |
return f"in this arrow there are {ee} e's, {nn} n's, and {rr} r's" | |
def solve(): | |
for ee in range(4, 8): | |
for nn in range(3, 8): | |
for rr in range(5, 8): | |
arrow = get_arrow(ee, nn, rr) | |
c = Counter(arrow) | |
if (c['e'], c['n'], c['r']) == (ee, nn, rr): | |
return arrow | |
if __name__ == '__main__': | |
print(solve()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Recursive solution with even fewer iterations. Requires a trick to prevent infinite recursion/no solution.