This problem can be solved by pre-school children in five to ten minutes, by programmers in an hour and by people with higher education… well, check it yourself! What number comes at the question mark?
Simply count the number of "circles" in the digits of the number. The digit 8 has two circles in its shape so it counts as two, and 0 is one big circle so it counts as 1. As a result, $$2581 = 2$$.
Each of the partial Unix commands below already outputs a positive integer to stdout.
$ echo 8809 | ... 6 $ echo 7111 | ... 0 $ echo 2172 | ... 0 $ echo 6666 | ... 4
How should we complete the commands, such that they output the solution to the above conundrum to stdout for the given number?