about | help | code help+videos | done | prefs |
(MEDIUM) Given a plaintext String and an int modulus, find the ciphertext. The modulus transposition scheme is described as follows: Re-arrange the characters in the String so that all the index positions with the same remainder are clustered together in sequence. For example, the plaintext "012345678" with modulus 3 becomes "036147258" - 0, 3 and 6 all have remainder 0 when divided by 3 but 0 comes before 3. 1 , 4 and 7 all have remainder 1 and so on. If the plaintext input does not have a length evenly divided by the modulus, use the available characters in the same sequence but do not add any garbage characters to the end, when you have run out of plaintext characters to reposition. Thus, the plaintext "01234" with modulus 3 is transformed into "03142" (same length as the original).HINTYou will need to pluck characters out of the plaintext using an algorithm. Remember to loop back to the beginning at appropriate moments. apcsaEncryptMod("012345678", 3) → "036147258" apcsaEncryptMod("012345678", 2) → "024681357" apcsaEncryptMod("0123456789", 4) → "0481592637" ...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: 220
Copyright Nick Parlante 2017 - privacy