daily pastebin goal
64%
SHARE
TWEET

number.py

angelboy Dec 8th, 2014 217 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import telnetlib
  2. import time
  3.  
  4. host = "number.quals.seccon.jp"
  5. port = 31337
  6.  
  7. connect = telnetlib.Telnet(host,port)
  8.  
  9. while 1 :
  10.     time.sleep(0.1)
  11.     problem = connect.read_until("number?")
  12.     print problem
  13.     quesion = problem.split()
  14.     number = []
  15.     for i in quesion :
  16.         if i in 'The' :
  17.             break
  18.         i = i.strip(',')
  19.         number.append(i)
  20.     print number
  21.     try :
  22.         number = [ int(i) for i in number]
  23.     except :
  24.         connect.write(response)
  25.         continue
  26.     if 'max' in problem :
  27.         answer = max(number)
  28.         response = str(answer) + "\n"
  29.  
  30.     else :
  31.         answer = min(number)
  32.         response = str(answer) + "\n"
  33.     time.sleep(0.1)
  34.     connect.write(response)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top