Files
wehub-resource-sync 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
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

1.4 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
6a1d9f98e819ed70a0e994dd Challenge 331: Nearest Multiple 29 challenge-331

--description--

Given two integers, round the first to the nearest multiple of the second.

--hints--

round_to_nearest_multiple(5, 3) should return 6.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(round_to_nearest_multiple(5, 3), 6)`)
}})

round_to_nearest_multiple(17, 4) should return 16.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(round_to_nearest_multiple(17, 4), 16)`)
}})

round_to_nearest_multiple(43, 5) should return 45.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(round_to_nearest_multiple(43, 5), 45)`)
}})

round_to_nearest_multiple(38, 11) should return 33.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(round_to_nearest_multiple(38, 11), 33)`)
}})

round_to_nearest_multiple(93, 12) should return 96.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(round_to_nearest_multiple(93, 12), 96)`)
}})

--seed--

--seed-contents--

def round_to_nearest_multiple(num, multiple):

    return num

--solutions--

def round_to_nearest_multiple(num, multiple):
    return round(num / multiple) * multiple