Related: Program my microwave oven. Inspired by Generate lazy microwave input.
The lazy value of the non-negative integer N is the smallest of the integers that are closest to N while all their digits are identical.
Return (by any means) the lazy value of a given (by any means) N.
N ≤ the largest integer that your language represents in non-exponent form by default. 1000000 (A lot of interesting solutions are lost because of this too-high requirement.)
Test cases:
0 → 0
8 → 8
9 → 9
10 → 9
16 → 11
17 → 22
27 → 22
28 → 33
100 → 99
105 → 99
106 → 111
610 → 555
611 → 666
7221 → 6666
7222 → 7777
The colleague in question proved that there will be no ties: Except for 9/11, 99/111, etc. for which one is shorter than the other, two consecutive valid answers are always an odd distance apart, so no integer can be exactly equidistant from them.