this requires js (sorry)
INPUT:
OUTPUT
UPDATE: To my shock and horror, an
equivalent function
is implamented into JavaScript.