0129. Super Duper Easy Make a function that returns the value multiplied by 50 and increased by 6. If the value entered is a string it should return "Error". Solution: problem = lambda x: "Error" if isinstance(x, str) else x * 50 + 6 나는 이렇게 학습한다/Algorithm & SQL 2023.01.29
1227. CSV representation of array Create a function that returns the CSV representation of a two-dimensional numeric array. Example: input: [[ 0, 1, 2, 3, 4 ], [ 10,11,12,13,14 ], [ 20,21,22,23,24 ], [ 30,31,32,33,34 ]] output: '0,1,2,3,4\n' +'10,11,12,13,14\n' +'20,21,22,23,24\n' +'30,31,32,33,34' Array's length > 2. Solution: def to_csv_text(array): return '\n'.join(','.join(map(str, i)) for i in array) 나는 이렇게 학습한다/Algorithm & SQL 2022.12.27
1223. validate code with simple regex Basic regex tasks. Write a function that takes in a numeric code of any length. The function should check if the code begins with 1, 2, or 3 and return true if so. Return false otherwise. You can assume the input will always be a number. Solution: def validate_code(code: int) -> bool: return int(str(code)[0]) 나는 이렇게 학습한다/Algorithm & SQL 2022.12.23
1222. Formatting decimal places #0 Each number should be formatted that it is rounded to two decimal places. You don't need to check whether the input is a valid number because only valid numbers are used in the tests. Example: 5.5589 is rounded 5.56 3.3424 is rounded 3.34 Solution: def two_decimal_places(n: float) -> float: l, r = str(n).split(".") r = str(round(int("1"+r[:5]), -3)) return float(".".join([l, r[1:3]])) def two_de.. 나는 이렇게 학습한다/Algorithm & SQL 2022.12.23
1025. Exclusive "or" (xor) Logical Operator Exclusive "or" (xor) Logical Operator Overview In some scripting languages like PHP, there exists a logical operator (e.g. &&, ||, and, or, etc.) called the "Exclusive Or" (hence the name of this Kata). The exclusive or evaluates two booleans. It then returns true if exactly one of the two expressions are true, false otherwise. For example: false xor false == false // since both are false true x.. 나는 이렇게 학습한다/Algorithm & SQL 2022.10.26
1005. Palindrome Strings Palindrome strings A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward or forward. This includes capital letters, punctuation, and word dividers. Implement a function that checks if something is a palindrome. If the input is a number, convert it to string first. Examples(Input ==> Output) "anna" ==> true "walter" ==> false 12321 ==> true 123456 =.. 나는 이렇게 학습한다/Algorithm & SQL 2022.10.05
0912. Fake Binary Given a string of digits, you should replace any digit below 5 with '0' and any digit 5 and above with '1'. Return the resulting string. Note: input will never be an empty string Solution: def fake_bin(x): return ''.join(str(int(i) >= 5 and 1 or 0) for i in x) 나는 이렇게 학습한다/Algorithm & SQL 2022.09.13
0909. Will there be enough space? The Story: Bob is working as a bus driver. However, he has become extremely popular amongst the city's residents. With so many passengers wanting to get aboard his bus, he sometimes has to face the problem of not enough space left on the bus! He wants you to write a simple program telling him if he will be able to fit all the passengers. Task Overview: You have to write a function that accepts t.. 나는 이렇게 학습한다/Algorithm & SQL 2022.09.09
Playing with digits Some numbers have funny properties. For example: 89 --> 8¹ + 9² = 89 * 1 695 --> 6² + 9³ + 5⁴= 1390 = 695 * 2 46288 --> 4³ + 6⁴+ 2⁵ + 8⁶ + 8⁷ = 2360688 = 46288 * 51 Given a positive integer n written as abcd... (a, b, c, d... being digits) and a positive integer p we want to find a positive integer k, if it exists, such that the sum of the digits of n taken to the successive powers of p is equal.. 나는 이렇게 학습한다/Algorithm & SQL 2022.08.15