Coding Games and Programming Challenges to Code Better
Send your feedback or ask for help here!
Created by @java_coffee_cup,validated by @Westicles,@FredericLocquet and @cg123.
If you have any issues, feel free to ping them.
Coding Games and Programming Challenges to Code Better
Send your feedback or ask for help here!
Created by @java_coffee_cup,validated by @Westicles,@FredericLocquet and @cg123.
If you have any issues, feel free to ping them.
Hey everyone
I think the problem is a fun exercise and it’s great it’s here.
However does it really need to be gendered in this way?
We all know that in the tech industry we struggle to attract diverse people and codingame is the first contact with development for a lot of people. So I think it’s too bad that an exercise on this website conveys genders stereotypes like “girls don’t want boys to know their weight”.
I think it should be pretty straightforward to reword it lightly to make it a group of people or to find another story explaining why an observer would only have access to the grouped measurements.
I’m not sure what’s the process to do this kind of change but if I can be helpful I’m up to give a hand rewording the exercise
This puzzle would be more appropriate on a math forum
Great little brain-teaser. Another excellent production from java_coffee_cup.
This doesn’t need loops. Just some basic calculations.
Find s = sum of total weights to 5 girls by calculating sum of pairs of weights divide by 4.
Calculate the middle girl by subtracting s to the first pair and the last pair.
Focus on the first two sums and the last two sums and the weight of the middle girl.
Sum of weights of 5 girls and the middle girl:
w = []
for i in input().split(): w.append(int(i))
c = sum(w)//4 - w[0] - w[-1]
Hello everyone,
I think this exercise is missing some informations about the order the people are paired up.
indeed their is not only one possible ordering.
For instance, I would assume that for people A, B, C, D, E , the order would be:
AB AC AD AE BC BD BE CD CE DE
The order isn’t needed to be known (and if you did know it it would be a much easier problem to solve).
some hints to solve this puzzle :
Let say we have 5 girls with weights ( A,B,C,D and E) Where : A <= B <= C <= D < E
so :
min = A+B is the minimum pairwise weight
max = D+E is the maximum pairwise weight
A+B < A+C < … < C+E < D+E
the sum of all 10 pairwise weight measurements :
sum = (A+B) + (A+C) + (A+D) + (A+E) + (B+C) + (B+D) + (B+E) + (C+D) + (C+E) + (D+E)
= 4 * A + 4 * B + 4 * C + 4 * D + 4 * E
= 4 * (A + B + C + D + E)
Therefore :
you can calculte the weight C :
you can solve the rest by yourself
thanks to @khanglovesIT for the hints
Actually you used loop for summing up values into w array.
Well, algebra is a longtime forgotten memory for me. I went into a full equation solver starting from the weights. However, my paper solution did not cover all the possibilities
I should have checked this forum earlier, for this simple 4abcd*e solution. Another “strive for simplicity” problem. Thanks, great exercice.
I understand the reasoning, and i get why you get C that way, but i thought this would apply to all of the weights, as in:
A < B < C < D < E
A + B = X0
A + C = X1
A + D = X2
A + E = X3
B + C = X4
B + D = X5
B + E = X6
C + D = X7
C + E = X8
D + E = X9
(A+B)+(A+C)+..(C+E)+(D+E) = SUM(X0..X9)
4*(A+B+C+D+E) = SUM(X0..X9)
A+B+C+D+E = SUM(X0..X9) / 4
A+B+C+D+E = S
A+B+C+D+E - (B+C) - (D+E) = S - X4 - X9
A = S - X4 - X9
A+B+C+D+E - (A+C) - (D+E) = S - X1 - X9
B = S - X1 - X9
A+B+C+D+E - (A+B) - (D+E) = S - X0 - X9
C = S - X0 - X9
A+B+C+D+E - (A+B) - (C+E) = S - X0 - X8
D = S - X4 - X9
A+B+C+D+E - (A+B) - (C+D) = S - X0 - X7
E = S - X0 - X7
why is it that only C is correct this way?
your algorithms uses the order of all pairweights to find the weights of all girls but
the order might change from an example to another so your method might not work
here’s an example :
A = 5 | A = 1
B = 6 | B = 2
C = 7 | C = 50
D = 8 | D = 75
E = 9 | E = 100
----------------------------------------
A + B = 11 | A + B = 3
A + C = 12 | A + C = 51
A + D = 13 | B + C = 52 <=
B + C = 13 | A + D = 76 <=
A + E = 14 | B + D = 77 <=
B + D = 14 | A + E = 101 <=
B + E = 15 | B + E = 102 <=
C + D = 15 | C + D = 125
C + E = 16 | C + E = 150
D + E = 17 | D + E = 175
A + B
A + C
C + E
D + E
Nice puzzle; I was not smart enough to do it without the help of the eye opener by khanglovesIT.