CS414 Spring 2017 Program #2

Due: Tuesday, February 21st, 2017, before midnight
Late penalty: Wed: -5%, Thursday: -10%, Friday: -20%, Sat, Sun: -100%

Before You Begin:

Questions:

  1. Ramanujan's Taxi. Ramanajunan was a brilliant self-taught Indian mathematician with an uncanny intuition for numbers. Mathematician G.H. Hardy was visiting him one day, and Hardy remarked to him that the number of his taxi had been 1729, a rather dull number. Ramanujan replied, "No, Hardy! No, Hardy! It is a very interesting number. It is the smallest number expressible as a sum of two cubes in two different ways.".

    Verify this claim. In other words, find four different positive integers a, b, c, and d, such that a3 + b3 = c3 + d3.

    Use four nested for loops ( one for a, one for b, one for c, and one for d). You only need to go as high as 15 for each variable. You are looking for values where a**3 + b**3 == c**3 + d**3, and also neither of a or b is equal to c or d.

    Save your program in a file called taxi.py

  2. Write a game that simulates landing on the moon. The player controls a spaceship with the following parameters:

    At each turn, print the height, the speed, and the fuel remaining. Then, prompt the user for an amount of fuel to burn, Mburn, for one second. Don't forget to convert the output of raw_input into a float!.

    If the player chooses more fuel than is available, Mburn should be set to the available amount.

    If there is no fuel left, print "No more fuel!" and burn zero fuel (of course, bad things will likely ensue).

    The game is won if the ship's height is less than 10 m, and its speed is less than 10 m/s. If the ship's height is negative, the game is lost.

    Here are the physics equations needed for each turn (if you're a physics expert, I confess they are only approximate).


    Save your program in a file called lander.py

Turn in your work

To turn you work in, go to mycourses.unh.edu, find CS414 and assignment 1, click the "Submit" button, and upload taxi.py and lander.py .