Advertisement
nq1s788

8 (один ноль и четные вокруг нуля)

Jan 12th, 2025
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. #8й https://kpolyakov.spb.ru/school/ege/gen.php?action=viewVar&answers=on&varId=7
  2. sl = '012345678'
  3. even = '02468'
  4. num = 1
  5. answ = 0
  6. for q in '12345678':
  7.     for w in sl:
  8.         for e in sl:
  9.             for r in sl:
  10.                 for t in sl:
  11.                     s = q + w + e + r + t
  12.                     if s.count('0') != 1:
  13.                         continue
  14.                     nul = s.index('0') #s.find('0')
  15.                     #for i in range(5): найти индекс через цикл
  16.                     #    if s[i] == '0':
  17.                     #        nul = i
  18.                     if nul == 4 and s[nul - 1] in even:
  19.                         answ += 1
  20.                     elif nul < 4 and s[nul - 1] in even and s[nul + 1] in even:
  21.                         answ += 1
  22. print(answ)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement