본문 바로가기

math11

Century From Year Introduction The first century spans from the year 1 up to and including the year 100, the second century - from the year 101 up to and including the year 200, etc. Task Given a year, return the century it is in. Examples 1705 --> 18 1900 --> 19 1601 --> 17 2000 --> 20 Solution: 1. Divide 'year' by 100. 2. Returns the decimal point rounded up. import math def century(year): return math.ceil(year.. 2022. 4. 13.
A square of squares Description: A square of squares You like building blocks. You especially like building blocks that are squares. And what you even like more, is to arrange them into a square of square building blocks! However, sometimes, you can't arrange them into a square. Instead, you end up with an ordinary rectangle! Those blasted things! If you just had a way to know, whether you're currently working in v.. 2022. 3. 13.
Maximum Length Difference Description: You are given two arrays a1 and a2 of strings. Each string is composed with letters from a to z. Let x be any string in the first array and y be any string in the second array. Find max(abs(length(x) − length(y))) If a1 and/or a2 are empty return -1 in each language except in Haskell (F#) where you will return Nothing (None). Example: a1 = ["hoqq", "bbllkw", "oox", "ejjuyyy", "plmii.. 2022. 3. 11.
Highest and Lowest Description: In this little assignment you are given a string of space separated numbers, and have to return the highest and lowest number. Examples highAndLow("1 2 3 4 5"); // return "5 1" highAndLow("1 2 -3 4 5"); // return "5 -3" highAndLow("1 9 3 4 -5"); // return "9 -5" Notes All numbers are valid Int32, no need to validate them. There will always be at least one number in the input string... 2022. 3. 8.
Growth of a Population Description: In a small town the population is p0 = 1000 at the beginning of a year. The population regularly increases by 2 percent per year and moreover 50 new inhabitants per year come to live in the town. How many years does the town need to see its population greater or equal to p = 1200 inhabitants? At the end of the first year there will be: 1000 + 1000 * 0.02 + 50 => 1070 inhabitants At .. 2022. 3. 1.