• IDK is a bug or site interpreter limitations

 

From: http://www.checkio.org/mission/pawn-brotherhood/solve/

HTTP_USER_AGENT:

Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:40.0) Gecko/20100101 Firefox/40.0

Hi I solved this quest in Python 2.7.6, [GCC 4.8.2] on linux2 and my implementation works perfectly (of course with pawns only centered, I realized if pawns will be placed on margins, i will get index range errors), but on site, i get an error on translation, I am not very skillful in python, but I would like to know is this a bug or site interpreter limitations

here is my solutions

from string import maketrans
def safe_pawns(pawns):
    safe = 0
    table = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], 
             [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0] ]
    inp, out = 'abcdefgh', '01234567'
    transtab = maketrans(inp, out)

    for k in pawns:        
        table[int(k[0].translate(transtab))][int(k[1]) - 1] = 1

    for x in range(len(table)):
        for y in range(len(table[x])):
            if table[x][y] == 1:
                if table[x - 1][y - 1] == 1 or table[x + 1][y - 1] == 1 : 
                    safe += 1   
    return safe

Thanks in advance. Have a nice day!

6