-
Project Euler – Problem # 20 – Solved with Python
Find the sum of digits in 100! n! means n * (n – 1) * … * 3 * 2 * 1 For example, 10! = 10 * 9 * … * 3 * 2 * 1 = 3628800, and the sum of the digits in the number 10! is 3 + 6 + 2…
-
Pig Solitare – version I
The objective of this lab is to learn how to use functions to implement a solitaire version of a game called Pig. In Pig Solitaire, our objective is to reach a given goal score g within n turns. For example, you win the game if you score 100 points within 5 turns. Or, 50 points…
-
Pig Solitare – version II
The objective of this lab is to learn how to use functions to implement a solitaire version of a game called Pig. In Pig Solitaire, our objective is to reach a given goal score g within n turns. For example, you win the game if you score 100 points within 5 turns. Or, 50 points…
-
Ravensburger Puzzle
-
Use Functions to Write the Following Python Programs:
This problem was similar to Project Euler’s # 17 so I decided to solve it. Can anyone solve this using functions? Problem: Integer to English conversion. Given an integer value, return a string with the equivalent Englist text of each digit. For example, an input of 89 results in “eight-nine” being returned. For an extra…
-
Project Euler – Problem # 17 – Solved with Python
Update: Thanks to a nice comment from a gentleman – Adam… He pointed out that the correct spelling for ‘fourty’ is ‘forty’. The answer now comes out to be 21124. I did this problem twice and came up with a total of 21224 each time. The correct answer is supposed to be 21124. Problem: If…
-
Project Euler – Problem # 14 – Solved with Python
Problem: The following iterative sequence is defined for the set of positive integers: n –> n/2 (n is even) n –> 3n + 1 (n is odd) Using the rule above and starting with 13, we generate the following sequence: 13 –> 40 –> 20 –> 10 –> 5 –> 16 –> 8 –> 4…
-
Project Euler – Problem # 13 – Solved with Python
Python can handle these large number (50 digits and their addition) without any special handling Problem: Work out the first ten digits of the sum of the following one-hundred 50-digit numbers. Project Euler