Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Integer substitute(int i) {
- if (getPosition() > i) {
- i = i - getPosition() + 26;
- }
- else {
- i = i - getPosition();
- }
- int newVal = mapping[i] + getPosition();
- if (newVal > 26) {
- newVal = newVal -26;
- return newVal;
- } else {
- return newVal;
- }
- }
- public Integer substituteBack(int iL) {
- for (int i = 0; i < 26; i++) {
- int tempOne = mapping[i];
- inverseMapping[tempOne] = i;
- }
- if (getPosition() > iL){
- iL = iL - getPosition() + 26;
- }
- else {
- iL = iL - getPosition();
- }
- int newVal = inverseMapping[iL] + getPosition();
- if (newVal > 26) {
- newVal = newVal -26;
- return newVal;
- } else {
- return newVal;
- }
Add Comment
Please, Sign In to add comment