What base is this number in?

31

4

Here's a nice easy challenge:

Given a string that represents a number in an unknown base, determine the lowest possible base that number might be in. The string will only contain 0-9, a-z. If you like, you may choose to take uppercase letters instead of lowercase, but please specify this. You must output this lowest possible base in decimal.

Here is a more concrete example. If the input string was "01234", it is impossible for this number to be in binary, since 2, 3, and 4 are all undefined in binary. Similarly, this number cannot be in base 3, or base 4. Therefore, this number must be in base-5, or a higher base, so you should output '5'.

Your code must work for any base between base 1 (unary, all '0's) and base 36 ('0-9' and 'a-z').

You may take input and provide output in any reasonable format. Base-conversion builtins are allowed. As usual, standard loopholes apply, and the shortest answer in bytes is the winner!

Test IO:

#Input          #Output
00000       --> 1
123456      --> 7
ff          --> 16
4815162342  --> 9
42          --> 5
codegolf    --> 25
0123456789abcdefghijklmnopqrstuvwxyz    --> 36

James

Posted 2016-08-23T00:11:57.877

Reputation: 54 537

my language doesn't really support string input, may I accept input as ascii integers separated by newlines? – Rohan Jhunjhunwala – 2016-08-23T01:04:08.510

I know it seems a bit "unreasonable" so I doubt its ok – Rohan Jhunjhunwala – 2016-08-23T01:04:34.417

@RohanJhunjhunwala, what's your language? – Daniel – 2016-08-23T01:32:37.600

2

S.I.L.O.S https://github.com/rjhunjhunwala/S.I.L.O.S @Dopapp

– Rohan Jhunjhunwala – 2016-08-23T01:36:09.453

In Python 3, could I take input as a byte string? – Dennis – 2016-08-23T02:25:02.977

8Can I output in base 36? – Leaky Nun – 2016-08-23T04:42:32.650

9@LeakyNun Geez, I hope not. – Dennis – 2016-08-23T05:22:15.997

4@LeakyNun You must output this lowest possible base in decimal. – James – 2016-08-23T06:09:38.547

3@RohanJhunjhunwala If that's your languages closest equivalent to a string, I don't see why not. – James – 2016-08-23T06:16:08.380

@Peter, I was just looking for dupes, but I think http://codegolf.stackexchange.com/q/48952/8478 is a better fit?

– Martin Ender – 2016-08-23T07:37:28.697

Although this is only a subset of the earlier question, it's a subset which is easy to extract.

– Peter Taylor – 2016-08-23T07:37:30.157

@MartinEnder, you're right. Do you need me to retract my close vote, or are your powers sufficient without? – Peter Taylor – 2016-08-23T07:38:26.907

@PeterTaylor I can undo it myself, don't worry. (Although I do think the new spec is better than the old...) – Martin Ender – 2016-08-23T07:39:15.937

Wait actually, I'm not sure it's a dupe of either. This only asks for the base, not for the actual conversion... I'll reopen this and let the community decide, but I don't think we'd close a prime-testing challenge as a dupe of any other challenge requiring a primality test either. – Martin Ender – 2016-08-23T07:41:15.680

3Usually unary is all 1s, and leading zeros are not standard for any positional-based numeric system. – OrangeDog – 2016-08-23T10:35:21.913

Well, you lost me after the fourth test input. – Jesse C. Slicer – 2016-08-23T14:49:13.340

if for hex the Greater digit is F, than yes for 36 is Z – RosLuP – 2016-08-27T20:10:09.563

Answers

16

Jelly, 4 bytes

ṀØBi

Requires uppercase. Try it online! or verify all test cases.

How it works

ṀØBi  Main link. Arguments: s (string)

Ṁ     Yield the maximum of s.
 ØB   Yield "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".
   i  Find the 1-based index of the maximum in that string.

Dennis

Posted 2016-08-23T00:11:57.877

Reputation: 196 637

1It's actually 7 bytes, not 4. The first 2 chars are multi-byte. – Nicomak – 2016-08-23T09:08:11.940

14

@Nicomak This answer is encoded in the Jelly code page, where all of these characters are encoded as 1 byte each.

– Loovjo – 2016-08-23T10:31:18.630

26

Python, 27 22 bytes

lambda s:(max(s)-8)%39

This requires the input to be a bytestring (Python 3) or a bytearray (Python 2 and 3).

Thanks to @AleksiTorhamo for golfing off 5 bytes!

Test it on Ideone.

How it works

We begin by taking the maximum of the string. This the code points of letters are higher than the code points of digits, this maximal character is also the maximal base 36 digit.

The code point of '0' – '9' are 48 – 57, so we must subtract 48 from their code points to compute the corresponding digits, or 47 to compute the lowest possible base. Similarly, the code points of the letters 'a' – 'z' are 97 – 122. Since 'a' represents the digit with value 10, we must subtract 87 from their code points to compute the corresponding digits, or 86 to compute the lowest possible base. One way to achieve this is as follows.

The difference between 97 and 58 (':', the character after '9') is 39, so taking the code points modulo 39 can achieve the subtraction. Since 48 % 39 = 9, and the desired result for the character '0' is 1, we first subtract 8 before taking the result modulo 39. Subtracting first is necessary since otherwise 'u' % 39 = 117 % 39 = 0.

c    n    n-8    (n-8)%39
0    48    40     1
1    49    41     2
2    50    42     3
3    51    43     4
4    52    44     5
5    53    45     6
6    54    46     7
7    55    47     8
8    56    48     9
9    57    49    10
a    97    89    11
b    98    90    12
c    99    91    13
d   100    92    14
e   101    93    15
f   102    94    16
g   103    95    17
h   104    96    18
i   105    97    19
j   106    98    20
k   107    99    21
l   108   100    22
m   109   101    23
n   110   102    24
o   111   103    25
p   112   104    26
q   113   105    27
r   114   106    28
s   115   107    29
t   116   108    30
u   117   109    31
v   118   110    32
w   119   111    33
x   120   112    34
y   121   113    35
z   122   114    36

Dennis

Posted 2016-08-23T00:11:57.877

Reputation: 196 637

If you make it Python 3, and take the input as a byte string, you can drop the ord() and win by 3 bytes. :) – Aleksi Torhamo – 2016-08-23T02:22:06.720

Nice idea! Let me ask the OP. – Dennis – 2016-08-23T02:25:35.127

3@AleksiTorhamo NOOOOOOOOOOOO y u do dis – Rɪᴋᴇʀ – 2016-08-23T02:42:54.097

20

Python, 25 bytes

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

Defines a lambda that takes the string x. Finds the largest digit in the string (sorted with letters above digits, by python's default), and converts to base 36. Adds 1, because 8 is not in base 8.

Rɪᴋᴇʀ

Posted 2016-08-23T00:11:57.877

Reputation: 7 410

11

Haskell, 34 bytes

f s=length['\t'..maximum s]`mod`39

Uses the mod(ord(c)-8,39) idea from Dennis.

41 bytes

g '0'=1
g 'W'=1
g x=1+g(pred x)
g.maximum

45 bytes:

(`elemIndex`(['/'..'9']++['a'..'z'])).maximum

Outputs like Just 3.

xnor

Posted 2016-08-23T00:11:57.877

Reputation: 115 687

6

Cheddar, 34 29 21 bytes

Saved 8 bytes thanks to Dennis!!!

s->(s.bytes.max-8)%39

Uses lowercase letters

Try it online

Explanation

s -> (      // Input is `s`
  s.bytes    // Returns array of char codes
   .max      // Get maximum item in array
) % 39      // Modulus 39

Downgoat

Posted 2016-08-23T00:11:57.877

Reputation: 27 116

1

Or you could just put quotes around the input

– James – 2016-08-23T00:26:01.937

12@DJMcMayhem .___. i didn't even know my own language could do that – Downgoat – 2016-08-23T00:37:53.717

How about (-)&8 instead of n->n-8? – Conor O'Brien – 2016-08-23T01:23:41.077

@ConorO'Brien >>>> I haven't gotten to that yet. I was _just planning to do it and then this challenge was posted. Bassically f&n bonds n to first arg of the function. – Downgoat – 2016-08-23T01:49:03.050

@Downgoat Oh. >_> – Conor O'Brien – 2016-08-23T01:49:52.817

Then how about (+)&-8? Nevermind, that doesn't save any bytes... – Dennis – 2016-08-23T02:58:58.133

s->(s.bytes.max-8)%39 saves 8 though, unless I'm missing something. – Dennis – 2016-08-23T03:01:11.157

@Dennis yes it does... >_> I'm not sure how I missed that – Downgoat – 2016-08-23T03:02:51.883

6

05AB1E, 6 bytes

{¤36ö>

Takes letters in upper case.

Explanation

{       # sort
 ¤      # take last
  36ö   # convert from base 36 to base 10
     >  # increment

Try it online

Emigna

Posted 2016-08-23T00:11:57.877

Reputation: 50 798

Forgive my naivete with 05AB1E, but do you mean convert FROM base 36 (to base 10)? – Keeta - reinstate Monica – 2016-08-23T18:30:23.850

@Keeta You are of course correct. My bad. – Emigna – 2016-08-23T18:33:47.500

5

Julia, 22 bytes

!s=(maximum(s)-'')%39

There's a BS character (0x08) between the quotes. Try it online!

Dennis

Posted 2016-08-23T00:11:57.877

Reputation: 196 637

what does the -'' do? – Downgoat – 2016-08-23T00:53:39.227

It subtracts 8 from the code point and returns an integer. – Dennis – 2016-08-23T00:56:31.163

5

Actually, 6 bytes

M6²@¿u

Try it online!

Leaky Nun

Posted 2016-08-23T00:11:57.877

Reputation: 45 011

4

JavaScript (ES6), 41 37 bytes

s=>parseInt([...s].sort().pop(),36)+1

Edit: Saved 4 bytes thanks to @edc65.

Neil

Posted 2016-08-23T00:11:57.877

Reputation: 95 035

use pop() to save 4 – edc65 – 2016-08-23T08:12:20.153

@edc65 I can't believe that's not under JavaScript tips. – Neil – 2016-08-23T08:31:47.337

3

Haskell, 55 40 bytes

f=(\y->mod(y-8)39).Data.Char.ord.maximum

Thanks @Dennis for his approach. (take that, @xnor ;))

ThreeFx

Posted 2016-08-23T00:11:57.877

Reputation: 1 435

I think you can remove f= for 38 bytes since f doesn't take explicit arguments. – Cyoce – 2016-08-23T15:00:41.227

3

Perl 6: 18 bytes

{:36(.comb.max)+1}

Defines a lambda that takes a single string argument, and returns an integer. It splits the string into characters, finds the "highest" one, converts it to base 36, adds 1.

{(.ords.max-8)%39}

This one uses the modulo approach from Dennis. Same length.

smls

Posted 2016-08-23T00:11:57.877

Reputation: 4 352

2

Retina, 28 bytes

O`.
.\B

{2`
$`
}T01`dl`_o
.

Try it online! (The first line enables a linefeed-separated test suite.)

Explanation

O`.

This sorts the characters of the input.

.\B

This removes all characters except the last, so the first two stages find the maximum character.

{2`
$`
}T01`dl`_o

These are two stages which form a loop. The first one duplicates the first character and the second one "decrements" it (replacing e.g. x with w, a with 9 and 1 with 0). The latter stage encounters a zero as the first character, it removes it instead. This is a standard technique for generating a range of characters, given the upper end. Hence, this generates all "digits" from 0 to the maximum digit.

.

Finally, we simply count the number of digits, which gives us the base.

Martin Ender

Posted 2016-08-23T00:11:57.877

Reputation: 184 808

2

R, 99 89 85 bytes

Look ! Less than 100 bytes !
Look ! 10 bytes off !
Look ! 4 bytes off !

ifelse((m=max(strsplit(scan(,''),"")[[1]]))%in%(l=letters),match(m,l)+10,strtoi(m)+1)

Ungolfed :

l=letters                  #R's built-in vector of lowercase letters

n=scan(what=characters())  #Takes an input from STDIN and convert it to characters

m=max(strsplit(n,"")[[1]]) #Splits the input and takes to max. 
                           #`letters` are considered > to numbers (i.e. a>1)


ifelse(m%in%l,match(m,l)+10,strtoi(m)+1) #If the max is in `letters`,
                                             #outputs the matching position of `m`in `letters` + 10 (because of [0-9]). 
                                             #Else, outputs `m` (as a number) + 1.

As often, this answer makes use of the ifelse function : ifelse(Condition, WhatToDoIfTrue, WhatToDoElse)

Frédéric

Posted 2016-08-23T00:11:57.877

Reputation: 2 059

I love your version; however, treating letters and numbers separately creates those pesky extra bytes. Please have a look at my solution that uses a different method. – Andreï Kostyrka – 2016-08-23T13:05:52.823

Your answer is interesting indeed. I will use the your scan method to golf some bytes ;) – Frédéric – 2016-08-23T13:10:32.410

1

Mathematica, 34 32 bytes

saved 2 bytes thanks to Martin Ender

Max@BaseForm[Characters@#,36]+1&

Defines a pure function that takes a string as input.

Splits the input into characters, converts them to base 36 numbers, and returns the maximum +1.

DanTheMan

Posted 2016-08-23T00:11:57.877

Reputation: 3 140

Max@BaseForm[Characters@#,36]+1& – alephalpha – 2016-08-23T14:19:20.443

1

Mathematica, 34 32 bytes

2 bytes saved thanks to Martin Ender

Max@Mod[ToCharacterCode@#-8,39]&

I decided the different method deserved a new answer.

method stolen inspired by Dennis' solution

DanTheMan

Posted 2016-08-23T00:11:57.877

Reputation: 3 140

2Use some prefix notation: Max@Mod[ToCharacterCode@#-8,39]& (same goes for your other answer) – Martin Ender – 2016-08-23T07:43:28.053

2Also, you need to add & to the end to indicate an anonymous function. – LegionMammal978 – 2016-08-23T11:43:27.470

You forgot one @ in both of your answers (ToCharacterCode@# and Characters@#). – Martin Ender – 2016-08-23T16:37:44.347

1

PHP, 51 38 bytes

(From Dennis) ^^

<?=(ord(max(str_split($argv[1])))-8)%39;

Other proposal without Dennis' trick

<?=($a=max(str_split($argv[1])))<a?$a+1:ord($a)-86;
  • Takes input as argument $argv[1];
  • Take max character (using ASCII) values
  • If it is a number (inferior to < 'a' ascii value) then output number+1
  • Else output ascii value -86 (97 for 'a' in ascii, -11 for 'a' is 11th base-digit)

Crypto

Posted 2016-08-23T00:11:57.877

Reputation: 862

It's too bad PHP has such verbose function names: <?=base_convert(max(str_split($argv[1])),36,10)+1 is an elegant solution, but at 49 bytes! – None – 2016-08-23T18:15:10.833

@YiminRong you can use intval() instead of base_convert() which shortens down to 38 bytes <?=intval(max(str_split($argn)),36)+1; tio: https://tio.run/##K8go@P/fxt42M6@kLDFHIzexQqO4pCi@uCAns0RDJbEoPU9TU8fYTFPb0Pr//@T8lNT0/Jy0f/kFJZn5ecX/dd0A

– 640KB – 2019-06-26T15:53:19.680

1

Octave, 20 bytes

@(a)mod(max(a)-8,39)

alephalpha

Posted 2016-08-23T00:11:57.877

Reputation: 23 988

1

Pyke, 6 bytes

Seb36h

Try it here!

Se     -   sorted(input)[-1]
  b36  -  base(^, 36)
     h - ^ + 1

Blue

Posted 2016-08-23T00:11:57.877

Reputation: 26 661

1

Java 7, 67 61 bytes

int c(char[]i){int m=0;for(int c:i)m=m>c?m:c;return(m-8)%39;}

(m-8)%39 is thanks to @Dennis' amazing answer.

Ungolfed & test code:

Try it here.

class Main{
  static int c(char[] i){
    int m = 0;
    for(int c : i){
      m = m > c
           ? m
           : c;
    }
    return (m-8) % 39;
  }

  public static void main(String[] a){
    System.out.println(c("00000".toCharArray()));
    System.out.println(c("123456".toCharArray()));
    System.out.println(c("ff".toCharArray()));
    System.out.println(c("4815162342".toCharArray()));
    System.out.println(c("42".toCharArray()));
    System.out.println(c("codegolf".toCharArray()));
    System.out.println(c("0123456789abcdefghijklmnopqrstuvwxyz".toCharArray()));
  }
}

Output:

1
7
16
9
5
25
36

Kevin Cruijssen

Posted 2016-08-23T00:11:57.877

Reputation: 67 575

2Instead of Math.max() you can use m = m>c?m:c – RobAu – 2016-08-23T09:53:33.387

@RobAu Ah of course, thanks. Completely forgot about it.. Sometimes I forget the easiest codegolfing things in Java that are even mentioned multiple times in the Tips for Codegolfing in Java post. Thanks for the reminder.

– Kevin Cruijssen – 2016-08-23T12:30:34.477

If you switch to Java 8 you can replace this whole function with a lambda that does a single reduce – BlueRaja - Danny Pflughoeft – 2016-08-23T12:32:32.690

@BlueRaja-DannyPflughoeft I know, which is why I specifically mentioned it as Java 7. Feel free to post a Java 8 lambda as a separate answer. – Kevin Cruijssen – 2016-08-23T12:33:48.053

@BlueRaja-DannyPflughoeft I wonder if that would end up with less bytes.. – RobAu – 2016-08-23T13:46:29.603

1

R, 62 54 bytes

max(match(strsplit(scan(,''),"")[[1]],c(0:9,letters)))

Ungolfed:

max(
  match( # 2: Finds the respective positions of these characters
    strsplit(scan(,''),"")[[1]], # 1: Breaks the input into characters
                                c(0:9,letters)) # 3: In the vector "0123...yz"
                                                )

Update: shaved off 8 bytes due to the redundancy of na.rm=T under the assumption of input validity.

A 39% improvement in size compared to Frédéric's answer. Besides that, it runs a wee bit faster: 0.86 seconds for 100000 replications versus 1.09 seconds for the competing answer. So the one of mine is both smaller and more efficient.

Andreï Kostyrka

Posted 2016-08-23T00:11:57.877

Reputation: 1 389

1

CJam, 10 bytes

Thanks to Martin Ender for saving me a few bytes!

Uses Dennis's formula

q:e>8-i39%

Try it online

CJam, 18 16 btyes

Alternative solution:

A,s'{,97>+q:e>#)

Try it online

A,s'{,97>+       e# Push the string "0123456789abcdefghijklmnopqrstuvwxyz"
          q      e# Get the input
           :e>   e# Find the highest character in the input
              #  e# Find the index of that character in the string
               ) e# Increment

Business Cat

Posted 2016-08-23T00:11:57.877

Reputation: 8 927

1

C89, 55 53 52 50 bytes

f(s,b)char*s;{return*s?f(s+1,*s>b?*s:b):(b-8)%39;}

-8%39 shamelessly stolen from Dennis

Test

test(const char* input)
{
    printf("%36s -> %u\n", input, f((char*)input,0));
}

main()
{
    test("00000");
    test("123456");
    test("ff");
    test("4815162342");
    test("42");
    test("codegolf");
    test("0123456789abcdefghijklmnopqrstuvwxyz");
}

Output

                               00000 -> 1
                              123456 -> 7
                                  ff -> 16
                          4815162342 -> 9
                                  42 -> 5
                            codegolf -> 25
0123456789abcdefghijklmnopqrstuvwxyz -> 36

Saved 2 bytes thanks to Toby Speight

Saved 2 bytes thanks to Kevin Cruijssen

YSC

Posted 2016-08-23T00:11:57.877

Reputation: 732

You can save 2 bytes with the non-prototype declaration: f(char*s,int b) becomes f(s,b)char*s;. – Toby Speight – 2016-08-23T14:13:00.683

You can save 3 bytes by removing the unnecessary parenthesis and space: f(s,b)char*s;{return*s?f(s+1,*s>b?*s:b):(b-8)%39;}

– Kevin Cruijssen – 2016-08-23T14:24:53.547

@KevinCruijssen thx – YSC – 2016-08-23T14:46:34.720

1

C, 55 bytes

This answer assumes that the input is in ASCII (or identical in the numbers and letters, e.g. ISO-8859 or UTF-8):

m;f(char*s){for(m=0;*s;++s)m=m>*s?m:*s;return(m-8)%39;}

We simply iterate along the string, remembering the largest value seen, then use the well-known modulo-39 conversion from base-{11..36}.

Test program

int printf(char*,...);
int main(int c,char **v){while(*++v)printf("%s -> ",*v),printf("%d\n",f(*v));}

Test results

00000 -> 1
123456 -> 7
ff -> 16
4815162342 -> 9
42 -> 5
codegolf -> 25
0123456789abcdefghijklmnopqrstuvwxyz -> 36

Toby Speight

Posted 2016-08-23T00:11:57.877

Reputation: 5 058

Couldn't you remove the m=0? If m appears at the top level of the file, its extern which implies static which implies it is initialized to zero. – Batman – 2016-08-24T03:47:28.403

@Batman - yes, but only if you won't call f() more than once. I know that almost anything's fair game in golf, but my professional instincts regard that as too fragile! – Toby Speight – 2016-08-24T07:46:58.183

On further thought, I could make it an external requirement to reset m between calls to f(). Then my test program could still work. – Toby Speight – 2016-08-24T07:47:39.363

@Batman: on [meta], the majority opinion on the question "Do function submissions have to be reusable?" seems to be against allowing single-use functions. So I'll stick with what I have. Thanks for the suggestion, anyway.

– Toby Speight – 2016-08-24T08:03:02.853

1

C# REPL, 17 bytes

x=>(x.Max()-8)%39

Just ported @Dennis's answer to C#.

stannius

Posted 2016-08-23T00:11:57.877

Reputation: 111

1

Scala, 25 bytes

print((args(0).max-8)%39)

Run it like:

$ scala whatbase.scala 0123456789abcdefghijklmnopqrstuvwxyz

AmazingDreams

Posted 2016-08-23T00:11:57.877

Reputation: 281

0

05AB1E, 3 bytes

Hà>

Try it online or validate all test cases.

Explanation:

          # implicit input
H         # convert each digit to decimal
 à        # maximum
  >       # add 1
          # implicit output

Grimmy

Posted 2016-08-23T00:11:57.877

Reputation: 12 521

0

JavaScript, 57 50 48 bytes

7 bytes saved thnks to @kamaroso97 2 bytes saved thanks to @Neil

n=>Math.max(...[...n].map(a=>parseInt(a,36))+1)

Original answer:

n=>n.split``.map(a=>parseInt(a,36)).sort((a,b)=>b-a)[0]+1

DanTheMan

Posted 2016-08-23T00:11:57.877

Reputation: 3 140

You can knock off 7 bytes with n=>Math.max(...n.split``.map(a=>parseInt(a,36)+1)). – kamoroso94 – 2016-08-23T05:45:41.257

@kamoroso94 I didn't realize Math.max existed. Thanks for telling me about it! – DanTheMan – 2016-08-23T05:52:12.917

[...s] is shorter than s.split\``. – Neil – 2016-08-23T07:31:29.883

0

Dyalog APL, 10 bytes

Prompts for uppercase input.

⌈/⍞⍳⍨⎕D,⎕A

⌈/ maximum

characters of input

⍳⍨ 1-indexed into

⎕D, all digits followed by

⎕A all characters

TryAPL online!

Adám

Posted 2016-08-23T00:11:57.877

Reputation: 37 779

0

Perl, 30 27 bytes

Includes +1 for -p

Run with the input on STDIN, e.g.

base.pl <<< codegolf

base.pl:

#!/usr/bin/perl -p
\@F[unpack"W*"];$_=@F%39-9

Ton Hospel

Posted 2016-08-23T00:11:57.877

Reputation: 14 114

0

BASH 70

grep -o .|sort -r|head -c1|od -An -tuC|sed s/$/-86/|bc|sed s/-/39-/|bc

Input letters are lowercase.

Riley

Posted 2016-08-23T00:11:57.877

Reputation: 11 345

0

R, 59 57 bytes

Thanks to @Andreï-Kostyrka for two bytes.

max(which(c(0:9,letters)%in%strsplit(scan(,""),"")[[1]]))

scan(,'') takes the input and coerces it to a string. Then strsplit divides it into its individual characters. [[1]] is because that returns a list. %in% then checks which of the vector 0,1,2,...,8,9,a,b,c,...,x,y,z is in the input. which tells us the place in that vector of items in the input -- and max finds the biggest place -- which corresponds to the base.

user5957401

Posted 2016-08-23T00:11:57.877

Reputation: 699

Try removing the two extra spaces to save 2 bytes. – Andreï Kostyrka – 2016-08-29T10:12:25.240

0

LiveScript, 32 bytes

->1+parseInt (it/'')sort!pop!,36

A port of this answer in my favorite language that compile to JavaScript. If base~number operator worked with variables I could write ->1+36~(it/'')sort!pop! (23 bytes), but it conflicts with the function bind operator :/

Gustavo Rodrigues

Posted 2016-08-23T00:11:57.877

Reputation: 261

0

PowerShell full program, 56 62 bytes

lowercase letters required.

([int]((read-host).ToCharArray()|sort|select -l 1)-8)%39

PeteA52

Posted 2016-08-23T00:11:57.877

Reputation: 1

-1

Powershell, 62 bytes

function t($s){(($s[0..$s.Length]|measure -Max).Maximum-8)%39}

%39 @Dennis, of course :)

Oliver Rahner

Posted 2016-08-23T00:11:57.877

Reputation: 101

1

Input through a variable isn't one of our accepted input methods, so unless I've misunderstood something, you should revert to using a function or convert this snippet to a full program.

– FryAmTheEggman – 2016-08-23T15:26:02.970