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

 

jebbert@volusia.k12.fl.us > shake
prev  |  next  |  chance

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)

public int shake(int num) { }

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

Copyright Nick Parlante 2017 - privacy