본문 바로가기

Values5

0118. Ordered Count of Characters Count the number of occurrences of each character and return it as a (list of tuples) in order of appearance. For empty output return (an empty list). Consult the solution set-up for the exact data structure implementation depending on your language. Example: ordered_count("abracadabra") == [('a', 5), ('b', 2), ('r', 2), ('c', 1), ('d', 1)] Solution: def ordered_count(inp): from collections impo.. 2023. 1. 18.
1106. Grasshopper - Messi Goals Messi's Goal Total Use variables to find the sum of the goals Messi scored in 3 competitions Information Messi goal scoring statistics: Competition Goals La Liga 43 Champions League 10 Copa del Rey 5 Task Create these three variables and store the appropriate values using the table above: la_liga_goals champions_league_goals copa_del_rey_goals Create a fourth variable named total_goals that stor.. 2022. 11. 7.
The Office I - Outed Description: Your colleagues have been looking over you shoulder. When you should have been doing your boring real job, you've been using the work computers to smash in endless hours of codewars. In a team meeting, a terrible, awful person declares to the group that you aren't working. You're in trouble. You quickly have to gauge the feeling in the room to decide whether or not you should gather.. 2022. 4. 24.
English beggars Description: Born a misinterpretation of this kata, your task here is pretty simple: given an array of values and an amount of beggars, you are supposed to return an array with the sum of what each beggar brings home, assuming they all take regular turns, from the first to the last. For example: [1,2,3,4,5] for 2 beggars will return a result of [9,6], as the first one takes [1,3,5], the second c.. 2022. 3. 16.
Python _ 딕셔너리 가져오기 메서드 정리 딕셔너리의 get 메서드와 ['키']를 이용해 값을 가져올 수 있습니다. 단 ['키']를 이용해 값을 가져올 경우, 키가 없다면 키 에러를 내뱉으므로 에러를 따로 핸들링 해주어야 합니다. >>> x {'a': 100, 'b': 200, 'c': 300} # x 딕셔너리 키-값 >>> x.get('a') # 'a'키를 가져온다. 100 >>> x.get('d') # 'd', 만약 없는 키를 요청하면 None을 반환한다. >>> >>> type(x.get('d')) >>> x.get('d', 1000) # 없는 키에 두 번째 인자로 기본값을 지정해주면 기본값을 반환한다. 1000 >>> x['a'] # get 뿐만아니라 ['키'] 형태를 이용해 값으르 가져올 수 있다. 100 >>> x['d'] # 단, 이.. 2022. 3. 4.