Comparing Digit Frequencies X63655


Statement
 

pdf   zip   main.py

html

Write a function compare_digits(p, q) that tells whether every digit (non-negative integer less than 10) of p occurs in q at least as often as it occurs in p. Borh p and q are positive integers.

Observation

Consider using as auxiliary function your (correct!) solution to X40706.

Sample session
>>> compare_digits(123, 321)
True
>>> compare_digits(1213, 33221)
False
>>> compare_digits(12, 22)
False
>>> compare_digits(314159, 112233456789)
True
Information
Author
Jordi Delgado \& José Luis Balcázar
Language
English
Official solutions
Python
User solutions
Python