Skip to content

Commit

Permalink
50!
Browse files Browse the repository at this point in the history
  • Loading branch information
park-jiyeong committed Aug 15, 2024
1 parent fe7aa68 commit 8a98570
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions JYPARK/41to50/50.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
def solution(n):
def check(ls, new):
for i in range(len(ls)):
if new == ls[i] or (len(ls)-i) == abs(ls[i]-new):
return False
return True
def dfs(n, ls):
if len(ls) == n:
return 1
cnt = 0
for i in range(n):
if check(ls, i):
cnt += dfs(n, ls+[i])
return cnt

return dfs(n, [])

n = 4
print(solution(n))

0 comments on commit 8a98570

Please sign in to comment.