-
E01-city-distances: Write an algorithm that takes as input a sequence of pairs of city names and distances between these cities (measured in miles) and reports the distances in kilometers. Note that the end of the input is determined by two cities with the same name and distance 0. Example: For the sequence "Caracas" "Valencia" "98" "Caracas" "Maturin" "312" "Caracas" "Caracas" "0", your algorithm should print:
Caracas Valencia: 156.8 Caracas Maturin: 499.2
-
E02-extract-digits: Create an algorithm for a function that receives two parameters, N and K, and returns the K leftmost digits of N. Example: extractDigits(542207, 2) should return 54.
-
E03-palindrome-substring: Create an algorithm that determines if a 6-digit number N contains any 3-digit palindrome number. Example: If N = 485992, there are no contained palindrome numbers, but N = 106562 does contain one (656).
-
E04-sort-numbers: Write a function or action that receives 5 numbers as parameters and prints the numbers from highest to lowest and also determines the maximum and minimum among them.
-
E05-days-to-month: Create a function that receives a month of the year as input and determines the number of days elapsed from the beginning of the year to the first day of the month.
-
E06-days-between-dates: Create a function that uses the function created in problem 5 to create another function that takes as input two dates (day, month, and year) and calculates the number of days elapsed between the dates. You can also assume that there is a function to determine if a year is a leap year.
-
E07-point-in-rectangle: Create a function to determine if a point (X, Y) is inside a rectangle. The rectangle is defined by the coordinate of the top-left vertex, its height, and its width.
-
E08-rectangle-intersection: Using the function developed in problem 7, create a function that takes as input two rectangles and determines if any vertex of the 1st rectangle is contained in the 2nd rectangle.
-
E09-bank-account: Create a program that simulates a bank account. It should allow you to deposit, withdraw, and check the account balance.
-
E10-rock-paper-scissors: Create a program that simulates the game rock-paper-scissors. The program should allow the user to play against the computer.
-
E11-math-friendship: It is said that two positive integers M and N share Mathematical Friendship when the sum of the divisors of M (excluding itself) equals N and the sum of the divisors of N (excluding itself) equals M. Example:
- The divisors of 220 are: 1, 2, 4, 5, 10, 11, 20, 22, 44, 55, 110 which sum up to 284
- The divisors of 284 are: 1, 2, 4, 71, 142 which sum up to 220
Create a program that, given two numbers, indicates if they share mathematical friendship.
-
E12-quadratic-friendship: Quadratic Friendship exists between two numbers when the following example holds true for the numbers 13 and 16:
- The number 16 squared is 256 and summing its digits 2+5+6 --> 13
- The number 13 squared is 169 and summing its digits 1+6+9 --> 16
When the above happens, the numbers are said to share quadratic friendship. Create a program that indicates if two given numbers share quadratic friendship.
-
E13-greatest-common-divisor: Create a program that calculates and displays the Greatest Common Divisor (GCD) of two given natural numbers.
-
E14-least-common-multiple: Develop a program that, given two natural numbers N and M provided by the user, calculates the Least Common Multiple (LCM) of them.