+ 26
[ ASSIGNMENT: ] Next bigger number with the same digits
TASK : You have to create a function that takes a positive integer number and returns the next bigger number formed by the same digits : For Example :: next_bigger(12) --> return 21 next_bigger(513) --> return 531 next_bigger(2017) --> return 2071 If no bigger number can be composed using those digits, return -1 : next_bigger(9) --> return -1 next_bigger(111) --> return -1 next_bigger(531) --> return -1 HappyCodings!:) https://code.sololearn.com/W2BW1CphwSyR/?ref=app
12 Answers
+ 18
https://code.sololearn.com/cggjg7OwB881/?ref=app
+ 12
my try
report if bugs
https://code.sololearn.com/cFJP1VZLpogk/?ref=app
+ 11
I answered this challenge on Codewars :
https://code.sololearn.com/cgMtX4sQGKq4/#py
+ 7
Bigger + Smaller âșïž
https://code.sololearn.com/cDLGsaKbRRl9/?ref=app
+ 7
A little late, but here's a try
https://code.sololearn.com/cp9Rj98VU327/?ref=app
+ 5
My trial without Permutations.
https://code.sololearn.com/cb0yF9PItytT/?ref=app
+ 3
Ruby:
Bigger & Smaller
https://code.sololearn.com/c5rG4A5xT9uG/#rb
quite new to oop en inheritance, so probably it could be optimized quite a lot
+ 2
I didn't notice about next bigger, so I update my code from next smaller, to have both
It use slices, so there is not limit like permutations about digits quantity
https://code.sololearn.com/c2WryQgXPPV4/?ref=app
+ 2
https://code.sololearn.com/wLX5190Zs0bz/?ref=app
https://code.sololearn.com/cWhBW83yu3eF/?ref=app
+ 2
This is my try in Python =
https://code.sololearn.com/c8iL7gMVd2im/?ref=app
+ 1
My solution, witch uses the build in permutations function:
https://code.sololearn.com/c8Ab3cnD2FGR/?ref=app