All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Just Math
How Mean Is It? (Posted on 2023-10-07) Difficulty: 3 of 5
The teacher has recently set a class the following puzzle: "Write down four positive whole numbers less than 100 and then write down their average: choose the original numbers so that overall the five numbers written down use each of the digits 1 to 9 exactly once."

Three students in the class were successful. Heinrich came up with 9, 15, 36 and 48, with average 27. Felix was more cunning – his average was not a whole number – it involved a mixed fraction in its simplest form, like 27¾. Delphine was devious, too, and her average, which was lower than Felix's, was not a whole number – it involved decimals, like 16.25.

What averages did Felix and Delphine write?

See The Solution Submitted by K Sengupta    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Computer solution Comment 2 of 2 |
Felix's average:  25 3/4
Delphine's average:  24.75 (which was lower than Felix's)

Program Output:
Felix
1,7,9,86 with average 25 3/4
1,6,9,87 with average 25 3/4
1,6,7,89 with average 25 3/4
6,7,9,81 with average 25 3/4

Delphine
1,6,9,83 with average 24.75
1,3,9,86 with average 24.75
1,3,6,89 with average 24.75
3,6,9,81 with average 24.75
7,9,24,86 with average 31.5
6,9,24,87 with average 31.5
6,7,24,89 with average 31.5
7,9,26,84 with average 31.5
4,9,26,87 with average 31.5
4,7,26,89 with average 31.5
6,9,27,84 with average 31.5
4,9,27,86 with average 31.5
4,6,27,89 with average 31.5
6,7,29,84 with average 31.5
4,7,29,86 with average 31.5
4,6,29,87 with average 31.5
8,9,42,67 with average 31.5
7,9,42,68 with average 31.5
7,8,42,69 with average 31.5
8,9,47,62 with average 31.5
2,9,47,68 with average 31.5
2,8,47,69 with average 31.5
7,9,48,62 with average 31.5
2,9,48,67 with average 31.5
2,7,48,69 with average 31.5
7,8,49,62 with average 31.5
2,8,49,67 with average 31.5
2,7,49,68 with average 31.5


----------------------------------
import math
from itertools import permutations

print('Felix')
for p in permutations('123456789'):
    if int(p[7]) >= int(p[8]):
        continue
    if math.gcd(int(p[8]),int(p[7])) != 1:
        continue
    a = int(p[1])
    b = 10*int(p[2])+int(p[3])
    c = int(p[4])
    d = int(p[5])
    if a>c or a>d or c>d:
        continue
    avg = 10*int(p[0])+int(p[6]) + int(p[7])/int(p[8])
    if avg == (a+b+c+d)/4:
        print('{},{},{},{} with average {} {}/{}'.format(a,c,d,b,10*int(p[0])+int(p[6]),int(p[7]),int(p[8]) ))

print('Delphine')
for p in permutations('123456789'):
    a = int(p[1])
    b = 10*int(p[2])+int(p[3])
    c = int(p[4])
    d = int(p[5])
    if a>c or a>d or c>d:
        continue
    avg = 10*int(p[0])+int(p[6]) + int(p[7])/10 +int(p[8])/100
    if avg == (a+b+c+d)/4:
        print('{},{},{},{} with average {}.{}{}'.format(a,c,d,b,10*int(p[0])+int(p[6]),int(p[7]),int(p[8]) )) 

for p in permutations('123456789'):
    a = 10*int(p[0])+int(p[1])
    b = 10*int(p[2])+int(p[3])
    c = int(p[4])
    d = int(p[5])
    if a>b or c>d:
        continue
    avg = 10*int(p[6]) + int(p[7]) + int(p[8])/10
    if avg == (a+b+c+d)/4:
        print('{},{},{},{} with average {}.{}'.format(c,d,a,b,10*int(p[6])+int(p[7]), int(p[8]) )) 

  Posted by Larry on 2023-10-07 11:43:15
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (1)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (6)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information