#!/bin/python3 import sys def berechne(): global count, allePositionen, aktPositionen, nextPositionen, bewegung while True: count += 1 allePositionen = allePositionen | aktPositionen for pos in aktPositionen: for bew in bewegung: x = pos[0] y = pos[1] x += bew[0] y += bew[1] if x >=0 and x < n and y >=0 and y < n: nextPositionen.add((x,y)) if (n-1,n-1) in nextPositionen: print(count, end='') return aktPositionen = nextPositionen.difference(allePositionen) if aktPositionen == set(): return -1 n = int(input().strip()) # your code goes here for i in range(1,n): for j in range(1,n): count = 0 allePositionen = { (0,0) } aktPositionen = { (0,0) } nextPositionen = set() bewegung = [(i,j), (j,i), (-i,j), (j,-i), (i,-j), (-j,i), (-i,-j), (-j,-i)] if berechne() == -1: print("-1", end='') if j != n-1: print(' ', end='') print('')