Advertisement
UF6

Final Problem for 3

UF6
Mar 28th, 2016
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | None | 0 0
  1. import time
  2. import math
  3. startingnumber = 0
  4. endnumber = 100000000
  5. startinterger=1
  6. def threealterative(number):
  7.     string = str(number)
  8.     length = len(string)
  9.     for i in range (length-2):
  10.         if (string [i] == string[i+1]) and (string [i] == string [i+2]):
  11.             return True
  12.     return false
  13.  
  14. def dighitsthree(number):
  15.     subs = [000,111,222,333,444,555,666,777,888,999]
  16.     string = str(number)
  17.     for sub in subs:
  18.         if str(sub) in string:
  19.             return true
  20.     return false
  21.  
  22. time = time.clock()
  23. for startinterger in range( 1,endnumber):
  24.     if not threealterative(startinterger):
  25.         startingnumber = startingnumber + (1/startinterger)
  26. time2 = time.clock()
  27. print (time.clock() - time, ' seconds ', endnumber, ' cycling')
  28. print (startingnumber)
  29.  
  30. #250.32544094291302  seconds  100000000  cycling
  31. #18.537367351280075
  32.  
  33. #http://www.tutorialspoint.com/python/python_date_time.htm
  34. #https://docs.python.org/3.0/library/time.html
  35. #https://pymotw.com/2/datetime/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement