FunctionRacerProblemsRace

Hex String to Decimal

BeginnerMathPython, JavaScript, TypeScript

The string s is a number in hexadecimal: each character is a digit 0 to 9 or a lowercase letter a to f (worth 10 to 15). Return its value as an integer. Do not use int(s, 16).

Example 1

s "ff"
returns 255

15*16 + 15 = 255.

Example 2

s "1a"
returns 26

16 + 10 = 26.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Math problems