A dictionary contains keys that map to values. For example, we have a dictionary that maps a country (keys) to its capital (values):
countryCapitals = {
'Ethiopia': 'Addis Abada',
'Canada': ' Ottawa',
'Iran': 'Tehran',
'Turkey': 'Ankara'
}
What will countryCapitals.keys()
output?
# YOUR ANSWER HERE
Check your answer by running this cell:
countryCapitals = {
'Ethiopia': 'Addis Abada',
'Canada': ' Ottawa',
'Iran': 'Tehran',
'Turkey': 'Ankara'
}
print('countryCapitals.keys(): ', countryCapitals.keys())
What will countryCapitals.values()
output?
# YOUR ANSWER HERE
Check your answer by running this cell:
print('countryCapitals.values(): ', countryCapitals.values())
What will len(countryCapitals)
output?
# YOUR ANSWER HERE
Check your answer by running this cell:
print('len(countryCapitals): ', len(countryCapitals))
What will 'Iran' in countryCapitals
output?
# YOUR ANSWER HERE
Check your answer by running this cell:
print("'Iran' in countryCapitals: ", 'Iran' in countryCapitals)
What will 'Iraq' in countryCapitals
output?
# YOUR ANSWER HERE
Check your answer by running this cell:
print("'Iraq' in countryCapitals: ", 'Iraq' in countryCapitals)
Write a dictionary friendsAge
mapping the names of five of your friends to their ages. We want a dictionary with students names as keys and ages as values.
friendsAge = {
# YOUR CODE HERE
}
Write a function averageFriendsAge(d)
that returns the average age of all the friends in a dictionary.
d
is a dictionary mapping the names of friends to their ages.d
.For example:
d = { 'dan': 10,
'sahaana': 15,
'corina': 20 }
averageFriendsAge(d) == 15
def averageFriendsAge(d):
# YOUR CODE HERE
return
# After you finish, this should print True
testDictionary = {
'isabelle': 15,
'jelani': 16,
'will': 14,
'heather': 16,
'rupal': 16
}
print(averageFriendsAge(testDictionary) == 15.4)
False
Try running this on your friendsAge
dictionary:
print(averageFriendsAge(friendsAge))
Now, write a function addFriend(d, name, age)
that adds a new friend to a dictionary
d
, a dictionary mapping the names of friends to their ages.name
, a string that represents your new friend's name.age
, an integer that represents your new friend's age.Note: Do not add a key if you already have a friend with the name given in name
.
For example:
d = { 'dan' : 10,
'sahaana' : 15,
'jelani' : 20 }
addFriend(d, 'isabelle', 25) == { 'dan' : 10,
'sahaana' : 15,
'jelani' : 20,
'isabelle' : 25 }
# 'sahaana' is already in the dictionary, so nothing should be changed.
# sahaana's age should remain at 15 -- it should NOT be changed to 22.
addFriend(d, 'sahaana', 22) == { 'dan': 10,
'sahaana': 15,
'jelani': 20,
'isabelle': 25 }
def addFriend(d, name, age):
# YOUR CODE HERE
return
# After you finish, these should all print True
inputDictionary = {
'friendA' : 15,
'friendB' : 16,
'friendC' : 14,
'friendD' : 16,
'friendE' : 16
}
outputDictionaryA = {
'friendA' : 15,
'friendB' : 16,
'friendC' : 14,
'friendD' : 16,
'friendE' : 16,
'friendF' : 19
}
outputDictionaryB = {
'friendA' : 15,
'friendB' : 16,
'friendC' : 14,
'friendD' : 16,
'friendE' : 16,
'friendF' : 19,
'friendG' : 15
}
print(addFriend(inputDictionary, 'friendF', 19) == outputDictionaryA)
print(addFriend(inputDictionary, 'friendG', 15) == outputDictionaryB)
print(addFriend(inputDictionary, 'friendA', 1000) == outputDictionaryB)
False False False
Write a function changeAge(d, name, age)
to change a friend's age.
d
, a dictionary mapping the names of friends (the keys) to their ages (the values).name
, a string that represents your friend's name.age
, an integer that represents your friend's new age.Note: Do not change the dictionary if you do not have a friend with the name given in name
.
For example:
d = { 'dan': 10,
'sahaana': 15,
'isabelle': 20 }
changeAge(d, 'isabelle', 25) == { 'dan': 10,
'sahaana': 15,
'isabelle': 25 }
# 'bob' is not in the dictionary, so nothing should be changed.
# 'bob' should NOT be added to the dictionary.
changeAge(d, 'bob', 58) == { 'dan': 10,
'sahaana': 15,
'isabelle': 25 }
def changeAge(d, name, age):
# YOUR CODE HERE
return
# After you finish, these should return True
inputDictionary = {
'friendA' : 15,
'friendB' : 16,
'friendC' : 14,
'friendD' : 16,
'friendE' : 16
}
outputDictionaryA = {
'friendA' : 16,
'friendB' : 16,
'friendC' : 14,
'friendD' : 16,
'friendE' : 16
}
outputDictionaryB = {
'friendA' : 16,
'friendB' : 13,
'friendC' : 14,
'friendD' : 16,
'friendE' : 16
}
print(changeAge(inputDictionary, 'friendA', 16) == outputDictionaryA)
print(changeAge(inputDictionary, 'friendB', 13) == outputDictionaryB)
print(changeAge(inputDictionary, 'friendF', 17) == outputDictionaryB)
False False False
Write a function getFriendAge(d, name)
that returns the age of your friend.
d
, a dictionary mapping the names of friends (string keys) to their ages (integer values).name
, your friend's name (a string).None
.For example:
d = { 'dan' : 10,
'sahaana' : 15,
'isabelle' : 20 }
getFriendAge(d, 'sahaana') == 15
getFriendAge(d, 'bob') == None
def getFriendAge(d,name):
# YOUR CODE HERE
return
# After you finish, these should all print True
inputDictionary = {
'friendA' : 15,
'friendB' : 16,
'friendC' : 14,
'friendD' : 16,
'friendE' : 16
}
print(getFriendAge(inputDictionary,'friendA') == 15)
print(getFriendAge(inputDictionary, 'friendD') == 16)
print(getFriendAge(inputDictionary, 'friendX') == None)
False False True
Write a function minKey(d)
that:
d
, that has integer keys.d
.For example:
minKey({77: 'foo', 28: 'bar', 32: 'baz'}) == 28
d = {
9: 2,
8: 1,
3: 7,
7: 8,
4: 3
}
minKey(d) == 3
Hints:
d.keys()
returns the list of keys in a dictionary d
. For example {1: 'a', 2: 'b'}.keys() == [1, 2]
min(lst)
finds the minimum value in a list. For example min([3,2,4]) == 2
# When you are done, these should all print True
def minKey(d):
return
print(minKey({77: 'foo', 28: 'bar', 32: 'baz'}) == 28)
d = {
9: 2,
8: 1,
3: 7,
7: 8,
4: 3
}
print(minKey(d) == 3)
print(minKey({88: 99}) == 88)
False False False
Write a function maxValue(d)
that:
d
, that has integer values.d
.For example:
maxValue({'dog': 33, 'cat': 92, 'ferret': 34}) == 92
d = {
9: 2,
8: 1,
3: 7,
7: 8,
4: 3
}
maxValue(d) == 8
Hints:
d.values()
returns the list of values in a dictionary d
. For example {1: 'a', 2: 'b'}.values() == ['a', 'b']
max(lst)
finds the maximum value in a list. For example max([3,2,4]) == 4
def maxValue(d):
# YOUR CODE HERE
return
# When you are done, these should all print True
print(maxValue({'dog': 33, 'cat': 92, 'ferret': 34}) == 92)
d = {
9: 2,
8: 1,
3: 7,
7: 8,
4: 3
}
print(maxValue(d) == 8)
print(maxValue({1: 10, 2: 10, 3: 10}) == 10)
False False False
Write a function sameKeyAndValue(d)
that:
d
.None
if there is no such key.For example:
d = {
1: 2,
3: 3,
4: 5
}
sameKeyAndValue(d) == 3 # key 3 has the same value of 3.
sameKeyAndValue({'foo': 'foo', 'bar': 'baz'}) == 'foo'
sameKeyAndValue({'a': 1, 'b': 2}) == None # no keys have the same value
sameKeyAndValue({}) == None
Hints:
d.items()
returns a list of [key, value]
pairs in a dictionary d
. For example {1: 'a', 2: 'b'}.items() == [[1, 'a'], [2, 'b']]
d.items()
in a loop:d = {1: 'a', 2: 'b', 3: 'c'}
for key, value in d.items():
print(value * key)
# this loop will print:
a
bb
ccc
def sameKeyAndValue(d):
# YOUR CODE HERE
return
# When you are done, these should all print True
d = {
1: 2,
3: 3,
4: 5
}
print(sameKeyAndValue(d) == 3)
print(sameKeyAndValue({'foo': 'foo', 'bar': 'baz'}) == 'foo')
print(sameKeyAndValue({'a': 1, 'b': 2}) == None)
print(sameKeyAndValue({}) == None)
# if multiple keys map to the same value, it is correct to return any one of them
print(sameKeyAndValue({1: 1, 2: 3, 4: 4}) in [1, 4])
False False True True False
Write a function getKey(d, value)
that returns a key that maps to a given value. In this problem, only one key will map to a value (no repeats or duplicates.)
d
, a dictionaryvalue
, the value to find a key for.None
Hint: Go through all of the keys in d
with a loop, and check to see if it maps to value
For example:
friends = { 'jelani': 10,
'timnit': 15,
'daniel': 20 }
getKey(friends, 10) == 'jelani'
getKey(friends, 20) == 'daniel'
getKey(friends, 100) == None
animals = { 'pig': 'pink',
'crow': 'black',
'donkey': 'brown',
'sheep': 'white' }
getKey(animals, 'black') == 'crow'
getKey(animals, 'pink') == 'pig'
getKey(animals, 'purple') == None
def getKey(d, value):
# YOUR CODE HERE
return
# After you finish, these should return True
friends = { 'jelani': 10,
'timnit': 15,
'daniel': 20 }
print(getKey(friends, 10) == 'jelani')
print(getKey(friends, 20) == 'daniel')
print(getKey(friends, 100) == None)
animals = { 'pig': 'pink',
'crow': 'black',
'donkey': 'brown',
'sheep': 'white' }
print(getKey(animals, 'black') == 'crow')
print(getKey(animals, 'pink') == 'pig')
print(getKey(animals, 'purple') == None)
False False True False False True
In the previous question, we found a single key with a specific value. Now, write a function getKeys(d, value)
that returns a list of keys that map to a given value. We may have repeat values for each key, so return them all in a list.
d
, a dictionary.value
, the value to find keys for.[]
.Hint: Go through all of the keys in d
with a loop, and check to see if it maps to value
, and add it to a list
For example:
friends = { 'arash': 10,
'mike': 15,
'corina': 20,
'jessica': 10,
'basi': 10,
'timnit': 20}
getKeys(friends, 10) has the same elements as ['arash', 'jessica', 'basi']
getKeys(friends, 20) has the same elements as ['corina', 'timnit']
getKeys(friends, 15) has the same elements as ['mike']
getKeys(friends, 999) == []
checkForSameKeys(getKeys(friends, 15), ['mike'])
animals = { 'pig' : 'pink',
'crow' : 'black',
'donkey' : 'brown',
'sheep' : 'white',
'mouse' : 'brown',
'monkey' : 'brown'}
getKeys(animals, 'black') has the same elements as ['crow']
getKeys(animals, 'brown') has the same elements as ['donkey', 'mouse', 'monkey']
getKeys(animals, 'purple') == None
Note: Because you can return the lists in any order, we created a function for you to check if two lists have the same elements. You can use it to check your work, like we do in the tests!
# This function sorts the two lists, and checked if they are the same
def checkForSameKeys(lst1, lst2):
return sorted(lst1) == sorted(lst2)
def getKeys(d, value):
return
# After you finish, each print statement below should print True
friends = {
'arash': 10,
'mike': 15,
'corina': 20,
'jessica': 10,
'basi': 10,
'timnit': 20
}
# This function sorts the two lists, and checked if they are the same
def checkForSameKeys(lst1, lst2):
if lst1 is None or lst2 is None:
return False
return sorted(lst1) == sorted(lst2)
print(checkForSameKeys(getKeys(friends, 10), ['arash', 'jessica', 'basi']))
print(checkForSameKeys(getKeys(friends, 20), ['corina', 'timnit']))
print(checkForSameKeys(getKeys(friends, 15), ['mike']))
print(getKeys(friends, 999) == [])
animals = { 'pig' : 'pink',
'crow' : 'black',
'donkey' : 'brown',
'sheep' : 'white',
'mouse' : 'brown',
'monkey' : 'brown'}
print(checkForSameKeys(getKeys(animals, 'black'), ['crow']))
print(checkForSameKeys(getKeys(animals, 'brown'), ['donkey', 'mouse', 'monkey']))
print(getKeys(animals, 'purple') == [])
False False False False False False False
Write a function mergeNamesAndGrades(names, grades)
that takes two lists (the student names and their grades) as inputs and returns a dictionary with the names of the students as keys and their grades as values.
names
, a list of strings with names of studentsgrades
, a list of strings with grades of each students ('A' - 'F')For example:
mergeListsAsDict(['Daniel', 'Rupal', 'Rajiv'], ['D', 'A', 'B']) == {
'Daniel': 'D',
'Rupal': 'A',
'Rajiv': 'B'
}
def mergeListsAsDict(names, grades):
# YOUR CODE HERE
return
names = ['Daniel', 'Basi', 'Rupal', 'Dim', 'Leello', 'Mike']
grades = ['D', 'B', 'A', 'C', 'A', 'B']
dictResult = {
'Daniel': 'D',
'Basi': 'B',
'Rupal': 'A',
'Dim': 'C',
'Leello': 'A',
'Mike': 'B'
}
print(mergeListsAsDict(names, grades) == dictResult)
print(mergeListsAsDict(['bob'], ['F']) == {'bob': 'F'})
print(mergeListsAsDict([], []) == {})
False False False
Write a function getStudentsWithGrade(d, grade)
that returns a list of students with a given grade.
d
, a dictionary mapping student names to their gradesgrade
, a string corresponding to a grade from 'A' to 'F'getStudentsWithGrade({'Daniel': 'F', 'Rupal': 'A', 'George': 'B'}, 'A') == ['Rupal']
getStudentsWithGrade({'Bob': 'F', 'Dim': 'F', 'Jelani': 'A'}, 'F') == ['Bob', 'Dim']
Hint: to complete this exercise in one line of code, try using one of the functions that you have already written!
def getStudentsWithGrade(d, grade):
# YOUR CODE HERE
return {}
print(set(getStudentsWithGrade({'Daniel': 'A', 'Rupal': 'A', 'George': 'B'}, 'A')) == set(['Daniel', 'Rupal']))
print(getStudentsWithGrade({'Bob': 'F', 'Dim': 'F', 'Jelani': 'A'}, 'F') == ['Bob', 'Dim'])
print(getStudentsWithGrade({'Daniel': 'F', 'Rupal': 'A'}, 'D') == [])
False False False
Write a function findDuplicates(lst)
that:
lst
.lst
. Specifically:lst
.Some examples will help:
findDuplicates([1, 5, 1, 0, 8, 1, 8]) == {
1: [0, 2, 5], # 1 appears in the list at positions 0, 2 and 5.
8: [4, 6] # 8 appears at positions 4 and 6.
}
findDuplicates([1, 5, 'Jelani', 'Timnit', 'Timnit', 'Jelani', 5]) == {
5: [1, 6],
'Jelani': [2, 5],
'Timnit': [3, 4]
}
findDuplicates([False, True, False]) == {False: [0, 2]}
findDuplicates([0, 1, 2, 3]) == {} # there are no repeats, so, return an empty dictionary.
findDuplicates([]) == {} # an empty list also results in an empty dictionary.
def findDuplicates(lst):
# YOUR CODE HERE
return
# When you are done, these should all print True
print(findDuplicates([1, 5, 1, 0, 8, 1, 8]) == {
1: [0, 2, 5],
8: [4, 6]
})
print(findDuplicates([1, 5, 'Jelani', 'Timnit', 'Timnit', 5, 'Jelani']) == {
5: [1, 5],
'Jelani': [2, 6],
'Timnit': [3, 4]
})
print(findDuplicates([False, True, False]) == {False: [0, 2]})
print(findDuplicates([0, 1, 2, 3]) == {})
print(findDuplicates([]) == {})
print(findDuplicates([8, 8, 8, 8, 8, 8]) == {8: [0, 1, 2, 3, 4, 5]})
False False False False False False
Write a function countWords(s)
that:
s
.s
.For example:
countWords('hello word hello ethiopia hello addis ababa') == {
'hello': 3, # hello appears three times
'world': 1, # everything else appears once
'ethiopia': 1,
'addis': 1,
'ababa': 1
}
countWords('. . @ # . # . . @ @ @@') == {
'.': 5,
'@': 3,
'#': 2,
'@@': 1
}
countWords('aaa aa aa a a a') == {
'aaa': 1,
'aa': 2,
'a: 3
}
Important Note: In Python, use the split
method to break strings into lists of words. For example:
'some words 1 2 3'.split() == ['some', 'words', '1', '2', '3']
s = '. . @ # . # . . @ @ @@'
s.split() == ['.', '.', '@', '#', '.', '#', '.', '.', '@', '@', '@@']
def countWords(s):
# YOUR CODE HERE
return
# When you are done, these should all print True
print(countWords('hello world hello ethiopia hello addis ababa') == {
'hello': 3,
'world': 1,
'ethiopia': 1,
'addis': 1,
'ababa': 1
})
print(countWords('. . @ # . # . . @ @ @@') == {
'.': 5,
'@': 3,
'#': 2,
'@@': 1
})
print(countWords('aaa aa aa a a a') == {
'aaa': 1,
'aa': 2,
'a': 3
})
print(countWords('a b c') == {
'a': 1,
'b': 1,
'c': 1
})
print(countWords('') == {})
False False False False False
Write a function countUniqueVisitors(d)
that counts how many different people enter a lab on each day.
d
is a dictionary mapping the days of the week to a list of names of people who entered the lab on that day, for instance:d = {
'Segno': ['rupal', 'arash', 'dim'],
'Maksegno': ['leello', 'leelo', 'leelo', 'dim'],
'Erob': ['dim', 'dim'],
'Hamus': ['arash', 'corina'],
'Arb': ['leello', 'leello', 'isa']
}
getDistinctEntriesCount(d) == {
'Segno': 3, # the distinct people are 'rupal', 'arash' and 'dim'.
'Maksegno': 2, # the distinct people are 'leelo' and 'dim'.
'Erob': 1, # only person who entered is 'dim'.
'Hamus': 2,
'Arb': 2
}
def countUniqueVisitors(d):
# YOUR CODE HERE
return {}
# When you finish, the code below should print True
input1 = {
'Segno': ['arash', 'arash', 'isa', 'rupal', 'arash', 'leello'],
'Maksegno': ['leello', 'dim', 'arash', 'arash', 'isa', 'rupal', 'nati', 'arash', 'nati', 'basi'],
'Erob': ['leello', 'dim', 'dim', 'dim', 'arash'],
'Hamus': ['arash', 'arash', 'rupal', 'arash'],
'Arb': ['leello', 'leello', 'isa', 'dim', 'rupal', 'corina', 'basi', 'nati']
}
input2 = {
'Segno': ['arash', 'arash', 'isa', 'rupal', 'arash', 'leello'],
'Maksegno': ['leello', 'dim', 'arash', 'arash', 'isa', 'rupal', 'nati', 'arash', 'nati', 'basi'],
'Erob': ['leello', 'dim', 'dim', 'dim', 'arash'],
'Hamus': [],
'Arb': ['leello', 'leello', 'isa', 'dim', 'rupal', 'corina', 'basi', 'nati']
}
output1 = {
'Segno': 4,
'Maksegno': 7,
'Erob': 3,
'Hamus': 2,
'Arb': 7
}
output2 = {
'Segno': 4,
'Maksegno': 7,
'Erob': 3,
'Hamus': 0,
'Arb': 7
}
print(countUniqueVisitors(input1) == output1)
print(countUniqueVisitors(input2) == output2)
False False
Write a function getIngredients(dishesDict, ingredientsDict)
that maps people to the list of ingredients they need to cook their favorite dishes.
dishesDict
, a dictionary mapping people to a list of dishes, for example:dishesDict = {
'sahaana': ['salad', 'pasta'],
'corina': ['pizza', 'soup'],
'dan': ['salad']
}
- `ingredientsDict`, a dictionary mapping dishes to a list of its ingredients, for example:
ingredientsDict = {
'salad': ['tomatoes', 'cucumber', 'spinach'],
'pizza': ['sauce', 'dough', 'cheese'],
'pasta': ['spaghetti', 'sauce'],
'soup': ['carrots', 'stock']
}
getIngredients(dishesDict, ingredientsDict) == {
'sahaana': ['tomatoes', 'cucumber', 'spinach', 'spaghetti', 'sauce'],
'corina': ['salami', 'dough', 'cheese', 'carrots', 'stock'],
'dan': ['tomatoes', 'cucumber', 'spinach']
}
Important Note: If two or more of a person's favorite dishes require the same ingredient, include it in their ingredient list only once. For example:
dishesDict = {
'will': ['icecream', 'butter']
}
ingredientsDict = {
'icecream': ['milk', 'sugar'],
'butter': ['milk', 'salt']
}
getIngredients(dishesDict, ingredientsDict) == {
'will': ['milk', 'sugar', 'salt'] ### milk appears only once!
}
def getIngredients(dishesDict, ingredientsDict):
# YOUR CODE HERE
return {}
# When you are finished, these messages should all show 'True' at the end.
dishesDict = {
'sahaana': ['salad', 'pasta'],
'corina': ['pizza', 'soup'],
'dan': ['salad']
}
ingredientsDict = {
'salad': ['tomatoes', 'cucumber', 'spinach'],
'pizza': ['salami', 'dough', 'cheese'],
'pasta': ['spaghetti', 'sauce'],
'soup': ['carrots', 'stock']
}
expected = {
'sahaana': ['spaghetti', 'sauce', 'tomatoes', 'cucumber', 'spinach'],
'corina': ['carrots', 'stock', 'salami', 'dough', 'cheese'],
'dan': ['tomatoes', 'cucumber', 'spinach']
}
actual = getIngredients(dishesDict, ingredientsDict)
print('Example answer has the right number of keys:', len(actual) == len(expected))
for person, ingredientsList in actual.items():
print(person, 'is one of the keys we expect in the example:', person in expected)
print('ingredients list for', person, 'is correct:', sorted(ingredientsList) == sorted(expected[person]))
dishesDict = {
'will': ['icecream', 'butter']
}
ingredientsDict = {
'icecream': ['milk', 'sugar'],
'butter': ['milk', 'salt']
}
actual = getIngredients(dishesDict, ingredientsDict)
expected = {'will': ['milk', 'sugar', 'salt']}
print("There is only one key in Will's dictionary:", len(actual) == 1)
print("There are three ingredients in Will's list:", 'will' in actual and len(actual['will']) == 3)
print("Will's list has milk, sugar and salt:", 'will' in actual and sorted(actual['will']) == ['milk', 'salt', 'sugar'])
Example answer has the right number of keys: False There is only one key in Will's dictionary: False There are three ingredients in Will's list: False Will's list has milk, sugar and salt: False
In mathematics, the $n^{th}$ Taxicab number, typically denoted Ta(n)
or Taxicab(n)
, also called the $n^{th}$ Hardy–Ramanujan number, is defined as the smallest number that can be expressed as a sum of two positive cubes in $n$ distinct ways.
$Taxicab(1) = 2$, because 2 is the smallest number that can be written (in one distinct way) as the sum of two positive cubes:
$Taxicab(1) = 2 = 1^3 + 1^3$
The most famous taxicab number is 1729. It can be written as two distinct sums of positive cubes:
$Taxicab(2) = 1729 = 1^3 + 12^3 = 9^3 + 10^3$
The name is derived from a conversation in ~1919 involving mathematicians G. H. Hardy and Srinivasa Ramanujan. As told by Hardy:
I remember once going to see Ramanujan when he was lying ill at Putney. I had ridden in taxi-cab No. 1729, and remarked that the number seemed to be rather a dull one, and that I hoped it was not an unfavourable omen. "No", he replied, "it is a very interesting number; it is the smallest number expressible as the sum of two positive cubes in two different ways.
Write some Python code to find $Taxicab(3)$.
Hint: $958595904$ can be written as the sum of two positive cubes in three distinct ways. (You can use Python to check for yourself.)
$958595904 = 856^3 + 692^3$
$958595904 = 984^3 + 180^3$
$958595904 = 986^3 + 22^3$
However, $Taxicab(3) \neq 958595904$ because it is not the smallest such number.
# YOUR CODE HERE: how can you use python to find Taxicab(3)?
# YOUR NUMBER HERE
Write some Python code to prove that there is no number smaller than 1729 that can be written as a sum of two positive cubes in two distinct ways.
# YOUR CODE HERE