From 612fb5f38eaddb69bc89d388a5eaca0646a6fb01 Mon Sep 17 00:00:00 2001 From: Stephen McQuay Date: Thu, 25 Oct 2012 21:33:35 -0700 Subject: [PATCH] part 1 --- .hgignore | 4 +++ bin/p1.py | 3 ++ maze/__init__.py | 17 ++++++++++++ samples/maze.txt | 72 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 96 insertions(+) create mode 100644 .hgignore create mode 100644 bin/p1.py create mode 100644 maze/__init__.py create mode 100644 samples/maze.txt diff --git a/.hgignore b/.hgignore new file mode 100644 index 0000000..1423a41 --- /dev/null +++ b/.hgignore @@ -0,0 +1,4 @@ +.*.swp$ +.*.pyc$ + +tags$ diff --git a/bin/p1.py b/bin/p1.py new file mode 100644 index 0000000..5d045cd --- /dev/null +++ b/bin/p1.py @@ -0,0 +1,3 @@ +from maze import make_maze + +print make_maze() diff --git a/maze/__init__.py b/maze/__init__.py new file mode 100644 index 0000000..15237aa --- /dev/null +++ b/maze/__init__.py @@ -0,0 +1,17 @@ +import random + + +def make_maze(size=8): + r = [[[0] * size] * size] * size + for i in xrange(size): + for j in xrange(size): + r[i][j] = [random.randint(0, 1) for i in xrange(size)] + r[0][0][0] = 1 + r[7][7][7] = 1 + return r + + +def parse_maze(filename): + f = open(filename, 'r') + t = f.read() + return [[int(j) for j in i.split()] for i in t.split('\n\n') if i] diff --git a/samples/maze.txt b/samples/maze.txt new file mode 100644 index 0000000..85c6c78 --- /dev/null +++ b/samples/maze.txt @@ -0,0 +1,72 @@ +1 0 0 0 1 0 0 0 +0 1 1 1 1 1 0 0 +0 1 0 1 1 0 0 0 +0 1 1 1 0 0 1 1 +1 1 0 0 0 1 0 0 +1 1 1 0 0 1 1 0 +1 0 1 0 0 1 0 1 +0 0 1 0 1 0 1 0 + +1 0 0 0 0 1 0 0 +1 1 0 0 0 1 0 1 +1 0 1 0 1 1 1 1 +0 0 0 0 1 0 0 1 +0 0 0 0 1 0 1 1 +0 0 0 1 0 0 1 0 +1 0 1 0 1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