#APL (24)
APL (24)
{(B⊥D-1),B←⌈/D←⍵⍳⍨⎕D,⎕A}
This is a function that takes a string and returns two values, the value and the base.
{(B⊥D-1),B←⌈/D←⍵⍳⍨⎕D,⎕A} 'DEADBEEF'
3735928559 16
Explanation:
⎕D,⎕A
: digits followed by lettersD←⍵⍳⍨
: store inD
the 1-based index of each character of ⍵ in the string of digits followed by lettersB←⌈/D
: store inB
the highest value inD
. (which is the base to use)(B⊥D-1)
: subtract 1 from each value inD
(making them the values of the digits), and decode them as a base-B
number.