fork download
  1. n = int(input())
  2.  
  3. for i in range(1, n + 1):
  4. i = str(i)
  5. dict = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8}
  6. letter = ''
  7. digit = ''
  8. for j in i:
  9. if j.isdigit():
  10. digit = j
  11. else:
  12. letter = j
  13.  
  14. letter = int(dict[letter])
  15. digit = int(digit)
  16. sum = 0
  17.  
  18. for k in range(1, 9):
  19. for m in range(1, 9):
  20. if (abs(letter - k) == 1 and abs(digit - m) == 2) or (abs(letter - k) == 2 and abs(digit - m) == 1):
  21. sum += 1
  22. print(sum)
Runtime error #stdin #stdout #stderr 0.02s 28384KB
stdin
3
a1
d4
g6
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 14, in <module>
    letter = int(dict[letter])
KeyError: ''