본문 바로가기
728x90

프로그래밍 문제53

[CheckIO/Scientific Expedition] Longest substring of unique characters 1. Problem : https://py.checkio.org/en/mission/longest-substring-of-unique-characters/ 2. My solution def longest_substr(s: str) -> int: # your code here no_repeat_list = [] longest = 0 for char in [*s]: if no_repeat_list.count(char) == 0: no_repeat_list.append(char) else: index = no_repeat_list.index(char)+1 no_repeat_list.append(char) no_repeat_list = no_repeat_list[index:] if len(no_repeat_li.. 2024. 2. 18.
[CheckIO] Replace All Occureences 1. Problem: https://py.checkio.org/en/mission/replace-all-occurrences/ 2. My solutions def replace_all(mainText: str, target: str, repl: str) -> str: # your code here return mainText.replace(target, repl) 2024. 2. 18.
[CheckIO] Convert To Title case 1. Problem: https://py.checkio.org/en/mission/convert-to-title-case/ 2. My solutions def to_title_case(sentence: str) -> str: # your code here return ' '.join([data.capitalize() for data in sentence.lower().split()]) print("Example:") print(to_title_case("hello world")) # These "asserts" are used for self-checking assert to_title_case("hello world") == "Hello World" assert to_title_case("openai .. 2024. 2. 18.
[CheckIO] Count Vowels 1. Problem: https://py.checkio.org/en/mission/count-vowels/ 2. My solutions def count_vowels(text: str) -> int: # your code here number_vowels = 0 lower_case = text.lower() for vowel in ['a','e','o','i', 'u']: number_vowels += [*lower_case].count(vowel) print(number_vowels) return number_vowels print("Example:") #print(count_vowels("Hello")) # These "asserts" are used for self-checking assert co.. 2024. 2. 18.
[C/C++] 기초플러스 5장 연습문제 1. 분수로 주어지는 시간을 시간 수와 분 로 변환하는 프로그램을 작성하여라. 60을 나타내는 기호 상수를 만들기 위해 #define 또는 const를 사용하라. 사용자가 반복적으로 값을 입력할 수 있도록 while 루프를 사용하고 0또는 0보다 작은 값이 입력되면 루프를 끝낸다. #include #define Hour_to_Min 60 int main(void){ float time; printf("#####################################\n"); printf("Please, write down a time (unit: hour)\n"); printf("Example: 1.25 hour\n"); while(1){ printf("If you want to quit this pr.. 2022. 3. 4.
[Check IO] words-order 1. Problem: https://py.checkio.org/en/mission/words-order/ 2. My solutions def words_order(text: str, words: list) -> bool: # your code here original_list = text.split() # check that words is in text for word in words: if word not in original_list: return False if words.count(word) != 1: return False order = list(map(lambda x: original_list.index(x), words)) if order == sorted(order): return Tru.. 2022. 2. 27.
[C기초 플러스] 4장 연습문제 1. 먼저 이름을 요청하고 이어서 다시 성을 요청한다. 그리고 나서, 성 이름 순으로 출력하는 프로그램을 작성하라. #include #define max_words 100 int main(void){ char last_name[max_words], first_name[max_words]; printf("Please write your last name: "); scanf("%s", last_name); printf("Please write your first name: "); scanf("%s", first_name); printf("This is your name: %s %s\n", first_name, last_name); } 2. 이름을 요청하고, 그 이름을 다음과 같은 포멧으로 출력하는 프로그램을.. 2022. 2. 27.
[C 기초 플러스] 3장 연습문제 문제 2 66과 같은 ASCII 코드값을 사용자에게 입력하도록 요청하고 그 ASCII 코드값에 해당되는 문자를 출력하는 프로그램을 작성하여라 #include #include int main(void){ printf("################################################################################\n"); printf("This program will translate a number you give into a corresponding ASCII code\n"); printf("################################################################################\n"); int nu.. 2022. 2. 25.
[Check-IO] Conversion into CamelCase [1] Problem: https://py.checkio.org/en/mission/conversion-into-camelcase/ [2] My solutions def to_camel_case(name: str) -> str: #replace this for solution dummy_list = list(map(lambda x: x.capitalize(), name.split('_'))) return "".join(dummy_list) if __name__ == '__main__': print("Example:") print(to_camel_case('name')) #These "asserts" using only for self-checking and not necessary for auto-tes.. 2021. 12. 25.
728x90