import random
import math
import sympy

from sympy import latex, fraction, Symbol, Rational
localid =11181500100000

letter=["a","b","c","d"]

n=[0,0,0,0,0,0]
m=[0,0,0,0,0]
f = open("111815001.tex","w") #opens file with name of "test.txt"



for x in range(0, 1000):
  localid = localid +1
  writewrong=["\correctchoice{\(","\wrongchoice{\(","\wrongchoice{\(","\wrongchoice{\("]
  
  for count in range (0,5):
    n[count]=random.randint(-20, 20)
  m[1]=n[4]-n[2]
  m[2]=n[3]-n[1]
  
  m[3]=n[2]-n[1]
  m[4]=n[4]-n[3]
 


  if n[2]==n[4]:
    letter[0]='undefined'
    letter[2]=latex(Rational(-m[3],m[2]))
    letter[3]=latex(Rational(-m[4],m[3]))
    letter[1]=latex(Rational(m[4],m[3]))
  else:
     
     letter[0]=latex(Rational(m[1],m[2]))
     letter[1]=latex(Rational(-m[1],m[2]))
     letter[2]=latex(Rational(-m[2],m[1]))
     letter[3]=latex(Rational(m[2],m[1]))
     zz=random.randint(1,6)
     if zz==1:
       letter[1]=latex(Rational(m[4],m[3]))
     elif zz==2:
       letter[2]=latex(Rational(m[4],m[3]))
     elif zz==3:
       letter[3]=latex(Rational(m[4],m[3]))
       
     
     

     n[5]=random.randint(0,10)
     
  if n[2]==n[4]:
    letter[0]='undefined'   
  elif n[5]==8:
    zz=random.randint(1,3)
    letter[zz]='undefined'
  

    
  if(len(letter)==4):
    for z in range (0, 4):
      

 
    random.shuffle(writewrong)
    f.write("\n\n\n")
    f.write("\\element{slope}{")
    f.write("\n")
    f.write("\\begin{question}{")
    f.write(str(localid))
    f.write("}")
    f.write("\n")
    f.write("Find the slope using points: (")
    f.write(str(n[1]))
    f.write(",")
    f.write(str(n[2]))
    f.write(") and (")
    f.write(str(n[3]))
    f.write(",")
    f.write(str(n[4]))
    f.write("):")
 
    f.write("\n")
    f.write("\\begin{choiceshoriz}")
    f.write("\n")
  
    for y in range(0, 4):
      f.write("\n")
      f.write(writewrong[y])
      f.write("\)}")
    
    f.write("\n")
    f.write("\\end{choiceshoriz}")
    f.write("\n")
    f.write("\\end{question}")
    f.write("\n")
    f.write("}")
f.close() 

writewrong[z]=writewrong[z]+str(letter[z])