0117. get character from ASCII Value Write a function get_char() / getChar() which takes a number and returns the corresponding ASCII char for that value. Example: get_char(65) should return: 'A' Solution: get_char = lambda x: chr(x) 나는 이렇게 학습한다/Algorithm & SQL 2023.01.18
0116. OOP: Object Oriented Piracy Ahoy matey! You are a leader of a small pirate crew. And you have a plan. With the help of OOP you wish to make a pretty efficient system to identify ships with heavy booty on board! Unfortunately for you, people weigh a lot these days, so how do you know if a ship is full of gold and not people? You begin with writing a generic Ship class / struct: class Ship: def __init__(self, draft, crew): s.. 나는 이렇게 학습한다/Algorithm & SQL 2023.01.16
0115. Name on billboard You can print your name on a billboard ad. Find out how much it will cost you. Each character has a default price of £30, but that can be different if you are given 2 parameters instead of 1. You can not use multiplier "*" operator. If your name would be Jeong-Ho Aristotelis, ad would cost £600. 20 leters * 30 = 600 (Space counts as a character). Solution: def billboard(name, price=30): return s.. 나는 이렇게 학습한다/Algorithm & SQL 2023.01.15
0114. Are arrow functions odd? Time to test your basic knowledge in functions! Return the odds from a list: [1, 2, 3, 4, 5] --> [1, 3, 5] [2, 4, 6] --> [] Solution: odds = lambda x: [i for i in x if i & 1] 나는 이렇게 학습한다/Algorithm & SQL 2023.01.15
0113. Build a square I will give you an integer. Give me back a shape that is as long and wide as the integer. The integer will be a whole number between 1 and 50. Example n = 3, so I expect a 3x3 square back just like below as a string: +++ +++ +++ Solution: def generate_shape(n: int) -> str: return "\n".join("+" * n for i in range(n)) 나는 이렇게 학습한다/Algorithm & SQL 2023.01.13
0112. Tip Calculator Complete the function, which calculates how much you need to tip based on the total amount of the bill and the service. You need to consider the following ratings: Terrible: tip 0% Poor: tip 5% Good: tip 10% Great: tip 15% Excellent: tip 20% The rating is case insensitive (so "great" = "GREAT"). If an unrecognised rating is received, then you need to return: "Rating not recognised" in Javascript.. 나는 이렇게 학습한다/Algorithm & SQL 2023.01.13
0111. You Can't Code Under Pressure #1 Code as fast as you can! You need to double the integer and return it. Solution: def double_integer(i: int) -> int: try: return i ** 2 // (i / 2) except: return 0 def doubleInteger(i: int) -> int: return i 나는 이렇게 학습한다/Algorithm & SQL 2023.01.12
0110. altERnaTIng cAsE <=> ALTerNAtiNG CaSe altERnaTIng cAsE ALTerNAtiNG CaSe Define String.prototype.toAlternatingCase (or a similar function/method such as to_alternating_case/toAlternatingCase/ToAlternatingCase in your selected language; see the initial solution for details) such that each lowercase letter becomes uppercase and each uppercase letter becomes lowercase. For example: "hello world".toAlternatingCase() === "HELLO WORLD" "HE.. 나는 이렇게 학습한다/Algorithm & SQL 2023.01.11
0104. Sleigh Authentication Christmas is coming and many people dreamed of having a ride with Santa's sleigh. But, of course, only Santa himself is allowed to use this wonderful transportation. And in order to make sure, that only he can board the sleigh, there's an authentication mechanism. Your task is to implement the authenticate() method of the sleigh, which takes the name of the person, who wants to board the sleigh .. 나는 이렇게 학습한다/Algorithm & SQL 2023.01.04
0103. Powers of 2 Complete the function that takes a non-negative integer n as input, and returns a list of all the powers of 2 with the exponent ranging from 0 to n ( inclusive ). Examples n = 0 ==> [1] # [2^0] n = 1 ==> [1, 2] # [2^0, 2^1] n = 2 ==> [1, 2, 4] # [2^0, 2^1, 2^2] Solution: def powers_of_two(n: str) -> list[int]: return [pow(2, i) for i in range(n+1)] 나는 이렇게 학습한다/Algorithm & SQL 2023.01.03