Calvin (Deutschbein)
W8Wed: 16 Oct
I would argue lists were the correct way to deal with the annoying part of Wordle.
colors =
colors = "Red", "Orange", "Green", "Cyan", "Blue"
colors = ["Red", "Orange", "Green", "Cyan", "Blue"]
>>> colors = ["Red", "Orange", "Green", "Cyan", "Blue"]
>>> type(colors)
<class 'list'>
>>> colors = ["Red", "Orange", "Green", "Cyan", "Blue"]
>>> type(colors)
<class 'list'>
>>> print(colors)
['Red', 'Orange', 'Green', 'Cyan', 'Blue']
>>> colors = ["Red", "Orange", "Green", "Cyan", "Blue"]
>>> type(colors)
<class 'list'>
>>> print(colors)
['Red', 'Orange', 'Green', 'Cyan', 'Blue']
>>> colors[0]
'Red'
>>> colors = ["Red", "Orange", "Green", "Cyan", "Blue"]
>>> type(colors)
<class 'list'>
>>> print(colors)
['Red', 'Orange', 'Green', 'Cyan', 'Blue']
>>> colors[0]
'Red'
>>> colors[::-1]
['Blue', 'Cyan', 'Green', 'Orange', 'Red']
>>> colors = ["Red", "Orange", "Green", "Cyan", "Blue"]
>>> type(colors)
<class 'list'>
>>> print(colors)
['Red', 'Orange', 'Green', 'Cyan', 'Blue']
>>> colors[0]
'Red'
>>> colors[::-1]
['Blue', 'Cyan', 'Green', 'Orange', 'Red']
>>> colors[-1]
'Blue'
>>> colors = ["Red", "Orange", "Green", "Cyan", "Blue"]
>>> type(colors)
<class 'list'>
>>> print(colors)
['Red', 'Orange', 'Green', 'Cyan', 'Blue']
>>> colors[0]
'Red'
>>> colors[::-1]
['Blue', 'Cyan', 'Green', 'Orange', 'Red']
>>> colors[-1]
'Blue'
>>> colors[::2]
['Red', 'Green', 'Blue']
>>> colors = ["Red", "Orange", "Green", "Cyan", "Blue"]
>>> colors[.5]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: list indices must be integers or slices, not float
>>> CookPVI
[['Alabama', 'R+15', '36.6%', '62.0%', '34.4%', '62.1%'], ['Alaska', 'R+8', '42.8%', '52.8%', '36.6%', '51.3%'], ['Arizona', 'R+2', '49.4%', '49.1%', '44.6%', '48.1%'], ['Arkansas', 'R+16', '34.8%', '62.4%', '33.7%', '60.6%'], ['California', 'D+13', '63.5%', '34.3%', '61.7%', '31.6%'], ['Colorado', 'D+4', '55.4%', '41.9%', '48.2%', '43.3%'], ['Connecticut', 'D+7', '59.3%', '39.2%', '54.6%', '40.9%'], ['Delaware', 'D+7', '58.7%', '39.8%', '53.1%', '41.7%'], ['District of Columbia', 'D+43', '92.2%', '5.4%', '90.9%', '4.1%'], ['Florida', 'R+3', '47.9%', '51.2%', '47.8%', '49.0%'], ['Georgia', 'R+3', '49.5%', '49.2%', '45.6%', '50.8%'], ['Hawaii', 'D+14', '63.7%', '34.3%', '62.2%', '30.0%'], ['Idaho', 'R+18', '33.1%', '63.8%', '27.5%', '59.3%'], ['Illinois', 'D+7', '57.5%', '40.6%', '55.8%', '38.8%'], ['Indiana', 'R+11', '41.0%', '57.0%', '37.9%', '56.8%'], ['Iowa', 'R+6', '44.9%', '53.1%', '41.7%', '51.2%'], ['Kansas', 'R+10', '41.6%', '56.2%', '36.1%', '56.7%'], ['Kentucky', 'R+16', '36.2%', '62.1%', '32.7%', '62.5%'], ['Louisiana', 'R+12', '39.9%', '58.5%', '38.5%', '58.1%'], ['Maine', 'D+2', '53.1%', '44.0%', '47.8%', '44.9%'], ['Maryland', 'D+14', '65.4%', '32.2%', '60.3%', '33.9%'], ['Massachusetts', 'D+15', '65.6%', '32.1%', '60.0%', '32.8%'], ['Michigan', 'R+1', '50.6%', '47.8%', '47.3%', '47.5%'], ['Minnesota', 'D+1', '52.4%', '45.3%', '46.4%', '44.9%'], ['Mississippi', 'R+11', '41.1%', '57.6%', '40.1%', '57.9%'], ['Missouri', 'R+10', '41.4%', '56.8%', '38.1%', '56.8%'], ['Montana', 'R+11', '40.6%', '56.9%', '35.8%', '56.2%'], ['Nebraska', 'R+13', '39.2%', '58.2%', '33.7%', '58.8%'], ['Nevada', 'R+1', '50.1%', '47.7%', '47.9%', '45.5%'], ['New Hampshire', 'D+1', '52.7%', '45.4%', '47.0%', '46.6%'], ['New Jersey', 'D+6', '57.3%', '41.4%', '55.5%', '41.4%'], ['New Mexico', 'D+3', '54.3%', '43.5%', '48.3%', '40.0%'], ['New York', 'D+10', '60.9%', '37.8%', '59.0%', '36.5%'], ['North Carolina', 'R+3', '48.6%', '49.9%', '46.2%', '49.8%'], ['North Dakota', 'R+20', '31.8%', '65.1%', '27.2%', '63.0%'], ['Ohio', 'R+6', '45.2%', '53.3%', '43.6%', '51.7%'], ['Oklahoma', 'R+20', '32.3%', '65.4%', '28.9%', '65.3%'], ['Oregon', 'D+6', '56.5%', '40.4%', '50.1%', '39.1%'], ['Pennsylvania', 'R+2', '50.0%', '48.8%', '47.5%', '48.2%'], ['Rhode Island', 'D+8', '59.4%', '38.6%', '54.4%', '38.9%'], ['South Carolina', 'R+8', '43.4%', '55.1%', '40.7%', '54.9%'], ['South Dakota', 'R+16', '35.6%', '61.8%', '31.7%', '61.5%'], ['Tennessee', 'R+14', '37.5%', '60.7%', '34.7%', '60.7%'], ['Texas', 'R+5', '46.5%', '52.1%', '43.2%', '52.2%'], ['Utah', 'R+13', '37.7%', '58.1%', '27.5%', '45.5%'], ['Vermont', 'D+16', '66.1%', '30.7%', '56.7%', '30.3%'], ['Virginia', 'D+3', '54.1%', '44.0%', '49.7%', '44.4%'], ['Washington', 'D+8', '58.0%', '38.8%', '52.5%', '36.8%'], ['West Virginia', 'R+22', '29.7%', '68.6%', '26.4%', '68.5%'], ['Wisconsin', 'R+2', '49.5%', '48.8%', '46.5%', '47.2%'], ['Wyoming', 'R+25', '26.6%', '69.9%', '21.9%', '68.2%']]
>>> CookPVI[0]
['Alabama', 'R+15', '36.6%', '62.0%', '34.4%', '62.1%']
>>> CookPVI[::10]
[['Alabama', 'R+15', '36.6%', '62.0%', '34.4%', '62.1%'], ['Georgia', 'R+3', '49.5%', '49.2%', '45.6%', '50.8%'], ['Maryland', 'D+14', '65.4%', '32.2%', '60.3%', '33.9%'], ['New Jersey', 'D+6', '57.3%', '41.4%', '55.5%', '41.4%'], ['South Carolina', 'R+8', '43.4%', '55.1%', '40.7%', '54.9%'], ['Wyoming', 'R+25', '26.6%', '69.9%', '21.9%', '68.2%']]
>>> for state in CookPVI[::10]:
... print(state[:2])
...
['Alabama', 'R+15']
['Georgia', 'R+3']
['Maryland', 'D+14']
['New Jersey', 'D+6']
['South Carolina', 'R+8']
['Wyoming', 'R+25']
>>> colors
['Red', 'Orange', 'Green', 'Cyan', 'Blue']
>>> colors[:2] + colors[3:] # not easy being green
['Red', 'Orange', 'Cyan', 'Blue']
>>> colors = ['Red', 'Orange', 'Green', 'Cyan', 'Blue']
>>> colors[2]
'Green'
>>> colors.pop(2)
'Green'
>>> colors
['Red', 'Orange', 'Cyan', 'Blue']
>>> s = "hello"
>>> s[1] = 'a'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'str' object does not support item assignment
>>> colors = ['Red', 'Orange', 'Green', 'Cyan', 'Blue']
>>> colors[4] = 'Pink'
>>> colors
['Red', 'Orange', 'Green', 'Cyan', 'Pink']
# Milestone 0: Bricks
bw, bh, bs = BRICK_WIDTH, BRICK_HEIGHT, BRICK_SEP
x = bs
y = GWINDOW_HEIGHT * TOP_FRACTION
for row in range(N_ROWS):
for col in range(N_COLS):
DEBUG and print("Brick at", x, y)
brick = GRect(x, y, bw, bh)
brick.set_filled(True)
brick.set_color("pink")
gw.add(brick)
x += bw + bs
x = bs
y += bh + bs
# Milestone 0: Bricks
bw, bh, bs = BRICK_WIDTH, BRICK_HEIGHT, BRICK_SEP
x = bs
y = GWINDOW_HEIGHT * TOP_FRACTION
for row in range(N_ROWS):
for col in range(N_COLS):
DEBUG and print("Brick at", x, y)
brick = GRect(x, y, bw, bh)
brick.set_filled(True)
brick.set_color("pink") # look here
gw.add(brick)
x += bw + bs
x = bs
y += bh + bs
bw, bh, bs = BRICK_WIDTH, BRICK_HEIGHT, BRICK_SEP
x = bs
y = GWINDOW_HEIGHT * TOP_FRACTION
colors = ['Red', 'Orange', 'Green', 'Cyan', 'Blue'] # new
for row in range(N_ROWS):
for col in range(N_COLS):
DEBUG and print("Brick at", x, y)
brick = GRect(x, y, bw, bh)
brick.set_filled(True)
brick.set_color("pink")
gw.add(brick)
x += bw + bs
x = bs
y += bh + bs
bw, bh, bs = BRICK_WIDTH, BRICK_HEIGHT, BRICK_SEP
x = bs
y = GWINDOW_HEIGHT * TOP_FRACTION
colors = ['Red', 'Orange', 'Green', 'Cyan', 'Blue']
for row in range(N_ROWS):
for col in range(N_COLS):
DEBUG and print("Brick at", x, y)
brick = GRect(x, y, bw, bh)
brick.set_filled(True)
brick.set_color(colors[row//2]) # use the list
gw.add(brick)
x += bw + bs
x = bs
y += bh + bs