Skip to content

Commit

Permalink
[#3] 2021.12.16 백준단계별 6. 함수
Browse files Browse the repository at this point in the history
  • Loading branch information
hyesuuou committed Dec 16, 2021
1 parent 177d1ed commit f616c63
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Boj/함수/1065.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
n = int(input())
result = 0

# 한수를 판단하는 함수
def d(k):
k_list = list(map(int, str(k)))
if len(k_list) < 3:
return True
elif len(k_list) == 3:
if k_list[1]-k_list[0] == k_list[2]-k_list[1]:
return True
else:
return False
else:
return False


for i in range(1, n+1):
# if 한수면 -> result + 1
if d(i) == True:
result = result + 1

print(result)
5 changes: 5 additions & 0 deletions Boj/함수/15596.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def solve(a):
sum = 0
for i in a:
sum = sum + i
return sum
24 changes: 24 additions & 0 deletions Boj/함수/4673.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
def d(n):
result = n
for i in str(n):
result = result + int(i)
return result

ans = []

# ans = [1, 2, 3, ...]
for i in range(0, 10000):
ans.append(i+1)


for i in range(1, 10000):
k = d(i)
if k > 10000:
continue
else:
ans[k-1] = 0

# 정답 출력
for i in ans:
if i != 0:
print(i)

0 comments on commit f616c63

Please sign in to comment.