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

 

orion.a.smith@gmail.com apcsa-encryption > apcsaHashCaesarString
prev  |  next  |  chance

Given an input String str, return a String of length len composed of only capital letters, which is constructed as follows.


1) each character in the output begins as "A"

2) the first character of the output is shifted as many letters as the first character of str

3) assuming that str contains 2+ characters and len >=2, the second character of the output is shifted by as many letters as the second character of str

4) the numeric value of the nth character of str (index n-1) is used to shift the the nth character of the output, unless len<n in which case you wrap around.

With this algorithm, any length of input can be hashed into an output with a fixed length.
Precondition: str is composed of only capital letters.

apcsaHashCaesarString("A", 1) → "B"
apcsaHashCaesarString("AAAA", 1) → "E"
apcsaHashCaesarString("ZZZZ", 2) → "AA"

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

public String apcsaHashCaesarString(String str, int len) { }

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: 350

Copyright Nick Parlante 2017 - privacy