The Bridge-Troll's Chiselled Toll
The toll for crossing the bridge at bitwick is chiselled into the stone at the bridge-head: one long row of digits, read left to right as a number. The town has bought the right to have the mason strike digits out of that row, and she will strike exactly `k` of them. Digits left standing keep the order they were carved in, and the shortened row is then read as the toll.
toll is a string of one or more characters, each one of 0-9. It may begin with zeros. k is an integer with 0 <= k <= the length of toll.
Return a string: the smallest number that can be read off the stone after exactly k digits have been struck out, written with no leading zeros. If no digits remain, or all remaining digits are zeros, return "0".
examples
- case 1
toll of "1432219", k of 3"1219" - case 2
toll of "10200", k of 1"200" - the row reads 0200, and leading zeros are not written - case 3
toll of "10", k of 2"0" - nothing remains on the stone - case 4
toll of "112", k of 1"11" - no digit is bigger than the one after it, so the strike falls at the right end
- reward
- 360 XP
- signature
smallestToll
TypeScript, run as ES2022 — types are stripped, not checked. If a JS engine would run it, so will we.
- the posted toll
- a zero in the middle
- nothing left to pay
- the mason strikes nothing
- zeros already carved in front
- strikes to spare
- a falling row
- only zeros remain
- a single digit struck away
- the long tally at the bridge-head