코드워 38

[python]Snail

www.codewars.com/kata/521c2db8ddc89b9b7a0000c1/train/python Codewars: Achieve mastery through challenge Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com 이 문제는 위와 같은 2차원 배열 값이 들어올 때 빨간색 선과 같은 순서로 1차원 배열을 구하는 것입니다. 위와 같은 예의 경우 입력값이 [[1, 2, 3], [4, 5, 6], [7, 8, 9]]인 경우 [1, 2, 3, 6, 9, 8, 7, 4, 5]를 구하는 ..

[python]Shortest Word

www.codewars.com/kata/57cebe1dc6fdc20c57000ac9/train/python Codewars: Achieve mastery through challenge Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com 이 문제는 문장 중에서 가장 짧은 단어의 길이를 구하는 문제입니다. 우선적으로 문자열을 단어로 분리하기 위해 split을 이용하였습니다. s는 입력 문자열 변수입니다. split() 설명보기 : 문자열을 나누어주는 함수입니다. 괄호 안에 아무 값도 넣지 않으면 공백..

[python]Equal Sides Of An Array

www.codewars.com/kata/5679aa472b8f57fb8c000047/train/python Codewars: Achieve mastery through challenge Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com 이 문제는 정수 배열이 주어질 때 배열의 왼쪽에 있는 정수들의 합과 오른쪽에 있는 정수들의 합이 같은 인덱스를 찾는 것입니다. 예를 들어 정수 배열 [1, 2, 3, 4, 3, 2, 1]이 있을 경우입니다. 인덱스 정수 값 왼쪽에 있는 정수들의 합 오른쪽에 있는 정..

[python]Number of People in the Bus

www.codewars.com/kata/5648b12ce68d9daa6b000099/train/python Codewars: Achieve mastery through challenge Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com 이 문제는 버스 탑승 인원을 계산하는 문제입니다. 버스 정류장에 설 때마다 [버스에 탑승하는 사람의 수, 버스 정류장에서 하차하는 사람의 수] 로 나타내 집니다. 마지막까지 버스에 탑승해 있는 인원수를 구하는 문제입니다. 예를 들어 [[10, 0], [3, 5], ..

[python]Disemvowel Trolls

www.codewars.com/kata/52fba66badcd10859f00097e/train/python Codewars: Achieve mastery through challenge Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com 이 문제는 간단히 말하자면 입력받은 문자열의 모음(AEIOU)을 지우고 리턴하는 것입니다. 이 문제를 처음 접했을 당시에는 vowel이라는 리스트 변수에 모음 문자들을 담고 for문과 replace를 이용하였습니다. def disemvowel(string): vow..

[python]Mumbling

www.codewars.com/kata/5667e8f4e3f572a8f2000039/train/python Codewars: Achieve mastery through challenge Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com 이 문제는 문자열을 특정 규칙에 적용하여 변경한 뒤 리턴해야 합니다. 여기서의 특정한 규칙은 문자열 안의 문자 순서만큼 반복한 뒤 '-'로 연결합니다. 그리고 반복하는 첫 번째 문자는 대문자로 나머지는 소문자로 변경합니다. 입력 문자열이 'abc'일 경우 다음과 같..

[python]Complementary DNA

www.codewars.com/kata/554e4a2f232cdd87d9000038/train/python Codewars: Achieve mastery through challenge Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com 이 문제는 지정된 문자를 바꾸는 것입니다. A -> T T -> A C -> G G -> C 저는 이 문제를 첫 번째는 for문과 if문을 이용하였고 두 번째는 dictionary를 이용해였습니다. 1. for문과 if문 사용 def DNA_strand(dna): ..

[python]Take a Ten Minute Walk

www.codewars.com/kata/54da539698b8a2ad76000228/train/python Codewars: Achieve mastery through challenge Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com 이 문제를 간단하게 설명하면 동서남북으로 10걸음 갔을 때 제자리로 돌아왔는지 확인하는 것입니다. 입력은 string 리스트 형식입니다. e : 동쪽 w : 서쪽 n : 북쪽 s : 남쪽 이 문제를 풀기 위해서는 2가지 조건을 만족하면 됩니다. 1. 배열의 길이가 ..

[python]List Filtering

www.codewars.com/kata/53dbd5315a3c69eed20002dd/train/python Codewars: Achieve mastery through challenge Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com 이 문제는 입력받은 배열 중 string 타입을 제외하는 문제입니다. 이 변수 타입을 구별하기 위해서 여러 가지 방법이 있지만 대표적으로 isinstance와 type이 있습니다. (사실 지금 이 두 가지밖에 생각이 안 나네요... 더 좋은 방법 있으시면 댓글로 남..

[python]Roman Numerals Encoder

https://www.codewars.com/kata/51b62bf6a9c58071c600001b/train/python Codewars: Achieve mastery through challenge Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com 이 문제는 입력받은 10진수를 로마 숫자로 출력하는 것입니다. 풀이를 보시려면 더보기를 누르시면 됩니다. 더보기 Roman Numerals Encoder 10진수를 로마 숫자로 바꾸러면 1, 4, 5, 9, 10, 40, 50, 90, 100, 400..

728x90