Skip to main content
6 of 6
Commonmark migration

Jelly, 6 3 bytes

-3 bytes by having I/O as a decimal list of digits.

ṫTṪ

Test suite at Try it online!

How?

ṫTṪ - Main link: listOfDigits  e.g.  [1,    0,    2,    0]  or [1,      1,    9  ]
 T  - truthy indexes                 [1,          3      ]     [1,      2,    3  ]
ṫ   - tail (vectorises)              [[1,0,2,0],  [2,0]  ]     [[1,1,9],[1,9],[9]]
  Ṫ - tail pop                                    [2,0]                       [9]

If we could not take decimal lists a 6 byter is:

DµṫTṪḌ

Which you can see here.

This does the same thing, but converts an integer to a decimal list beforehand and converts back to an integer afterwards.

Jonathan Allan
  • 110.1k
  • 7
  • 65
  • 282