This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Background: http://cses.ucsd.edu/pokemon/ & http://cseweb.ucsd.edu/classes/fa11/cse127-a/ | |
from urllib import urlopen, urlencode | |
url = "http://cses.ucsd.edu/pokemon/submitemail.php" | |
for n in range(1, 1000): | |
data = urlencode({"email":"[email protected]", "pokemonid":str(n), "submit":"Catch!"}) | |
f = urlopen(url, data) | |
result = f.read() | |
f.close() | |
print(result) # if you want |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def balls_in_numbered_boxes(balls, box_sizes): | |
if not isinstance(balls, int): | |
raise TypeError("balls must be a non-negative integer.") | |
if balls < 0: | |
raise ValueError("balls must be a non-negative integer.") | |
box_sizes = list(box_sizes) | |
if not box_sizes: | |
raise ValueError("box_sizes must be a non-empty iterable.") |
NewerOlder