about | help | code help+videos | done | prefs |
Write a method that accepts a positive integer parameter, num, and then returns the "shake" of that number. The "shake" is found by replacing each even digit with one less than that digit, then reversing the order of the digits, then for each time a digit was reduced, the final answer is also reduced by one. For example, shake(689) returns 973. Reducing an reversing produces the number 975, but since two digits were reduced, the final answer was also reduced by 2 to get 973. Note that NONE of the digits will be a zero. shake(8) → 6 shake(455) → 552 shake(1735) → 5371 ...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: 290
Copyright Nick Parlante 2017 - privacy