Skip to content

Instantly share code, notes, and snippets.

@escherize
Created June 12, 2019 00:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save escherize/8294a96c7bda6ebd0738c12a78411ca8 to your computer and use it in GitHub Desktop.
Save escherize/8294a96c7bda6ebd0738c12a78411ca8 to your computer and use it in GitHub Desktop.
import numpy as np
a = np.array([[6, 0, 0], # 6 shoes
[2, 2, 2], # 2 shoes, 2 boys, 2 whistles
[0, 1, 3]]) # 1 boy, 3 whistles
b = np.array([30, 20, 13])
[shoe, boy, whistle] = np.linalg.solve(a,b)
print("\nshoe=", shoe, "\nboy=", boy, "\nwhistle=", whistle)
# shoe= 5.0
# boy= 1.0
# whistle= 4.0
print("shoe + boy * whistle = ", shoe + boy * whistle)
# shoe + boy * whistle = 9.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment