Post History
Sandbox
How many odd digits? [FINALIZED]
#2: Post edited
How many odd digits?
- How many odd digits? [FINALIZED]
- Given a positive integer, count its odd digits.
- ## Input
- - An integer from 1 to 999,999,999, inclusive.
- ## Output
- - The number of odd digits in the input.
- ## Test cases
- Test cases are in the format `input : output`.
- ```text
- 1 : 1
- 2 : 0
- 3 : 1
- 4 : 0
- 5 : 1
- 6 : 0
- 7 : 1
- 8 : 0
- 9 : 1
- 10 : 1
- 11 : 2
- 12 : 1
- 13 : 2
- 14 : 1
- 15 : 2
- 16 : 1
- 17 : 2
- 18 : 1
- 19 : 2
- 20 : 0
- 111111111 : 9
- 222222222 : 0
- 123456789 : 5
- 999999999 : 9
- ```
- ## Scoring
- This is a [code golf challenge]. Your score is the number of bytes in your code. Lowest score for each language wins.
- > Explanations are optional, but I'm more likely to upvote answers that have one.
- [code golf challenge]: https://codegolf.codidact.com/categories/49/tags/4274 "The code-golf tag"
- # Now posted: [How many odd digits?](https://codegolf.codidact.com/posts/292354)
- ---
- Given a positive integer, count its odd digits.
- ## Input
- - An integer from 1 to 999,999,999, inclusive.
- ## Output
- - The number of odd digits in the input.
- ## Test cases
- Test cases are in the format `input : output`.
- ```text
- 1 : 1
- 2 : 0
- 3 : 1
- 4 : 0
- 5 : 1
- 6 : 0
- 7 : 1
- 8 : 0
- 9 : 1
- 10 : 1
- 11 : 2
- 12 : 1
- 13 : 2
- 14 : 1
- 15 : 2
- 16 : 1
- 17 : 2
- 18 : 1
- 19 : 2
- 20 : 0
- 111111111 : 9
- 222222222 : 0
- 123456789 : 5
- 999999999 : 9
- ```
- ## Scoring
- This is a [code golf challenge]. Your score is the number of bytes in your code. Lowest score for each language wins.
- > Explanations are optional, but I'm more likely to upvote answers that have one.
- [code golf challenge]: https://codegolf.codidact.com/categories/49/tags/4274 "The code-golf tag"
#1: Initial revision
How many odd digits?
Given a positive integer, count its odd digits. ## Input - An integer from 1 to 999,999,999, inclusive. ## Output - The number of odd digits in the input. ## Test cases Test cases are in the format `input : output`. ```text 1 : 1 2 : 0 3 : 1 4 : 0 5 : 1 6 : 0 7 : 1 8 : 0 9 : 1 10 : 1 11 : 2 12 : 1 13 : 2 14 : 1 15 : 2 16 : 1 17 : 2 18 : 1 19 : 2 20 : 0 111111111 : 9 222222222 : 0 123456789 : 5 999999999 : 9 ``` ## Scoring This is a [code golf challenge]. Your score is the number of bytes in your code. Lowest score for each language wins. > Explanations are optional, but I'm more likely to upvote answers that have one. [code golf challenge]: https://codegolf.codidact.com/categories/49/tags/4274 "The code-golf tag"