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
71 lines
1.5 KiB
Markdown
71 lines
1.5 KiB
Markdown
---
|
|
id: 699c8e045ee7cb94ed2322db
|
|
title: "Challenge 220: Largest Number"
|
|
challengeType: 29
|
|
dashedName: challenge-220
|
|
---
|
|
|
|
# --description--
|
|
|
|
Given a string of numbers separated by various punctuation, return the largest number.
|
|
|
|
- The given string will only contain numbers and separators.
|
|
- Separators can be commas (`","`), exclamation points (`"!"`), question marks (`"?"`), colons (`":"`), or semi-colons (`";"`).
|
|
|
|
# --hints--
|
|
|
|
`largest_number("1,2")` should return `2`.
|
|
|
|
```js
|
|
({test: () => { runPython(`
|
|
from unittest import TestCase
|
|
TestCase().assertEqual(largest_number("1,2"), 2)`)
|
|
}})
|
|
```
|
|
|
|
`largest_number("4;15:60,26?52!0")` should return `60`.
|
|
|
|
```js
|
|
({test: () => { runPython(`
|
|
from unittest import TestCase
|
|
TestCase().assertEqual(largest_number("4;15:60,26?52!0"), 60)`)
|
|
}})
|
|
```
|
|
|
|
`largest_number("-402,-1032!-569:-947;-633?-800!-1012;-402,-723?-8102!-3011")` should return `-402`.
|
|
|
|
```js
|
|
({test: () => { runPython(`
|
|
from unittest import TestCase
|
|
TestCase().assertEqual(largest_number("-402,-1032!-569:-947;-633?-800!-1012;-402,-723?-8102!-3011"), -402)`)
|
|
}})
|
|
```
|
|
|
|
`largest_number("12;-50,99.9,49.1!-10.1?88?16")` should return `99.9`.
|
|
|
|
```js
|
|
({test: () => { runPython(`
|
|
from unittest import TestCase
|
|
TestCase().assertEqual(largest_number("12;-50,99.9,49.1!-10.1?88?16"), 99.9)`)
|
|
}})
|
|
```
|
|
|
|
# --seed--
|
|
|
|
## --seed-contents--
|
|
|
|
```py
|
|
def largest_number(s):
|
|
|
|
return s
|
|
```
|
|
|
|
# --solutions--
|
|
|
|
```py
|
|
import re
|
|
def largest_number(s):
|
|
numbers = [float(n) for n in re.split(r'[,!?:;]', s)]
|
|
return max(numbers)
|
|
```
|