From 8505476cbb3f9748194a7dbe4d1e98634a4f2354 Mon Sep 17 00:00:00 2001 From: Stephen McQuay Date: Thu, 25 Oct 2012 22:14:49 -0700 Subject: [PATCH] fixed shallow copy problem --- maze/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/maze/__init__.py b/maze/__init__.py index 90670ef..c59a777 100644 --- a/maze/__init__.py +++ b/maze/__init__.py @@ -1,5 +1,5 @@ import copy -import random +from random import randint class CS235Maze(object): @@ -20,10 +20,11 @@ class CS235Maze(object): def make_maze(size=8): - r = [[[0] * size] * size] * size + r = [] for i in xrange(size): + r.append([]) for j in xrange(size): - r[i][j] = [random.randint(0, 1) for i in xrange(size)] + r[i].append([randint(0, 1) for k in xrange(size)]) r[0][0][0] = 1 r[7][7][7] = 1 return CS235Maze(r, size)