PythonDojo / Reversi /

#!/usr/bin/env python
# encoding: utf-8

Created by Coding Dojo on 2013-03-13.
Copyright (c) 2013 __MyCompanyName__. All rights reserved.

def current_player(input):
    return input.strip()[-1]

def parse(input):
    return [line for line in input.split()[:-1]]

def determine_player_positions(input):
    """Return player positions (row, column)"""
    player = current_player(input)
    board = parse(input)
    positions = []
    # board = ["abc", "def", "ghi"]
    for y, row in enumerate(board):
        # (0, "abc"), (1, "def"), (2, "ghi")
        for x, field in enumerate(row):
            # (0, "a"), (1, "b"), (2, "c")
            if field == player:
                positions.append((y, x))
    return positions

def determine_attackable_enemy_positions(input, position):
    return [
        (3, 4),
        (4, 3),

if __name__ == '__main__':
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.