Skip to content

Instantly share code, notes, and snippets.

View akirap3's full-sized avatar

akirapf3 akirap3

View GitHub Profile
# main part
userInput = input("Enter the matrix you would like to check (Sudoku): ").strip()
userInputList = userInput.split(' ')

testList = inputToMatrix(userInputList)
answer1 = checkRowAndColumnSum(testList)

slicedMatrix = tosliceMatrix(testList)
anwser2 = checkSubMatrixSum(slicedMatrix)
def checkSubMatrixSum(slicedMatrix):
    for k in range(3):
        k *= 3
        for j in range(3):
            matrixSum = 0
            for i in range(3):
                subSum = 0
                for num in slicedMatrix[i+k][j]:
 subSum += num
def tosliceMatrix(testList):    
    slicedMatrix = []
    for i in range(9):
        temp = []
        for j in range(3):
            temp.append(testList[i][3*j:(j+1)*3])
        slicedMatrix.append(temp)
    return slicedMatrix
def checkRowAndColumnSum(testList):
    sumOf1to9 = 0
    for i in range(10):
        sumOf1to9 += i
    
    for i in range(len(testList)):
        rowSum = 0
        columnSum = 0
def inputToMatrix(userInputList):
    testList = []
    for i in range(9):
        tempList = []
        for chr in userInputList[i]:
            tempList.append(int(chr))
        testList.append(tempList)
    return testList
text1 = input("Enter a short text: ").lower()
text2 = input("Enter a long text: ").lower()

check = checkAllChr(text1,text2)
if check:
    answer = checkSequence(text1,text2)
    print(answer)
else:
 print("No")
def checkSequence(word, lword):
    find = 0
    for chr in word:
        find = lword.find(chr, find)
        if find != -1:
            find += 1
        else:
            return "No"
 return "Yes"
def checkAllChr(word, lword):
    lwordList = []   
    for chr in lword:
        lwordList.append(chr)
    check = True    
    for chr in word:
        if chr not in lwordList:
            check = False
 return check
cipher = ''
for char in text:
    if not char.isalpha():
        cipher += char
    if char.islower():
        code = ord(char) + shift
        if code > ord('z'):
            code = ord('a') + (code - ord('z') - 1)
 cipher += chr(code)
checkShift = False
shiftNumber = list(range(1,26))
while checkShift != True:
    try:
        shift = int(input("Enter your shift number(1~25): "))
        if shift in shiftNumber:
            checkShift = True
    except:
 print("Please Enter number between 1 and 25!!")