Compress the Digits X44100


Statement
 

pdf   zip   main.py

html

Write a function compress(n) that, given a positive integer n, returns the number obtained by deleting from n all digits (non-negative integers less than 10) that repeat the digit at their left.

Observation

All integers are assumed written in the usual base 10.

Sample session
>>> compress(1234)
1234
>>> compress(12234441)
12341
>>> compress(3)
3
>>> compress(11200000013333)
12013
Information
Author
Jordi Delgado \& José Luis Balcázar
Language
English
Official solutions
Python
User solutions
Python