Skip to content

Commit

Permalink
Create 2-9_Password.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jisunp04023 authored Oct 23, 2023
1 parent e0da738 commit ecbc971
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions 2-9_Password.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# UTF-8 encoding when using korean

def solution(password):
length = len(password)
for i in range(length - 2):
first_check = ord(password[i + 1]) - ord(password[i])
second_check = ord(password[i + 2]) - ord(password[i + 1])
if first_check == second_check and (first_check == 1 or first_check == -1):
return False
return True


password1 = "cospro890"
ret1 = solution(password1)

print("solution 함수의 반환 값은", ret1, "입니다.")

password2 = "cba323"
ret2 = solution(password2)

print("solution 함수의 반환 값은", ret2, "입니다.")

0 comments on commit ecbc971

Please sign in to comment.