Mayan Calculation puzzle discussion

Hello, I have the same problem with the 'Base 20" validator.

Anyone have an idea of why ?

Hi,

Iā€™m validating all the tests but the test ā€œDivisionsā€ is the only one not validated after. Am I the only one ?

Thanks !

Bonjour,

Jā€™ai validĆ© tous les tests mais le tests ā€œDivisionsā€ lui ne passe pas et je ne comprend pas pourquoi. Suis-je le seul ?

Merci !

Same for me !

Idem pour moi !

Hi, I also have a failed final Division test, but on the test execution itā€™s green and other tests also are green. Maybe issue in our code, but without additional test cases itā€™s hard to understand whatā€™s working in the wrong way. Does anyone has additional test data for the division test?

UPD: What kind of output should be if divisor is 0?

Totally stuck here. All the tests work except for the large multiplication one.

Donā€™t want to give away any answers here, but my last value Iā€™m printing is 8 (printing the equivalent text). This is the last of 7 numbers that were printed.

Can someone please tell me if Iā€™m on the right track.

I have the first value as 12345 and second 789012 given itā€™s multiplied that leaves me with 1150418548

Was using INTs instead of Int64

With regard to Base20 test case, I had that problem as well. The solution was to revisit the portion where you ā€œread inā€ and convert each number (1 and 2) into a decimal. In my situation, I was mistakenly assigning 2 lines to a numeral, instead of 1 (which is what the height is), and that was because of a faulty logic in my if() clause. I think if you review that portion and try to print debug messages, youā€™ll find where you make a mistake. It certainly helped me.

1 Like

Hi,

I agree with @connie_zest - your issue should be in a function that reads initial input (var numeral). I had an error in statements of FOR loop (JavaScript). Here is a brief explanation of this error:

var numeral = ā€œ0123456789ABCDEFGHIJā€; (20 symbols)

my wrong loop:

for(var a=1; a<numeral.length; a++){ā€¦} (reads only 19 symbols)

so I only needed to update the middle statement in my loop:

for(var a=1; a<**=**numeral.length; a++){ā€¦}

In this exercise it is important not to forget that BASE20 system has 20 numerals, starting from 0. (comment for myself mainly) :relaxed: Although, interesting thing is that my code passed the initial BASE20 test without ā€œJā€ numeral.

I hope this helps!

2 Likes

I got the same problem, when submitting my code, ā€˜divisionā€™ test fails. Does someone has a solution, an idea ?

I have the same problem: validation test with ā€œDivisionā€ fails.

Logically, it seems unlikely that there would be a problem in parts of code that converts symbols to numbers, base20 to base10 and vice versa or everything else wouldā€™ve failed.

So itā€™s likely that itā€™s a problem that is unique to division. I went back to my code and put int() in front of every division so a float doesnā€™t show up and made sure all /'s are read correctly.

I ran the code in IDLE with some test cases I generated myself that does division and everything works fine.

Iā€™m at a loss. Coding in python3.

I figured out my problem.

The part of code that converts base10 back into base20 was faulty and unable to handle base10 numbers like 20, 400, 8000 correctly.

So maybe if youā€™re failing only the divisions validation, this could be your problem, too.

Hi !

I do not understand I have that ā€œgreat multiplicationā€ of incorrect and this is wrong at the first Mayan figure.

My total result is 1150418548 and the nearest power divisor is 64000000

I therefore deduce that the first figure is 17. But the program tells me that he expects the number 7 (in Maya).

I have done it by hand by displaying the variables, I get the same result as my program (17) and this is the only one where I cale :frowning:

EDIT : My bad it was because the type int is limited ^^

Hi !
I have a little problem in C++. My code doesnā€™t pass the ā€œbig multiplicationā€ test. So Iā€™ve tried with long long int : same problem. Then iā€™ve manually tried to print the result of 12345*789012 and the result is wrong ! Same issue in C, but not in python.
Whatā€™s wrong ?

Are your ints long enough?

Yeah, but the probleme is that even typing ā€œcout<<12345*789012;ā€ the result is wrongā€¦

You are doing int-multiplication with integers that are too big. Try cout<<12345L*789012; or cout<<(long)12345*789012. Thats the long-multiplication.

Your problem is probably this:

int x = 12345;
int y = 789012;
long r = x*y; // wrong: int*int -> int-multiplication

The values for x and y are small enough, so you can save them in ints. The result is too big for an int, so you save it in a long. So far so good. But if you take x*y you get the int result of two ints, not the long result you want.

You have to make sure you use the long multiplication. Details depend on the language. Thatā€™s why your Python code works and your C code doesnā€™t.

int x = 12345;
int y = 789012;
long r = (long)x*y; // right: long*int -> long-multiplication
long x = 12345;
long y = 789012;
long r = x*y; // right: long*long -> long-multiplication
1 Like

I did not know that ! Thank you ! :slight_smile:

1 Like

Hi, I had the same issue, and your message helped me: I checked the reading of numeral variable and appeared that function parsed first 20 symbols without ā€œJā€ (and test BASE20 passed so as in your case).

Regarding Base 20 I am having a problem.
In base 10 the desired result after applying the operator is 134668800 (=160320*840).
As I pass to base 20 I get 221DC00, which eems to be the true value.
However, the the correct solution accepted here is 221DC.
Am I missing something? Or is the solution accepted wrong?
Thanks in advance!

Although I didnā€™t understand your problem, are you sure you have all values in LONG and not INT?