-
Notifications
You must be signed in to change notification settings - Fork 1
/
challengenotes.txt
78 lines (70 loc) · 2.45 KB
/
challengenotes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
datafile = open("equality.txt", "r")
matrix = []
i = 0
for line in datafile:
matrix.append([])
for c in line:
matrix[i].append(c)
i += 1
# this code doesn't give the answer, but I developed it anyway (2 dimensions)
for i in range(len(matrix)):
for j in range(len(matrix)):
if (i > 0 and i < len(matrix)-1 and j > 0 and j < len(matrix[i])-1):
if not(matrix[i][j].istitle()):
mask = []
for m in [0,1,2]:
mask.append([])
for n in [0,1,2]:
mask[m].append([])
mask[m][n] = matrix[i-1+m][j-1+n].istitle()
if (mask[0][0] and mask[0][1] and mask[0][2] and mask[1][0] and mask[1][2] and mask[2][0] and mask[2][1] and mask[2][2]):
print matrix[i][j]
# this is *almost* working:
for i in range(len(matrix)):
for j in [3,len(matrix[i])-2]:
if matrix[i][j].istitle():
mask = [0,0,0,0,0,0,0]
for n in range(7):
p = n - 3
mask[n] = matrix[i][p].istitle()
print mask
if (mask[0] and mask[1] and mask[2] and mask[4] and mask[5] and mask[6]):
print matrix[i][j]
# well this is kicking *something* out:
for i in range(len(matrix)):
for j in [3,len(matrix[i])-4]:
test = True
for m in [-3,-2,-1,1,2,3]:
test = (test and matrix[i][j+m].istitle())
if (test and not(matrix[i][j].istitle())):
print str(i)+'x'+str(j)+':'+matrix[i][j]
# finally, got this bitch working!
output = ''
for i in range(len(matrix)):
for j in range(3,len(matrix[i])-3):
test = True
try:
test = (test and not(matrix[i][j-4].istitle()))
except:
pass
for m in [-3,-2,-1,1,2,3]:
test = (test and matrix[i][j+m].istitle())
try:
test = (test and not(matrix[i][j+4].istitle()))
except:
pass
if (test and not(matrix[i][j].istitle())):
output += matrix[i][j]
output
# challenge 4
from urllib import *
baseurl = 'http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing='
seednothing = '12345'
for i in range(400):
callurl = baseurl+seednothing
code = urlopen(callurl).read()
print code
if (code != 'Yes. Divide by two and keep going.'):
seednothing = code[len(code)-5:len(code)]
else:
seednothing = str(int(seednothing)/2)