4 kyu

Next bigger number with the same digits

1,169 of 39,288GiacomoSorbi

Description:

Create a function that takes a positive integer and returns the next bigger number that can be formed by rearranging its digits. For example:

  12 ==> 21
 513 ==> 531
2017 ==> 2071

If the digits can't be rearranged to form a bigger number, return -1 (or nil in Swift, None in Rust):

  9 ==> -1
111 ==> -1
531 ==> -1
Strings
Refactoring

Stats:

CreatedJul 4, 2015
PublishedJul 4, 2015
Warriors Trained118657
Total Skips20722
Total Code Submissions522838
Total Times Completed39288
JavaScript Completions11487
Python Completions15749
Ruby Completions1169
C# Completions2897
CoffeeScript Completions31
Java Completions3514
Kotlin Completions347
Rust Completions503
Haskell Completions245
C Completions933
Swift Completions252
Go Completions548
TypeScript Completions854
Julia Completions44
Crystal Completions15
Groovy Completions23
PHP Completions437
VB Completions15
COBOL Completions9
C++ Completions1191
Scala Completions16
Total Stars4876
% of votes with a positive feedback rating93% of 4579
Total "Very Satisfied" Votes4019
Total "Somewhat Satisfied" Votes468
Total "Not Satisfied" Votes92
Ad
Contributors
  • GiacomoSorbi Avatar
  • jhoffner Avatar
  • joh_pot Avatar
  • g964 Avatar
  • Unnamed Avatar
  • anter69 Avatar
  • Chrono79 Avatar
  • imjasonmiller Avatar
  • kazk Avatar
  • user5036852 Avatar
  • docgunthrop Avatar
  • JohanWiltink Avatar
  • Firefly2002 Avatar
  • Voile Avatar
  • Awesome A.D. Avatar
  • hobovsky Avatar
  • akvptp Avatar
  • OpenByte Avatar
  • jaeheonshim Avatar
  • TeoChrist Avatar
  • user8436785 Avatar
  • chrismatic Avatar
  • dfhwze Avatar
  • Just4FunCoder Avatar
  • KayleighWasTaken Avatar
  • Ryanlie Avatar
Ad