7 kyu

[Code Golf] - Oddity Count

Description:

Task

You are given a positive integer n, and your goal is to compute the count of odd digits in the number n.

Special Condition

You need to count how many digits in n are odd (1, 3, 5, 7, 9).

Constraints

  • The input n will be a positive integer such that 5 ≤ n ≤ 9999999.
  • The result should reflect the count of odd digits in the number n.
  • Code golf restriction: maximum solution length of 37 characters.

Example

For instance:

  • The count of odd digits in 234 is 1 (only the digit 3 is odd).

  • For the number 405, the count of odd digits is 1 (only 5 is odd).

  • For the number 111, the count of odd digits is 3 (all digits are odd).

  • For the number 2468, the count of odd digits is 0 (all digits are even).

  • You cannot use built-in functions (like str(), eval(), sum(), etc.)

  • You also cannot import any external modules or libraries.


    Good luck!
Mathematics
Algorithms
Restricted

More By Author:

Check out these other kata created by MLYTC1

Stats:

CreatedNov 19, 2024
PublishedNov 19, 2024
Warriors Trained230
Total Skips7
Total Code Submissions1471
Total Times Completed54
Python Completions54
Total Stars8
% of votes with a positive feedback rating87% of 23
Total "Very Satisfied" Votes17
Total "Somewhat Satisfied" Votes6
Total "Not Satisfied" Votes0
Total Rank Assessments10
Average Assessed Rank
7 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • MLYTC1 Avatar
  • dfhwze Avatar
Ad