[Community Puzzle] Egyptian multiplication

Coding Games and Programming Challenges to Code Better

Send your feedback or ask for help here!

Hello!

I’m solving the “Egyptian multiplication” community puzzle and cannot pass the final test for some reason (probably the test verification data is wrong).
The input parameters for this case (“Bigger numbers”) are:
7675 * 179

the error I get is:
Found: = 15350 * 88 + 2
Expected: = 15350 * 88 + 7

which leads to the following line of my solution:
= 15350 * 88 + 23025

When I verify with calculator I get the correct value for this line (1373825 = 7675 * 179). That’s why I think that that the test data is wrong or maybe I’m missing something in general?

I think that 23025 is decomposed too.

1 Like

Hi,

You need to keep all the additions terms at each step.

= NUM1 * NUM2 + … + … + …

1 Like

Oh, I see. Thank you very much guys!

Hi

I don’t understand how the egyptian multiplication works
It’s said “First, sort the two numbers.
Then follow the steps below, the algorithm uses base-2 decomposition of the biggest number.”
but in the example 12 * 5 we divide the 5 by 2

maybe if someone can give me the first line for 7675 * 179 I will be able to solve the puzzle

Thanks

Hi

Here are the first lines of the answer:
7675 * 179
= 7675 * 178 + 7675
= 15350 * 89 + 7675
= 15350 * 88 + 7675 + 15350

I hope this is enough to get the idea.

Good luck!

Thanks for the reply

I’ll think about it

A slight error in the puzzle: it’s the decomposition of the smallest, not of the biggest.

2 Likes

Another puzzle where test validators are not quite sufficient :frowning: I pass all tests but get only 75%. My code doesn’t pass validator 2 but I have absolutely no way of knowing why.

Validator 2 seems ok to me. I PM you the validator input so you can find the issue in your code.

Thank you for your help. My error was pretty dumb, but it did slip through test validators. It occurred only when there were steps with no “unmultiplied” integers at the end of the line, but not in test validator 2 because then my code went directly to the next odd multiplier value. In test validator 2, that occurs directly so my code didn’t skip a line like it did in real validator 2.

hello, My code pass all tests except the validator 2.
I tried other test of my own but without finding the problem.
Could you help me debug my code?