Advertisement
HasteBin0

Python Prime Proposal Tester

Jan 9th, 2018
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.54 KB | None | 0 0
  1. #!/usr/bin/python3
  2. from simple_tools import *
  3.  
  4. NUMBER: int = get_input_advanced(minimum=1)
  5. option: int = get_input_advanced('Record Hits [1], Misses [2], or Both [3]', 1, 3)
  6. padding: int = get_pad_length(NUMBER)
  7.  
  8. # Explanation @ https://youtu.be/Da7vmPuokSE
  9.  
  10. with output('w') as of :
  11.     output_entries(of, NUMBER)
  12.     spinner: Reporter = Reporter(NUMBER)
  13.     for x in range(NUMBER) :
  14.         spinner.add_step()
  15.         sure_prime: bool = is_prime_primitive(x)
  16.         posit_prime: bool = False
  17.         # The hinted Test
  18.         if x == 2 or x == 3 :
  19.             posit_prime = True
  20.         elif x % 2 and x % 3 :
  21.             if (x - 25) % 30 :
  22.                 if (x - 35) % 30 :
  23.                     if (x - 35) % 42 :
  24.                         posit_prime = True
  25.         #
  26.         if option == 1 :
  27.             if sure_prime == posit_prime :
  28.                 out_write_line(of, '({}) sure[{}] ^ posit[{}] = Hit;', pad_value_int(x, padding),
  29.                                str(sure_prime).ljust(5), str(posit_prime).ljust(5))
  30.         elif option == 2 :
  31.             if sure_prime ^ posit_prime :
  32.                 out_write_line(of, '({}) sure[{}] ^ posit[{}] = Miss;', pad_value_int(x, padding),
  33.                                str(sure_prime).ljust(5), str(posit_prime).ljust(5))
  34.         else :
  35.             out_write_line(of, '({}) sure[{}] ^ posit[{}] = {}.', pad_value_int(x, padding), str(sure_prime).ljust(5),
  36.                            str(posit_prime).ljust(5), ('Miss' if sure_prime ^ posit_prime else 'Hit '))
  37.     spinner.stop()
  38.  
  39. stop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement