0915. Beginner - Reduce but Grow Given a non-empty array of integers, return the result of multiplying the values together in order. Example: [1, 2, 3, 4] => 1 * 2 * 3 * 4 = 24 Solution: def grow(arr, i=1): return grow(arr, i*arr.pop()) if arr else i 나는 이렇게 학습한다/Algorithm & SQL 2022.09.15
Money, Money, Money Mr. Scrooge has a sum of money 'P' that he wants to invest. Before he does, he wants to know how many years 'Y' this sum 'P' has to be kept in the bank in order for it to amount to a desired sum of money 'D'. The sum is kept for 'Y' years in the bank where interest 'I' is paid yearly. After paying taxes 'T' for the year the new sum is re-invested. Note to Tax: not the invested principal is taxed.. 나는 이렇게 학습한다/Algorithm & SQL 2022.07.26
Persistent Bugger Description: Write a function, persistence, that takes in a positive parameter num and returns its multiplicative persistence, which is the number of times you must multiply the digits in num until you reach a single digit. For example (Input --> Output): 39 --> 3 (because 3*9 = 27, 2*7 = 14, 1*4 = 4 and 4 has only one digit) 999 --> 4 (because 9*9*9 = 729, 7*2*9 = 126, 1*2*6 = 12, and finally 1.. 나는 이렇게 학습한다/Algorithm & SQL 2022.03.20
Grasshopper - Summation Summation Write a program that finds the summation of every number from 1 to num. The number will always be a positive integer greater than 0. For example: summation(2) -> 3 1 + 2 summation(8) -> 36 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 Solution 1. Repeat the number incrementing by 1 as much as 'num'. 2. Add up all the calculated numbers and return them. JS code :: // js :: for var summation = function .. 나는 이렇게 학습한다/Algorithm & SQL 2022.03.03