Advertisement
Toxotsist

task 1

Feb 25th, 2021
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. import traceback
  2.  
  3.  
  4. def opposite_house(address, n):
  5.     i = 0
  6.     street = []
  7.     for i in range(2 * n):
  8.         i += 1
  9.         street.append(i)
  10.     print(street)
  11.     print(2 * n - street.index(address))
  12.     return (2 * n - street.index(address))
  13.  
  14.  
  15. # Тесты
  16. try:
  17.     assert opposite_house(1, 3) == 6
  18.     assert opposite_house(3, 3) == 4
  19.     assert opposite_house(2, 3) == 5
  20.     assert opposite_house(3, 5) == 8
  21.     assert opposite_house(7, 11) == 16
  22. except AssertionError:
  23.     print("TEST ERROR")
  24.     traceback.print_exc()
  25. else:
  26.     print("TEST PASSED")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement