human
What is a code to check if a number can be represented as sum of two positive perfect cubes and the other steps required given the following:
Check if a number can be represented as sum of two positive perfect cubes | Function to check if N can be represented as sum of two perfect cubes or not.
Stores the perfect cubes of first N natural numbers.
Traverse the map.
Stores first number.
Stores second number.
Search the pair for the first number to obtain sum N from the Map.
If N cannot be represented as sum of two positive perfect cubes.
Function call to check if N can be represented as sum of two perfect cubes or not"
How can the above be solved in Python?
assistant
#Here is code to check if a number can be represented as sum of two positive perfect cubes and the other steps required.
 def sumOfTwoPerfectCubes ( N ) :
	cubes = { }
	i = 1
	while i * i * i <= N :
		cubes [ i * i * i ] = i
		i += 1
	for itr in cubes :
		firstNumber = itr
		secondNumber = N - itr
		if secondNumber in cubes :
			print ( " True " , end = " " )
			return
	print ( " False " , end = " " )
N = 28
sumOfTwoPerfectCubes ( N )