Disks over threshold
A free easy coding practice problem from sysadmin. Solve it in JavaScript, TypeScript or Python and check your solution against fresh hidden tests — edge cases and random inputs — as often as you like.
- Difficulty
- Easy
- Type
- Function
- Topic
- Sysadmin
- Languages
- JavaScript, TypeScript or Python
Problem
rows are lines of df output without the header: filesystem size used avail use% mountpoint, with fields separated by ONE OR MORE spaces (no field contains a space), e.g. "/dev/sda1 100G 85G 15G 85% /". Return the mount points whose use% (the integer before %) is at least threshold (0–100), sorted by use% DESCENDING, ties by mount point ascending (character-code order). Return [] when none qualify.
Function signature
// JavaScript
function mountsOverThreshold(rows, threshold)
// TypeScript
function mountsOverThreshold(rows: any, threshold: any): any
// Python
def mounts_over_threshold(rows, threshold):Examples
mountsOverThreshold(["/dev/sda1 100G 85G 15G 85% /","/dev/sdb1 500G 100G 400G 20% /data","tmpfs 2G 2G 0 100% /run"], 80)→["/run","/"]mountsOverThreshold(["/dev/sda1 10G 5G 5G 50% /"], 51)→[]
How checking works
Run your code against the examples above, then submit a check: it runs on the server against hidden tests built fresh each time, including edge cases and random inputs. Practice is untimed and never affects a verified score; when you are ready, take a graded coding challenge to earn a badge.