Skip to content

Commit

Permalink
multicampus coding test
Browse files Browse the repository at this point in the history
  • Loading branch information
sunyeongchoi committed Oct 26, 2020
1 parent b8c71cf commit 752f860
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
12 changes: 12 additions & 0 deletions argorithm/balanced_array.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
def balanced_sum(arr):
size = arr.pop(0)
for i in range(size):
# print('arr[:i+1]: ', arr[:i+1])
# print('arr[-(len(arr)-i):]: ', arr[-(len(arr)-i):])
if sum(arr[:i+1]) == sum(arr[-(len(arr)-i):]):
return i


if __name__ == '__main__':
real_answer = balanced_sum([4, 1, 2, 3, 3])
print(real_answer)
8 changes: 8 additions & 0 deletions argorithm/last_and_second-last.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
def lastLetters(word):
str_to_list = list(word)[-2:]
return ' '.join(str_to_list[::-1])


if __name__ == '__main__':
real_answer = lastLetters('bat')
print(real_answer)
22 changes: 22 additions & 0 deletions argorithm/prime_or_not.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'''
문제 :
주어진 숫자가 소수 일 경우 1을 return
소수가 아닐 경우 약수 중 1을 제외한 가장 작은 숫자 return
아직 푸는중임!~!!!!
'''

def is_prime(n):
answer = []
for i in range(2, n):
if n % i == 0:
answer.append(i)
n = n//i
else:
return 1
return min(answer)


if __name__ == '__main__':
real_answer = is_prime(24)
print(real_answer)

0 comments on commit 752f860

Please sign in to comment.