Letters and Numbers X91355


Statement
 

pdf   zip

html

Given a string containing letters and numbers, the implicit value of the string is the integer value obtained by removing the letters and then reading out the digits.

For example, the implicit value of 16Dec2019 is 162019 and the implicit value of a1B2c3D is 123.

The implicit value of a string without digits is zero.

Write a function i_val(lst) that receives a list of strings made up of letters and numbers, and returns the corresponding list of implicit values, sorted by their nummerical value.

Sample session
>>> i_val(['Dec16of2019', 'a1B2c3D'])
[123, 162019]
>>> i_val(['a21', 'b2']) + i_val(['1j5k'])
[2, 21, 15]
>>> i_val(['456x654', 'NoDigitsHere', 'xyz7zxy', '007Bond', ''])
[0, 0, 7, 7, 456654]
>>> i_val([])
[]
Information
Author
ProAl
Language
English
Official solutions
Python
User solutions
Python