Last active
          February 6, 2022 21:12 
        
      - 
      
- 
        Save megahomyak/b020d5d0e7bbbc174cc12bd57664619e to your computer and use it in GitHub Desktop. 
    Finds coefficients for quadratic equations using bruteforce. Use only when you cannot find them by yourself
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | known_points = [(-2, -1), (-3, 1), (1, 5)] | |
| step = 0.25 | |
| max_value = 3 | |
| a = -max_value | |
| while a <= max_value: | |
| b = -max_value | |
| while b <= max_value: | |
| c = -max_value | |
| while c <= max_value: | |
| if all( | |
| y == (a * (x ** 2) + b * x + c) | |
| for x, y in known_points | |
| ): | |
| print(f"{a=}, {b=}, {c=}") | |
| exit() | |
| c += step | |
| b += step | |
| a += step | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment