Guest User

Untitled

a guest
Apr 23rd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. public Integer substitute(int i) {
  2. if (getPosition() > i) {
  3. i = i - getPosition() + 25;
  4. }
  5. else {
  6. i = i - getPosition();
  7. }
  8. int newVal = mapping[i] + getPosition();
  9. if (newVal > 25) {
  10. newVal = newVal -25;
  11. return newVal;
  12. } else {
  13. return newVal;
  14. }
  15. // return mapping[i];
  16. }
  17.  
  18. public Integer substituteBack(int iL) {
  19. for (int i = 0; i < 26; i++) {
  20. int tempOne = mapping[i];
  21. inverseMapping[tempOne] = i;
  22. }
  23. if (getPosition() > iL){
  24. iL = iL - getPosition() + 25;
  25. }
  26. else {
  27. iL = iL - getPosition();
  28. }
  29.  
  30. int newVal = inverseMapping[iL] + getPosition();
  31. if (newVal > 25) {
  32. newVal = newVal -25;
  33. return newVal;
  34. } else {
  35. return newVal;
  36. }
  37. //return inverseMapping[iL];
  38. }
Add Comment
Please, Sign In to add comment