r/dailyprogrammer • u/rya11111 3 1 • Mar 09 '12
[3/9/2012] Challenge #21 [easy]
Input: a number
Output : the next higher number that uses the same set of digits.
6
Upvotes
r/dailyprogrammer • u/rya11111 3 1 • Mar 09 '12
Input: a number
Output : the next higher number that uses the same set of digits.
2
u/defrost Mar 09 '12 edited Mar 09 '12
In C, with possible repeated digits, as a string of symbols
In place manipulation, no generation of other permutations, no generic sorting.
Tested on Codepad.
2
u/Cosmologicon 2 3 Mar 09 '12
C++ cop-out (doesn't count, I know, I'm just sharing):
2
u/jnaranjo Mar 10 '12
Simple python solution.
1
u/[deleted] Mar 10 '12
Okay, bear with me because this is my first time using Python, and I'm not really that good at programming anyways:
Any criticism is appreciated.
1
u/drb226 0 0 Mar 10 '12
Haskell, I'm away from my home computer so I had to compact it into one line to test with lambdabot xD
1
u/eruonna Mar 10 '12
Haskell, without finding permutations:
1
u/bigmell Mar 10 '12
Can you only use each digit once? Because for 38276, the next higher number using the same set is 38277
1
u/[deleted] Mar 10 '12
Perl.
1
u/huck_cussler 0 0 Mar 12 '12
In Java:
1
u/Yuushi Mar 13 '12
Python:
1
u/[deleted] Mar 18 '12
a lot of tidbits and comments leftover, sorry
1
u/Should_I_say_this Jun 24 '12
python 3.2