about | help | code help+videos | done | prefs |
Bilbo wants to send secret messages to his friends from his adventures. He has devised a simple replacement cipher where he will select certain letters or symbols to be replaced by different letters or symbols. Write a method to encrypt Bilbo's messages. The parameter 'orig' will contain the original text. The parameters 'from' and 'to' will contain the symbols to change and what to change them into. For example, if 'from' contains "abcd" and 'to' contains "wxyz" that means that each 'a' will be changed to a 'w', each 'b' will be changed to an 'x', each 'c' will be changed to a 'y', and each 'd' will be changed to a 'z'. Any other letters or symbols will remain unchanged. Notice that each unique symbol is handled separately. In particular, upper-case and lower-case are treated as different symbols. Look at the test data for further examples. Please note that the 'from' parameter will contain no duplicate letters or symbols. hobbit4("The Hobbit", "thmoT", "abcdE") → "Ebe Hdbbia" hobbit4("in a hole, in the ground", "aeghilnortu", "oukwanpaxvy") → "ap o wanu, ap vwu kxaypd" hobbit4("there lived a hobbit.", "abcdefghijklmnopqrstuvwxyz", "zyxwvutsrqponmlkjihgfedcba") → "gsviv orevw z slyyrg." ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 300
Copyright Nick Parlante 2017 - privacy