Skip to main content
added 86 characters in body
Source Link
user34736
user34736

Python 2, 74 64 56 5555 53 bytes

x=inputdef f(x)
 :a=ord(max(x))-54
a+=7*54;a+=7*(a<8)
print(;print int(x,a),a)

Call the function (i.e. f("HELLOWORLD")) and outputs to stdout (809608041709942 33)

This is case-sensitive, requiring upper case letters, and crashes for invalid input (e.g. "$^$%!(&£%)())

This code gets the max letter in the string (z>x>y>...>b>a>9>8>...>2>1>0) and gets the largest base needed to represent it.

Change the 54 into a 76 to make it work for lowercase (but no longer upper case).

Python, 74 64 56 55 bytes

x=input()
 a=ord(max(x))-54
a+=7*(a<8)
print(int(x,a),a)

This is case-sensitive, requiring upper case letters, and crashes for invalid input (e.g. "$^$%!(&£%)())

This code gets the max letter in the string (z>x>y>...>b>a>9>8>...>2>1>0) and gets the largest base needed to represent it.

Change the 54 into a 76 to make it work for lowercase (but no longer upper case).

Python 2, 74 64 56 55 53 bytes

def f(x):a=ord(max(x))-54;a+=7*(a<8);print int(x,a),a

Call the function (i.e. f("HELLOWORLD")) and outputs to stdout (809608041709942 33)

This is case-sensitive, requiring upper case letters, and crashes for invalid input (e.g. "$^$%!(&£%)())

This code gets the max letter in the string (z>x>y>...>b>a>9>8>...>2>1>0) and gets the largest base needed to represent it.

Change the 54 into a 76 to make it work for lowercase (but no longer upper case).

added 28 characters in body
Source Link
user34736
user34736

Python, 74 64 5656 55 bytes

x=input()
a=ord(max(x))-54
if a+=7*(a<8:a+=7)
print(int(x,a),a)

This is case-sensitive, requiring upper case letters, and crashes for invalid input (e.g. "$^$%!(&£%)())

This code gets the max letter in the string (z>x>y>...>b>a>9>8>...>2>1>0) and gets the largest base needed to represent it.

Change the 54 into a 76 to make it work for lowercase as well(but no longer upper case).

Python, 74 64 56 bytes

x=input()
a=ord(max(x))-54
if a<8:a+=7
print(int(x,a),a)

This is case-sensitive, requiring upper case letters, and crashes for invalid input (e.g. "$^$%!(&£%)())

This code gets the max letter in the string (z>x>y>...>b>a>9>8>...>2>1>0) and gets the largest base needed to represent it.

Change the 54 into a 76 to make it work for lowercase as well.

Python, 74 64 56 55 bytes

x=input()
a=ord(max(x))-54
a+=7*(a<8)
print(int(x,a),a)

This is case-sensitive, requiring upper case letters, and crashes for invalid input (e.g. "$^$%!(&£%)())

This code gets the max letter in the string (z>x>y>...>b>a>9>8>...>2>1>0) and gets the largest base needed to represent it.

Change the 54 into a 76 to make it work for lowercase (but no longer upper case).

deleted 216 characters in body
Source Link
user34736
user34736

Python, 74 6464 56 bytes

x,i=inputx=input(),2
while 1:
 try:printa=ord(intmax(x,i),i);break
 except:i+=1

Alternative 64 bytes

x=input();i=z=2-54
whileif za<8:a+=7
 try:print(int(x,ia),ia);z=0
 except:i+=1

This is case-insensitivesensitive, requiring upper case letters, and loops forevercrashes for invalid input (e.g. "$^$%!(&£%)())

This code uses Pythons built-in int to try and convertgets the max letter in the string into base 10. It starts at base 2 and tries all. If there is an error (It is notz>x>y>...>b>a>9>8>...>2>1>0) and gets the largest base needed to represent it.

Change the i54), it continues after incrementing into a i76. It does this until to make it successfully prints the numberwork for lowercase as well.

Python, 74 64 bytes

x,i=input(),2
while 1:
 try:print(int(x,i),i);break
 except:i+=1

Alternative 64 bytes

x=input();i=z=2
while z:
 try:print(int(x,i),i);z=0
 except:i+=1

This is case-insensitive, and loops forever for invalid input (e.g. "$^$%!(&£%)())

This code uses Pythons built-in int to try and convert the string into base 10. It starts at base 2 and tries all. If there is an error (It is not base i), it continues after incrementing i. It does this until it successfully prints the number.

Python, 74 64 56 bytes

x=input()
a=ord(max(x))-54
if a<8:a+=7
print(int(x,a),a)

This is case-sensitive, requiring upper case letters, and crashes for invalid input (e.g. "$^$%!(&£%)())

This code gets the max letter in the string (z>x>y>...>b>a>9>8>...>2>1>0) and gets the largest base needed to represent it.

Change the 54 into a 76 to make it work for lowercase as well.

added 21 characters in body
Source Link
user34736
user34736
Loading
added 21 characters in body
Source Link
user34736
user34736
Loading
Source Link
user34736
user34736
Loading