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

 

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

Given an input String, change it into a String comprised of characters representing the difference between the sequential character values, considered as numbers, but shifted to be in the range 32-126. Consider the input "ABC" - this is made up of the values 65, 66, 67. The resulting differences are 1 (which came from 66-65), 1, and -2 (which came from 65-67, the difference between the last and first characters). These become 33 (1 more than 32), 33, 125 (2 less than 32 which wraps around to the end of the sequence) which becomes "!!}" in the ASCII table.


Precondition: the plaintext only contains characters in the ASCII visible range (32-126), and the plaintext length is at least 2 characters.

apcsaEncryptDifferences("ABC") → "!!}"
apcsaEncryptDifferences("0123456789") → "!!!!!!!!!v"
apcsaEncryptDifferences("abcdefghijklmnopqrstuvwxyz") → "!!!!!!!!!!!!!!!!!!!!!!!!!f"

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

public String apcsaEncryptDifferences(String str) { }

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

Copyright Nick Parlante 2017 - privacy