[Community Puzzle] Fibonacci's Rabbit

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.

3 Likes

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.

2 Likes

I liked it, I found the loops not as easy to write as I expected :stuck_out_tongue: 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 ?

1 Like

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 (2
T4)
_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. :slight_smile:

1 Like

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