알고리즘/코드워 65

[python]Binomial Expansion

https://www.codewars.com/kata/540d0fdd3b6532e5c3000b5b/train/python Codewars: Train your coding skills Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com 저는 정규표현식을 사용하지 않았지만 정규표현식을 사용하면 코드 길이는 훨씬 짧아질 것 같습니다. 코드를 보시려면 더보기를 클릭하시면 됩니다. 더보기 Binomial Expansion # My Code def expand(expr): tmp = expr.replace(..

[python]SpeedCode #2 - Array Madness

https://www.codewars.com/kata/56ff6a70e1a63ccdfa0001b1/train/python Codewars: Train your coding skills Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com 이 문제는 코드 제작보다 문제를 이해하는 것이 더 어려웠습니다. 문제 풀이를 보시려면 더보기를 클릭하시면 됩니다. 더보기 SpeedCode #2 - Array Madness 우선 이 문제를 해석해 보면 길이 >=1의 두 정수 배열 a, b를 주어진다면, a의 각 원소..

[python]Polish alphabet

https://www.codewars.com/kata/57ab2d6072292dbf7c000039/train/python Codewars: Train your coding skills Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com 이 문제는 폴란드 알파벳의 분음 부호를 사용하여 글자를 변경하는 것입니다. python에서는 replace를 이용하면 쉽게 문제를 풀 수 있습니다. replace 외에도 maketrans나 st 문자열을 하나씩 나누어서 if 문을 이용하여 문제를 풀 수도 있습니다. ..

[python]Largest 5 digit number in a series

https://www.codewars.com/kata/51675d17e0c1bed195000001/train/python Codewars: Train your coding skills Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com 이 문제는 길이가 5 이상인 숫자(예를 들어 12345, 123456 등)를 5개씩 쪼개서 최댓값을 반환하면 되는 문제입니다. 예를 들어서 1234567898765일 경우 아래와 같이 쪼개어볼 수 있습니다. 12345, 23456, 34567, 45678, 56789..

[python]Sudoku Solution Validator

https://www.codewars.com/kata/529bf0e9bdf7657179000008/train/python Codewars: Train your coding skills Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com Sudoku Solution Validator 스도쿠는 숫자 퍼즐로 가로 9칸, 세로 9칸으로 이루어져 있는 표에 1부터 9까지의 숫자를 채워 넣는 퍼즐입니다. 퍼즐을 푸는 방법은 같은 줄에는 1에서 9까지의 숫자를 한 번만 넣고, 3x3칸의 작은 격자 또한 1에서 ..

[python]Get Planet Name By ID

https://www.codewars.com/kata/515e188a311df01cba000003/train/python Codewars: Train your coding skills Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com python에서는 switch문이 없습니다. switch문 없이 id를 입력받았을 때 다른 값이 출력될 수 있도록 코드를 만들면 됩니다. 간단하게 2가지 방법을 소개해보겠습니다. 1. if와 elif를 사용하는 방법 # 1. if와 elif 사용 def get_pla..

[python]Total amount of points

https://www.codewars.com/kata/5bb904724c47249b10000131/train/python Codewars: Train your coding skills Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com Total amount of points x:y 인 형태로 점수가 들어 있는 배열을 입력받아서 x가 y보다 클 경우는 포인트를 3점 더하고 x가 y와 같을 경우는 1을 더한 후 포인트를 되돌려주면 됩니다. 우선적으로 배열 안의 x:y만 출력되도록 만들어보면 아래의 코..

[python]Expressions Matter

https://www.codewars.com/kata/5ae62fcf252e66d44d00008e/train/python Codewars: Train your coding skills Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com 이 문제는 3가지 주어진 수 및 '(', '+', '*', ')' 이 연산자들을 이용하여 최댓값을 리턴하면 됩니다. 여기서 중요한 것은 3가지 주어진 수는 위치를 바꿀 수 없다는 것입니다. a, b와 c가 1일 경우로 나누어서 문제를 풀었습니다. 하지만 python의..

[python]Abbreviate a Two Word Name

https://www.codewars.com/kata/57eadb7ecd143f4c9c0000a3/train/python Codewars: Train your coding skills Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com Abbreviate a Two Word Name 이 문제는 하나의 공백이 있는 두 단어를 주어 이니셜로 변경하는 문제입니다. 이 이니셜을 연결할 때는 반드시 '.'이 있어야 합니다. 여기서 주의할 점은 입력이 항상 대문자로 주어지지 않을 가능성이 있습니다. 이것을 위..

[python]Did I Finish my Sudoku?

https://www.codewars.com/kata/53db96041f1a7d32dc0004d2/train/python Codewars: Train your coding skills Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com 이번 제 코드는 효율적인 코드는 아닌 것 같습니다. 제 코드는 참고만 하시고 직접 풀어보시는 것을 추천드립니다. 풀이를 보시려면 더보기를 클릭하시면 됩니다. 더보기 Did I Finish my Sudoku? 스도쿠는 숫자 퍼즐로, 가로 9칸, 세로 9칸으로 이루어져 ..

728x90