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

 

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

Given an input String and a key n, rotate-right the positions of all the characters in the String within the length n subgroups. So if n is 2 this means "ABCD" becomes "BADC" and "AHOY MATEY" becomes "HAYOM TAYE". But if n is 3, "AHOY MATE" becomes "OAHMY EAT" instead because the group size is 3. Preconditions: str.length() % n == 0, and n > 1.


apcsaEncryptRotatePositions("ABCD", 2) → "BADC"
apcsaEncryptRotatePositions("ab", 2) → "ba"
apcsaEncryptRotatePositions("The clue was always in your head", 8) → "eThe cluw was alyays in dour hea"

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

public String apcsaEncryptRotatePositions(String str, int n) { }

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

Copyright Nick Parlante 2017 - privacy