# Arup Guha
# 8/28/2025
# Code for CIS 3362 Homework 1, Q4

# Displays the result of applying the function f(x) = (ax+b)%26 on each
# letter in s.
def display(s,a,b):

    # Encrypt
    for x in s:
        print( chr ( ord('a') + (a*(ord(x)-ord('a')) + b)%26 ), end="")
    print()

# Solution for Q4.
display("thanksforgradingmyassignment", 9, 4)

'''
    Note: Here we solve for the decryption function:
    x = 9y + 4 mod 26
    9y = (x - 4) mod 26
    3(9y) = 3(x-4) mod 26
    y = 3x - 12 mod 126
    y = 3x + 14 mod 26
'''

# Note to grader: to grade a student, please call the function
# with a = 3, b = 14

# Here I just decrypt my own message.
display("tperqkxabgbefyrgimekkygriort", 3, 14)
