diff options
author | Peter Ward <peteraward@gmail.com> | 2010-09-10 09:39:01 +1000 |
---|---|---|
committer | Peter Ward <peteraward@gmail.com> | 2010-09-10 09:39:01 +1000 |
commit | 56c61e0850478e3aa31b4e559acabcd0f3c4f0d2 (patch) | |
tree | 57a4465a557bca5d9ff90b2c1ad32f4351f42a4f | |
parent | 2ee7eaba813ffaca6a3715d8bc7cf25d854af835 (diff) |
Added input processing.
-rw-r--r-- | processbot.py | 23 |
1 files changed, 23 insertions, 0 deletions
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 + |