From 655e44361104a20dfa0e71724b47012660f815ae Mon Sep 17 00:00:00 2001 From: Seongbeom Park Date: Tue, 10 May 2022 14:10:53 +0000 Subject: [PATCH] finish extra/i-love-lance-janice --- README.md | 3 ++ extra/i-love-lance-janice/constraints.txt | 21 +++++++++++ extra/i-love-lance-janice/readme.txt | 43 +++++++++++++++++++++++ extra/i-love-lance-janice/solution.py | 17 +++++++++ 4 files changed, 84 insertions(+) create mode 100644 extra/i-love-lance-janice/constraints.txt create mode 100644 extra/i-love-lance-janice/readme.txt create mode 100644 extra/i-love-lance-janice/solution.py diff --git a/README.md b/README.md index fe116a7..e9a590b 100644 --- a/README.md +++ b/README.md @@ -108,3 +108,6 @@ CFcSBwgCCBoHRhkKU1cGAA4AGU5YQR5THBwNFwoGGAxTQQMQVBUSBg4EAAwQRhUQVBUHFAQTGRpT QQM ### skipping-work * Completed in: 20 mins, 58 secs. + +### i-love-lance-janice +* Completed in: 34 mins, 26 secs. diff --git a/extra/i-love-lance-janice/constraints.txt b/extra/i-love-lance-janice/constraints.txt new file mode 100644 index 0000000..f201987 --- /dev/null +++ b/extra/i-love-lance-janice/constraints.txt @@ -0,0 +1,21 @@ +Java +==== +Your code will be compiled using standard Java 8. All tests will be run by calling the solution() method inside the Solution class + +Execution time is limited. + +Wildcard imports and some specific classes are restricted (e.g. java.lang.ClassLoader). You will receive an error when you verify your solution if you have used a blacklisted class. + +Third-party libraries, input/output operations, spawning threads or processes and changes to the execution environment are not allowed. + +Your solution must be under 32000 characters in length including new lines and and other non-printing characters. + +Python +====== +Your code will run inside a Python 2.7.13 sandbox. All tests will be run by calling the solution() function. + +Standard libraries are supported except for bz2, crypt, fcntl, mmap, pwd, pyexpat, select, signal, termios, thread, time, unicodedata, zipimport, zlib. + +Input/output operations are not allowed. + +Your solution must be under 32000 characters in length including new lines and and other non-printing characters. diff --git a/extra/i-love-lance-janice/readme.txt b/extra/i-love-lance-janice/readme.txt new file mode 100644 index 0000000..b222f46 --- /dev/null +++ b/extra/i-love-lance-janice/readme.txt @@ -0,0 +1,43 @@ +I Love Lance & Janice +===================== + +You've caught two of your fellow minions passing coded notes back and forth -- while they're on duty, no less! Worse, you're pretty sure it's not job-related -- they're both huge fans of the space soap opera ""Lance & Janice"". You know how much Commander Lambda hates waste, so if you can prove that these minions are wasting time passing non-job-related notes, it'll put you that much closer to a promotion. + +Fortunately for you, the minions aren't exactly advanced cryptographers. In their code, 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. + +Languages +========= + +To provide a Python solution, edit solution.py +To provide a Java solution, edit Solution.java + +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? + +Input: +solution.solution("Yvzs! I xzm'g yvorvev Lzmxv olhg srh qly zg gsv xlolmb!!") +Output: + Yeah! I can't believe Lance lost his job at the colony!! + +-- Java cases -- +Input: +Solution.solution("Yvzs! I xzm'g yvorvev Lzmxv olhg srh qly zg gsv xlolmb!!") +Output: + Yeah! I can't believe Lance lost his job at the colony!! + +Input: +Solution.solution("wrw blf hvv ozhg mrtsg'h vkrhlwv?") +Output: + did you see last night's episode? + +Use verify [file] to test your solution and see how it does. When you are finished editing your code, use submit [file] to submit your answer. If your solution passes the test cases, it will be removed from your home folder. diff --git a/extra/i-love-lance-janice/solution.py b/extra/i-love-lance-janice/solution.py new file mode 100644 index 0000000..98485e8 --- /dev/null +++ b/extra/i-love-lance-janice/solution.py @@ -0,0 +1,17 @@ +def solution(x): + result = "" + for c in x: + if ord('a') <= ord(c) and ord(c) <= ord('z'): + result += chr(ord('a') + ord('z') - ord(c)) + else: + result += c + return result + +tests = [ + ("wrw blf hvv ozhg mrtsg'h vkrhlwv?", "did you see last night's episode?"), + ("Yvzs! I xzm'g yvorvev Lzmxv olhg srh qly zg gsv xlolmb!!", "Yeah! I can't believe Lance lost his job at the colony!!"), + ] + +for i, o in tests: + result = solution(i) + print (i, result == o, result, o)