NIKOLAY_TETUS

8 задание

Jun 22nd, 2021 (edited)
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.78 KB | None | 0 0
  1. def toOct(n):
  2.     tempStr = ""
  3.     while n > 0:
  4.         tempStr += str(n % 8)
  5.         n //= 8
  6.        
  7.     outStr = tempStr[::-1]
  8.     return outStr
  9.  
  10. def checkNumber(strNumber):
  11.     for i in range(0, 10):
  12.         if strNumber.count(str(i)):
  13.             return False
  14.     for i in range(0, len(strNumber) - 3):
  15.         if int(strNumber[i]) % 2 == 0 and int(strNumber[i + 1]) % 2 == 0 and int(strNumber[i + 2]) % 2 == 1 and int(strNumber[i + 3]) % 2 == 1:
  16.             return False
  17.         if int(strNumber[i]) % 2 == 1 and int(strNumber[i + 1]) % 2 == 1 and int(strNumber[i + 2]) % 2 == 0 and int(strNumber[i + 3]) % 2 == 0:
  18.             return False
  19. #print(toOct(999999))
  20. score = 0
  21. for i in range(262144, 2097151):
  22.     if checkNumber(toOct(i)):
  23.         score += 1
  24.  
  25. print(score)
  26.  
Add Comment
Please, Sign In to add comment