Home > Software engineering >  Foobar Test Case Failing on my solution on decrypting input
Foobar Test Case Failing on my solution on decrypting input

Time:02-10

every lowercase letter [a..z] is replaced with the corresponding one in [z..a], while every other character (including uppercase letters and punctuation) is left untouched. That is, 'a' becomes 'z', 'b' becomes 'y', 'c' becomes 'x', etc. For instance, the word ""vmxibkgrlm"", when decoded, would become ""encryption"".

Write a function called solution(s) which takes in a string and returns the deciphered string so you can show the commander proof that these minions are talking about ""Lance & Janice"" instead of doing their jobs.

def solution(x):
    alph = "abcdefghijklmnopqrstuvwxyz"
    decryptDic = {}
    alph_len = (len(alph) -1)
    response =""
    for i in alph:      
        decryptDic[i] = alph[alph_len]
        alph_len = alph_len-1      
    for char in  x:
        if char == char.upper():
            response = f"{response}{char}"      
        elif char not in decryptDic:
            response = response.join(char)
        else:
            response = f"{response}{(decryptDic.get(char))}"

    return response

It is just saying test case failed

Test cases

Your code should pass the following test cases. Note that it may also be run against hidden test cases not shown here.

-- Python cases --

Input: solution.solution("wrw blf hvv ozhg mrtsg'h vkrhlwv?")

Output: did you see last night's episode?

CodePudding user response:

  •  Tags:  
  • Related