Coding Games and Programming Challenges to Code Better
Send your feedback or ask for help here!
Created by @Diabetos,validated by @Timinator,@yveslacroix83400 and @jddingemanse.
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 @Diabetos,validated by @Timinator,@yveslacroix83400 and @jddingemanse.
If you have any issues, feel free to ping them.
Only validator 6 result is over 2^63 (but still below 2^64). This makes the puzzle unnecessarily complicated in languages that have only āsigned int64ā support, but not āunsigned int64ā support.
To be honest i didnāt check this, because i supposed it was a standard data type supported in every language, My bad. What language does not support it ?
I donāt program in Java, but there might be problems.
The ones Iām aware of are Java (no unsigned), php (no unsigned), javascript (double - roughly 2^53). They all have biginteger support so the problem is still possible but slightly more complicated if using one of those languages.
I liked it, I found the loops not as easy to write as I expected thank you !
I got stuck a while with the bigInt test until I understood I needed a bigInt. In javascript there is no error and the number calculated by my code was truncated but really close to the expected answer (only 95 of difference). It was funny to figure it out.
I agree with the others, it may be difficult for beginners to think of that, especially depending on the language.
I donāt understand tests 7 and 8. Why the result is 64 for test 7 and 2066850 for test 8?
What do you think the answer should be, and what is your calculation (say, list the first few steps)?
The problem is that itās a validator (12 for me) which is not working with a classic code in phpā¦It can be hard to guess that itās a problem with large numbers. Should be a good thing to swap validator 12 and test 12 no ?
For test 7:
_At T0: nb of pairs = 8
_At T1: nb of pairs = 8
_At T2: nb of pairs = 8
_At T3: nb of pairs = 8
_At T4: nb of pairs = 16 (2T3)
_At T5: nb of pairs = 32 (2T4)
_At T6: nb of pairs = 24 (T1+T2+T3)
_At T7: nb of pairs = 32 (T2+T3+T4)
_At T8: nb of pairs = 56 (T3+T4+T5)
_At T9: nb of pairs = 72 (T4+T5+T6)
_At T10: nb of pairs = 88 (T5+T6+T7)
_At T11: nb of pairs = 112 (T6+T7+T8)
_At T12: nb of pairs = 160 (T7+T8+T9)
Hi,
For Test 7 it should be:
T0: 8
T1: 0
T2: 0
T3: 8 (T0)
T4: 8 (T0 + T1)
T5: 8 (T0 + T1 + T2)
T6: 8 (T1 + T2 + T3)
T7: 16 (T2 + T3 + T4)
...
The initial pairs are only old enough to produce new pairs starting at T3
Seeing the comments here I realised I set the maximum to be under 2^64 so it could be done in every languages, I didnāt know there was no unsigned in some language, if itās not too late to change that now that it is published Iāll edit that because even if there was the fact that the issue only occur on a validator is no good.
Itās ok to edit the puzzle to remove the issues which prevent players of some programming languages from completing it.
I set the maximum to be under 2^64 so it could be done in every languages
It would not be good enough for javascript, which has a max int value (2^53) -1
Itās no big deal, javascript can have numbers up to 2^1024, youāre not the first one I see telling that but you have not any problem with overflows in js, Iām no expert but Iām pretty sure js only has the type ānumberā for floats and ints and it can go way higher than 2^53, itās not even like you had to specify you want a big number. No issue there
Well I realise I said something really wrong, it must have been too long since I last did Js, you can overcome the 2^53-1 limit by using BigInt. Something like the following will print the exact good answer:
const num = BigInt(2**64);
console.log(num.toString());
// Output : 18446744073709551616