dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
1.9 KiB
1.9 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 68c497f3aaefc9fd9f1b0e26 | Challenge 62: Hex to Decimal | 29 | challenge-62 |
--description--
Given a string representing a hexadecimal number (base 16), return its decimal (base 10) value as an integer.
Hexadecimal is a number system that uses 16 digits:
0-9represent values0through9.A-Frepresent values10through15.
Here's a partial conversion table:
| Hexadecimal | Decimal |
|---|---|
| 0 | 0 |
| 1 | 1 |
| ... | ... |
| 9 | 9 |
| A | 10 |
| ... | ... |
| F | 15 |
| 10 | 16 |
| ... | ... |
| 9F | 159 |
| A0 | 160 |
| ... | ... |
| FF | 255 |
| 100 | 256 |
- The string will only contain characters
0–9andA–F.
--hints--
hex_to_decimal("A") should return 10.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(hex_to_decimal("A"), 10)`)
}})
hex_to_decimal("15") should return 21.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(hex_to_decimal("15"), 21)`)
}})
hex_to_decimal("2E") should return 46.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(hex_to_decimal("2E"), 46)`)
}})
hex_to_decimal("FF") should return 255.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(hex_to_decimal("FF"), 255)`)
}})
hex_to_decimal("A3F") should return 2623.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(hex_to_decimal("A3F"), 2623)`)
}})
--seed--
--seed-contents--
def hex_to_decimal(hex):
return hex
--solutions--
def hex_to_decimal(hex):
return int(hex, 16)