← Back to challenges

Ones, Threes and Nines (Version #1)

PythonHardclassesnumbersmath

Instructions

Given an int, figure out how many ones, threes and nines you could fit into the number. You must create a class. You will make variables (self.ones, self.threes, self.nines) to do this.

Examples

n1 = ones_threes_nines(5)
n1.nines ➞ 0

n1.ones ➞ 5

n1.threes ➞ 1

Notes

  • Do not use the math module.
  • See version #2 of this series.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: RegEx VIII-B: Digit Character Class