From 56c61e0850478e3aa31b4e559acabcd0f3c4f0d2 Mon Sep 17 00:00:00 2001 From: Peter Ward Date: Fri, 10 Sep 2010 09:39:01 +1000 Subject: Added input processing. --- processbot.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/processbot.py b/processbot.py index 3bd3038..15e7de0 100644 --- a/processbot.py +++ b/processbot.py @@ -1,3 +1,4 @@ +import sys import subprocess class BotWrapper(object): @@ -28,3 +29,25 @@ class BotWrapper(object): output = proc.stdout.read() return output.strip() +def process_input(fp=sys.stdin): + width, height, letter = fp.readline().split() + + width = int(width) + height = int(height) + letter = letter.upper() + + position = None + + board = [] + for i in xrange(height): + row = fp.readline()[:-1] + assert len(row) == width + + pos = row.find(letter) + if pos >= 0: + position = (pos, i) + + board.append(list(row)) + + return board, position + -- cgit v1.2.3