Created
June 10, 2022 00:33
-
-
Save HomemadeToast57/58e731c7c75427b1fd3c4b352cbd76c9 to your computer and use it in GitHub Desktop.
Animal Well Puzzle
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
# Python code written by @HomemadeToast57 (twitter) for the Animal Well puzzle :). Thank you to the devs and the community for this wonderful experience! | |
import numpy as np | |
# string given at https://animalwell.net/fountain | |
string = "amtmc xumuacm fcze mtnd ysi wehlnd vtgowqkw oqsaa diqgewa hhrpsi cq pf pftqd uh gijdugr" | |
# key found in trailer for the game | |
key = "waterfall" | |
# result array | |
res = [] | |
# total characters in string (helped find divisors for matrices) | |
letterCount = 0 | |
# checked the values of sum of all characters | |
stringVal = 0 | |
keyVal = 0 | |
# convert each char to int (A->1, B->2, C->3, ... Z->26) | |
for char in string: | |
if char != " ": | |
stringVal += ord(char) - 96 | |
res.append(ord(char) - 96) | |
letterCount += 1 | |
else: | |
res.append(" ") | |
letterCount += 1 | |
# take sum of char values | |
for char in key: | |
keyVal += ord(char) - 96 | |
print("KEY VAL = ", keyVal) | |
print("STRING VAL = ", stringVal) | |
print(res) | |
print(letterCount) | |
# waterfall - [23, 1, 20, 5, 18, 6, 1, 12, 12] | |
# result for prev code execution | |
""" OG string to arr of num | |
[1, 13, 20, 13, 3, ' ', 24, 21, 13, 21, 1, 3, 13, ' ', 6, 3, 26, 5, ' ', 13, 20, 14, 4, ' ', 25, 19, 9, ' ', 23, 5, 8, 12, 14, 4, ' ', 22, 20, 7, 15, 23, 17, 11, 23, ' ', 15, 17, 19, 1, 1, ' ', 4, 9, 17, 7, 5, 23, 1, ' ', 8, 8, 18, 16, 19, 9, ' ', 3, 17, ' ', 16, 6, ' ', 16, 6, 20, 17, 4, ' ', 21, 8, ' ', 7, 9, 10, 4, 21, 7, 18] | |
""" | |
# build array of transposed matrices (col <-> row) and return the array | |
def buildMatrices(arr): | |
div = [1, 3, 29, 87] | |
matrices = [] | |
# testing matrix sizes for (1x87, 87x1, 3x29, 29x3) and storing transpose matrix in matrices array | |
for d in div: | |
print("\n") | |
data = np.array(arr) | |
shape = (d, 87//d) | |
data = data.reshape(shape) # enforce size in new matrix | |
# print(d) | |
print(data.transpose().flatten()) | |
print("\n") | |
matrices.append(data.transpose().flatten()) # transpose (row <-> col) and flatten matrix then add to matrices list | |
return matrices | |
matrices = buildMatrices(res) # get the transpose flattened matrices | |
resStrings = [] | |
# convert back to strings | |
for matrix in matrices: | |
string = "" | |
for num in matrix: | |
if num != " ": | |
string = string + chr(int(num)+96) | |
else: | |
string = string + " " | |
resStrings.append(string) | |
print("RESSTRINGS", resStrings) | |
print("\n\n") | |
# print strings | |
for r in resStrings: | |
print(r) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment