# Determine the algorithm

So I was given this puzzle quite some time ago and just thought it would make a nice addition to this site:

Your task is to determine the method how the result is determined from the given number. A few example cases include:

177383 -> 2
267453 -> 2
111111 -> 0
636240 -> 4
367183 -> 3
247123 -> 1
369108 -> 5


To those, who hit a brick wall, here is a tip: This puzzle is easiest for young children and gets harder the older you get... Happy guessing ;)

• Nice hint. It is really great. Jan 28, 2017 at 9:52

The number is the number of "holes" in the written decimal representation of the number.

More specifically, each digit contributes this much to the total number:

0: 1
1: 0
2: 0
3: 0
4: 0 or 1, depending on how you draw them
5: 0
6: 1
7: 0
8: 2
9: 1


In your case above, 4 is drawn with a hole, so it contributes 1.

• No spoiler here because there really isn't much I could leave exposed if I did choose to hide all the important details.
– user88
Nov 30, 2014 at 17:56
• This is right, but 0 has 2 holes, at least in the font used. I'm kind of surprised that you got it right even with this happening. Nov 30, 2014 at 17:57
• It's more a function of having seen these puzzles before. They're chestnuts.
– user88
Nov 30, 2014 at 17:57
• @mdc32: on the font that I'm using, 0 has only a single hole.
– user88
Nov 30, 2014 at 17:57
• I like the puzzle, but I would do away with the "harder the older you get" hint. That makes it too easy, because one immediately disregards maths. Maybe edit it? Nov 30, 2014 at 19:11

I included mathematics :)

The method is as follows:

2. If step 1's result has a 9, subtract 2
3. If step 1's result has a 6, add 1
4. If the original number has a 0, multiply by 2 then subtract 4
6. Mod 7 step 5's result

Now use this method on your numbers:

1 + 7 + 7 + 3 + 8 + 3 = 29
29 - 2 = 27
2 + 7 = 9
9 % 7 = 2

2 + 6 + 7 + 4 + 5 + 3 = 26
26 + 1 = 27
2 + 7 = 9
9 % 7 = 2

1 + 1 + 1 + 1 + 1 + 1 = 6
6 + 1 = 7
7 = 7
7 % 7 = 0

6 + 3 + 6 + 2 + 4 + 0 = 21
21 x 2 - 4 = 38
3 + 8 = 11
11 % 7 = 4

3 + 6 + 7 + 1 + 8 + 3 = 28
2 + 8 = 10
10 % 7 = 3

2 + 4 + 7 + 1 + 2 + 3 = 19
19 - 2 = 17
1 + 7 = 8
8 % 7 = 1

3 + 6 + 9 + 1 + 0 + 8 = 27
2 x 27 - 4 = 50
5 + 0 = 5
5 % 7 = 5

• Not what I was looking for, but creative :D Dec 1, 2014 at 7:16
• @ThreeFx damnit :D Dec 1, 2014 at 7:27
• In general, when the number of rules is equal or close to the number of cases, then the rules are made up to fit the data. Dec 1, 2014 at 8:24
• I know this is for fun, but your equation breaks on 600000 :) +1 for you May 8, 2015 at 19:11