g | x | w | all
Bytes Lang Time Link
043C gcc251003T144216Zjdt
051Rust251008T170021ZShadowRa
021GolfScript251009T025242Zmanatwor
233Python 2 33 Bytes251007T015042ZRandom D
039Desmos251005T202341ZAiden Ch
041Swift 6.1251004T233549ZmacOSist
010Uiua251004T133401Zaaa
107Lua250930T144840ZSomeone
026Ruby250928T041438ZJordan
076Vim250930T143203ZAaroneou
050Java250930T084245ZKevin Cr
038R250930T020016ZGiuseppe
065PowerShell Core250929T191251ZJulian
106Excel250929T144137Ztufbyte
00305AB1E250929T024443ZLucenapo
033x8664 machine code250928T164909Zm90
013APLNARS250928T073903ZRosario
031Google Sheets250928T065317Zdoubleun
022Wolfram Language Mathematica250928T065258ZGreg Mar
021Juby250928T041746ZJordan
008cQuents250928T034331ZStephen
041R250927T194737ZM--
057Retina250927T232308ZNeil
005Japt250927T223704ZShaggy
011Pyth250927T182029ZManish K
029Python250927T174147Z97.100.9
006Charcoal250927T150323ZNeil
003Jelly250927T141736ZJonathan
003Vyxal250927T141302Zlyxal
031JavaScript ES6250927T140236ZArnauld

C (gcc), 43 bytes

f(s){strtol(s,0,10-strcspn("98765432",s));}

Try it online!

strtol puts its result in eax/rax (x86 return register); f leaves it untouched, so caller sees it as return.

Rust, 51 bytes

|n|(2..).find_map(|b|u64::from_str_radix(n,b).ok())

Attempt This Online!

Rust solution differs from most other languages in that Rust makes it comparatively verbose to convert back and forth between types (e.g. to get the byte values of a str, even just to extract the highest ordinal in it; to coerce the resulting byte value to a valid radix, since the bytes are u8s, but the radix must be u32), but makes both iterating over an infinite range of values and discarding failures fairly succinct (when ? is an option, or in this case, with iterator methods that filter by Option, with .ok() being a cheap way to convert from a Result), so this EAFP-style code (attempts to convert in each base until it finds one that works) is shorter than similar LBYL code (prechecks to find minimal valid base) used in most languages, which ends up five bytes longer expressed in Rust:

Rust, 56 bytes

|n|u64::from_str_radix(n,n.bytes().max()?as u32-47).ok()

Attempt This Online!

GolfScript, 21 characters

.[{48-}/]\$)47-\;base

Sample run:

bash-5.2$ echo -n 32021 | ruby golfscript.rb <( echo '.[{48-}/]\$)47-\;base' )
905

Try it online! / Try all test cases online!

Python 2 33 Bytes

lambda x:int(`x`,int(max(`x`))+1)

Finds the largest digit in the number, adds 1 to it, and uses it as the base. Then uses int to it turn into decimal.

Desmos, 39 bytes

f(L)=total(Lmax(L+1)^{[L.count-1...0]})

Takes input as a list of digits. Returns an integer.

Try It On Desmos!

Try It On Desmos! - Prettfied

Swift 6.1, 41 bytes

{Int($0+"",radix:Int("\($0.max()!)")!+1)}

Try it on SwiftFiddle! Type is (String) -> Int; assumes the input is a string containing a base-10 integer.

Uiua, 10 chars

⌝⊥+1⊸/↥⊥10

pad

⊥10 converts a number into an array of its digits in base 10
+1⊸/↥ finds the largest number in the array and adds 1 to the result, keeping the array on the stack
⌝⊥ converts an array of digits to a number, taking the base as the first argument

Lua, 111 110 107 bytes

Once again, Lua proves why it's a horrible language for good golfing.

Addendum: using table.sort instead of math.max saves a byte‽ Neat!

Addendum 2: …W H Y I S I O S M A L L E R

n=io.read()t={}n:gsub(".",function(c)table.insert(t,tonumber(c))end)table.sort(t)print(tonumber(n,t[#t]+1))

Ruby, 26 bytes

-4 bytes thanks to Value Ink

->n{n.to_i n.bytes.max-47}

Attempt This Online!

Vim, 76 bytes

:s/./&\r/g|g/^/m0
:sor
G<C-a>^y$uu:g//norm@=line('.')<C-v>
a*<C-r>0<C-v><Esc>3hD
:%s/\n/+
C<C-r>=<C-r>-0­⁡​‎‎⁡⁠⁡‏⁠‎⁡⁠⁢‏⁠‎⁡⁠⁣‏⁠‎⁡⁠⁤‏⁠‎⁡⁠⁢⁡‏⁠‎⁡⁠⁢⁢‏⁠‎⁡⁠⁢⁣‏⁠‎⁡⁠⁢⁤‏⁠‎⁡⁠⁣⁡‏⁠‎⁡⁠⁣⁢‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁣⁤‏⁠‎⁡⁠⁤⁡‏⁠‎⁡⁠⁤⁢‏⁠‎⁡⁠⁤⁣‏⁠‎⁡⁠⁤⁤‏⁠‎⁡⁠⁢⁡⁡‏⁠⁠⁠⁠‏​⁡⁠⁡‌⁣​‎‎⁢⁠⁡‏⁠‎⁢⁠⁢‏⁠‎⁢⁠⁣‏⁠‎⁢⁠⁤‏‏​⁡⁠⁡‌⁤​‎‎⁣⁠⁡‏‏​⁡⁠⁡‌⁢⁡​‎‎⁣⁠⁢‏⁠‎⁣⁠⁣‏⁠‎⁣⁠⁤‏⁠‎⁣⁠⁢⁡‏⁠‎⁣⁠⁢⁢‏⁠‎⁣⁠⁢⁣‏⁠‎⁣⁠⁢⁤‏⁠‎⁣⁠⁣⁡‏⁠‏​⁡⁠⁡‌⁢⁢​‎‎⁣⁠⁣⁢‏⁠‎⁣⁠⁣⁣‏‏​⁡⁠⁡‌⁢⁣​‎‎⁣⁠⁣⁤‏⁠‎⁣⁠⁤⁡‏⁠‎⁣⁠⁤⁢‏⁠‎⁣⁠⁤⁣‏⁠‎⁣⁠⁤⁤‏⁠‎⁣⁠⁢⁡⁡‏⁠‎⁣⁠⁢⁡⁢‏⁠‎⁣⁠⁢⁡⁣‏‏​⁡⁠⁡‌⁢⁤​‎‎⁤⁠⁡‏⁠‎⁤⁠⁢‏⁠‎⁤⁠⁣‏⁠‎⁤⁠⁤‏⁠‎⁤⁠⁢⁡‏⁠‎⁤⁠⁢⁢‏⁠‎⁤⁠⁢⁣‏⁠‎⁤⁠⁢⁤‏⁠‎⁤⁠⁣⁡‏⁠‎⁤⁠⁣⁢‏⁠‎⁤⁠⁣⁣‏⁠‎⁤⁠⁣⁤‏⁠‎⁤⁠⁤⁡‏⁠‎⁤⁠⁤⁢‏⁠‎⁤⁠⁤⁣‏⁠‎⁤⁠⁤⁤‏⁠‎⁤⁠⁢⁡⁡‏⁠‎⁤⁠⁢⁡⁢‏‏​⁡⁠⁡‌⁣⁡​‎‎⁣⁠⁢⁡⁤‏⁠‎⁣⁠⁢⁢⁡‏⁠‎⁣⁠⁢⁢⁢‏⁠‎⁣⁠⁢⁢⁣‏⁠‎⁣⁠⁢⁢⁤‏⁠‎⁣⁠⁢⁣⁡‏⁠‎⁣⁠⁢⁣⁢‏⁠‎⁣⁠⁢⁣⁣‏⁠‎⁣⁠⁢⁣⁤‏⁠‎⁣⁠⁢⁤⁡‏⁠‎⁣⁠⁢⁤⁢‏⁠‎⁣⁠⁢⁤⁣‏⁠‎⁣⁠⁢⁤⁤‏⁠‎⁣⁠⁣⁡⁡‏⁠‎⁣⁠⁣⁡⁢‏⁠‎⁣⁠⁣⁡⁣‏⁠‏​⁡⁠⁡‌⁣⁢​‎‎⁤⁠⁢⁡⁣‏⁠‎⁤⁠⁢⁡⁤‏⁠‎⁤⁠⁢⁢⁡‏‏​⁡⁠⁡‌⁣⁣​‎‏​⁢⁠⁡‌⁣⁤​‎‎⁢⁡⁠⁡‏⁠‎⁢⁡⁠⁢‏⁠‎⁢⁡⁠⁣‏⁠‎⁢⁡⁠⁤‏⁠‎⁢⁡⁠⁢⁡‏⁠‎⁢⁡⁠⁢⁢‏⁠‎⁢⁡⁠⁢⁣‏⁠‎⁢⁡⁠⁢⁤‏⁠‏​⁡⁠⁡‌⁤⁡​‎‎⁢⁢⁠⁡‏⁠⁠⁠⁠⁠⁠⁠⁠⁠⁠⁠⁠‏​⁡⁠⁡‌⁤⁢​‎‎⁢⁢⁠⁢⁤‏⁠‎⁢⁢⁠⁣⁡‏⁠‎⁢⁢⁠⁣⁢‏⁠‎⁢⁢⁠⁣⁣‏⁠‎⁢⁢⁠⁣⁤‏⁠‎⁢⁢⁠⁤⁡‏⁠‎⁢⁢⁠⁤⁢‏‏​⁡⁠⁡‌⁤⁣​‎‎⁢⁢⁠⁢‏⁠‎⁢⁢⁠⁣‏⁠‎⁢⁢⁠⁤‏⁠‎⁢⁢⁠⁢⁡‏⁠‎⁢⁢⁠⁢⁢‏⁠‎⁢⁢⁠⁢⁣‏‏​⁡⁠⁡‌⁤⁤​‎‏​⁢⁠⁡‌­

:s/./&\r/g                           # ‎⁡Add a newline after each digit, and...
           g/^/m0                    # ...‎⁢reverse their order
:sor                                 # ‎⁣Sort all lines
G                                    # ‎⁤Jump to the last line (the highest digit)
 <C-a>^y$                            # ‎⁢⁡Increment and copy to the 0 register (this is the base)
         uu                          # ‎⁢⁢Undo the increment and sort
           :g//norm                  # ‎⁢⁣On every digit...
a*<C-r>0<C-v><Esc>                   # ‎⁢⁤...append '*<base>'...
                   @=line('.')<C-v>  # ‎⁣⁡...<digit position> times
                  3hD                # ‎⁣⁢We appended a couple extra times, so delete the extras
                                     # ‎⁣⁣Each line now looks like, e.g. 1*2*2*2*2*2*2
:%s/\n/+                             # ‎⁣⁤Join each line with '+'
C                                    # ‎⁤⁡Delete everything into the '-' register and insert...
       <C-r>-0                       # ‎⁤⁢...the '-' register (w/ an extra 0 to cancel an extra '+')...
 <C-r>=                              # ‎⁤⁣...executed as an expression

# ‎⁤⁤The final expression was, e.g. 1*2*2*2*2*2*2+0*2*2*2*2*2+1*2*2*2*2+1*2*2*2+0*2*2+1*2+0+0
💎

Created with the help of Luminespire.

Try it online!

Java, 50 bytes

n->Long.parseLong(n,n.chars().max().orElse(0)-47);

Try it online.

Explanation:

n->                 // Method with String parameter and long return-type
  Long.parseLong(n, //  Return the input-string parsed to base:
   n.chars()        //   Convert the input to an IntStream of its codepoints
    .max()          //   Get its max codepoint
    .orElse(0)      //   Convert it from an OptionalInt to an int
                    //   (`.orElse(#)` is 1 byte shorter than `.getAsInt()`)
    -47);           //   -48 to convert the codepoint to a digit,
                    //   then +1 to convert that digit to the correct base

R, 38 bytes

\(n)min(mapply(strtoi,n,2:10),na.rm=T)

Attempt This Online!

mapply as a version of Map that simplifies to array is the trick!

R, 42 bytes

\(n)min(Vectorize(strtoi)(n,2:10),na.rm=T)

Attempt This Online!

Test harness taken from M--'s answer.

Frustratingly, this is a byte longer! Naively tries each base, then takes the minimum of the non-missing values. Vectorize is rarely used for golfing, but is shorter than sapply since we want to vectorize over the second argument.

PowerShell Core, 65 bytes

(($a=$args)|%{"$(1+($a|sort)[-1])*"*$j++ +$a[-++$i]})-join'+'|iex

Try it online!

Expects a list of digits using splatting
Returns an integer

Builds a base conversion expression and executes it:

For example 70707 becomes 7 + 8*0 + 8*8*7 + 8*8*8*0 + 8*8*8*8*7 which evaluates to 29127

Excel, 106 bytes

=SUM(--MID(A1,SEQUENCE(LEN(A1)),1)*(MAX(--MID(A1,SEQUENCE(LEN(A1)),1))+1)^SEQUENCE(LEN(A1),,LEN(A1)-1,-1))

Ungolfed version:

=LET(
  s, A1,                          // the input as text
  n, LEN(s),                      // number of digits
  d, --MID(s, SEQUENCE(n), 1),    // array of digits
  b, MAX(d) + 1,                   // smallest valid base
  SUM( d * b ^ SEQUENCE(n, 1, n-1, -1) )
)

output from MS Excel

05AB1E, 3 bytes

Z>ö

Try it online!

Explanation: Get the largest digit, add 1 and convert using that base.

x86-64 machine code, 33 bytes

97 31 FF 8D 77 0A 56 99 F7 F6 52 39 FA 0F 47 FA 85 C0 75 F3 FF C7 A9 F7 E7 01 C8 59 39 F1 75 F7 C3

Try it online!

Following the standard calling convention for Unix-like systems (from the System V AMD64 ABI), this takes a 32-bit integer in EDI and returns a 32-bit integer in EAX.

In assembly:

f:  xchg eax, edi   # Switch the number into EAX.
    xor edi, edi    # Set EDI to 0 by XORing it with itself.
    lea esi, [rdi + 10] # Set ESI to 10.
    push rsi        # Push RSI (10) onto the stack as a sentinel.
r0: cdq             # Sign-extend EAX, setting up for the next instruction.
    div esi         # Divide by ESI (which is 10);
                    #  put the quotient in EAX and the remainder in EDX.
    push rdx        # Push RDX (contains EDX; a digit) onto the stack.
    cmp edx, edi    # Compare the digit to EDI.
    cmova edi, edx  # If the digit is greater, set EDI to that value.
    test eax, eax   # Check the value of the quotient.
    jnz r0          # Jump back, to repeat, if it's nonzero.
    inc edi         # Add 1 to the highest digit (in EDI) to get the base.
    .byte 0xA9      # Bypass the next two instructions by absorbing them into
                    #  the 32-bit immediate operand of a TEST instruction.
r1: mul edi             # Multiply EAX by EDI.
    add eax, ecx        # Add ECX to EAX.
    pop rcx         # Pop a value from the stack into RCX (contains ECX).
    cmp ecx, esi    # Compare the value to ESI, which is still 10.
    jne r1          # Jump back, to repeat, if they are not equal.
    ret             # Return.

APL(NARS), 13 chars

k⊥⍨1+⌈/k←⍎¨⍕⎕

It result:

  10⊥1 2 3
123
  16⊥1 2 3
291

test:

   k⊥⍨1+⌈/k←⍎¨⍕⎕
⎕:
  1234
194
   k⊥⍨1+⌈/k←⍎¨⍕⎕
⎕:
  1011010
90
   k⊥⍨1+⌈/k←⍎¨⍕⎕
⎕:
  56789
56789

Google Sheets, 31 bytes

=decimal(join(,1:1),1+max(1:1))

Put the digits in row 1 and the formula in row 2.

screenshot

To input an integer or string instead (42 bytes):

=decimal(A1,1+sort(mid(A1,row(A:A),1),1,))

screenshot

Wolfram Language (Mathematica), 22 bytes

FromDigits[#,1+Max@#]&

Try all test cases online! Unnamed function taking a list of digits as input and outputting an integer. Same algorithm as many other answers.

J-uby, 21 bytes

:to_i%(A|:max|Z|:+&1)

Attempt This Online!

cQuents, 8 bytes

K$;1+MD$

Try it online!

Runs a bit slow for big inputs.

Explanation

:              implicit mode sequence : given input n, output the nth term in the sequence
               each term equals
 K ;       )   from base (               ,                                      )
  $                        current index
    1+                                     1 +
      M   )                                    max (                          )
       D )                                           digits (               )
        $                                                     current index

R, 45 41 bytes

A different solution using strtoi():

\(n)strtoi(n,max(utf8ToInt(paste(n))-47))

Attempt This Online!

If we assume character inputs, then it'd be 34 bytes:

\(s)strtoi(s,max(utf8ToInt(s)-47))

Attempt This Online!


R, 59 58 bytes

\(n,b=utf8ToInt(paste(n))-48)sum(b*max(b+1)^rev(seq(b)-1))

Attempt This Online!

Retina, 57 bytes

^
$'¶0_
O`\G.
+`(.¶)(.+)_(.)
$1$.($2*$1*_$2*_$3*)_
.+¶|_

Try it online! Link includes test cases. Explanation:

^
$'¶0_

Duplicate the input and prefix 0_ to the second copy.

O`\G.

Sort the digits in the first copy.

+`(.¶)(.+)_(.)
$1$.($2*$1*_$2*_$3*)_

Using the last digit in the first copy, convert the second copy from the desired base a digit at a time. Arithmetically, it behaves something like while d:l,r,d[:1]=l,(r*l+r+d[:1]),[].

.+¶|_

Delete the first copy and the _ marker.

Japt, 5 bytes

Takes input as a digit array.

ìUrÔÄ

Try it

Pyth, 11 bytes

iz+1seS.Pz1

Try it online!

Explanation

         z   # Input
       .P  1 # All lists of elements of length 1
      S      # Sort
     e       # Last element
    s        # Convert to int
  +1         # Add 1 with
i            # Convert from base 
 z           # Input

Python, 29 bytes

lambda x:int(x,int(max(x))+1)

Attempt This Online!

Assumes input is a string, outputs an integer.

Charcoal, 6 bytes

I↨θ⊕⌈θ

Try it online! Link is to verbose version of code. Explanation:

  θ     Input string
 ↨      Convert from base
     θ  Input string
    ⌈   Maximum
   ⊕    Incremented
I       Cast to string
        Implicitly print

Jelly, 3 bytes

ḅ‘Ṁ

A monadic Link that accepts the number as a list of its base ten digits and yields the value of those digits interpreted in the smallest valid base.

Try it online! Or see the test-suite.

How?

ḅ‘Ṁ - Link: list of integers, D (N in base ten) e.g. [  3,   2,   0,   2,   1]
 ‘  - increment each digit of {D}                    [  4,   3,   1,   3,   2]
ḅ   - convert {D} from {those} bases                 [905, 304,   8, 304,  69] 
  Ṁ - maximum of {those}                              905

Note that Jelly will happily convert a list of digits containing numbers greater than the base, e.g. [8, 2, 7] converted from base three will evaluate \$8 \cdot 3 ^ 2 + 2 \cdot 3 ^ 1 + 7 \cdot 3 ^0 = 85\$.

Vyxal, 3 bytes

G›β

Try it Online!

Takes input as a list of digits, outputs the desired number.

Explained

G›β
  β  # Input from base:
G    # biggest digit
 ›   # + 1 

JavaScript (ES6), 31 bytes

Expects a string, returns an integer.

s=>parseInt(s,Math.max(...s)+1)

Try it online!

Rebasing from 1 to 200