Problem 2735. Binary Neighbourhood
Given a natural number reorder its binary form to create another number, closest to the given one.
Examples:
- 1 gives 2, ( 1(dec) > 1 > 01 > 10 > 2(dec) )
- 2 gives 1, ( 2(dec) > 10 > 01 > 1(dec) )
- 5 gives 6, ( 5(dec) > 101 > 110 > 6(dec) )
Solution Stats
Problem Comments
-
3 Comments
one perhpas "unfair" issue with this scoring system is that it penalizes strings by their length (e.g. unique(...,'sorted') costs more points than unique(...,'rows')) which encourages attempting to avoid strings all together...
That's good point. Thanks for your involvement Alfonso. I will disable this feature. I thought it's right approach to count strings like that but your argument shows there are many exceptions, so... not a good idea.
but I liked your fix for the ans trick, I wish that was part of the standard cody scoring!
Solution Comments
Show commentsProblem Recent Solvers91
Suggested Problems
-
22301 Solvers
-
Project Euler: Problem 2, Sum of even Fibonacci
2466 Solvers
-
Project Euler: Problem 8, Find largest product in a large string of numbers
1189 Solvers
-
Matrix with different incremental runs
509 Solvers
-
Calculate the Number of Sign Changes in a Row Vector (No Element Is Zero)
745 Solvers
More from this Author40
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!