+ 2
how to find next highest number for the given number which should contains only the digits 2 and 7. ex:i/p 2 o/p 7,i/p 22 o/p 27
what is the way to find 2nd highest value in Ruby's
1 Answer
+ 1
I'd create a class that translates your number to binary (replace 2 by 0 and 7 by 1), then increase your number and convert back to 2's and 7's.
Example: i/p: 7727 is translated to binary 1101, which is 13. Add 1 makes 14, which is 1110. Translated this makes 7772 :)