id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > olympicEncryption
prev  |  next  |  chance

Write a method that encrypts an 'orig' string using a 'replace' string. The way the encryption works is that for each character in 'orig' look for the first occurrence of that character in 'replace' and then use the very next character in 'replace' as a replacement character. If the first occurrence of a character in 'replace' is the last character, or if the character never appears in 'replace', then simply use the original character from 'orig'. Please note that this must work with any string characters and that it IS case sensitive. Look at the test data for examples. For this program, you have a restricted subset of string methods you may use. You may use any combination of: .equals .substring .charAt .length but you may not use any other string methods.


olympicEncryption("", "") → ""
olympicEncryption("good luck decrypting this", "aabacadaeafagahaiajakalamanaoapaqarasatauavawaxayaza") → "aaaa aaaa aaaaaaaaaa aaaa"
olympicEncryption("Different Capitalization Changes EVERYTHING", "dxDWcpCZEeVvE-R-GH") → "WiffVrVnt ZaCitalization ZhangVs eve-YTHINH"

...Save, Compile, Run (ctrl-enter)

public String olympicEncryption(String orig, String replace) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 280

Copyright Nick Parlante 2017 - privacy