# [Community Puzzle] Tiny Forest

Coding Games and Programming Challenges to Code Better

Created by @AdrienLB,validated by @Timinator,@lllllllllllllllllll1 and @FredericLocquet.
If you have any issues, feel free to ping them.

Hi there,

I just finished this tiny forest puzzle, and my first impression is that there are missing test cases.
To cover more cases that help understand the logic behind this puzzle you could add this test case:

one-tree-2
Input:

``````5
5
. . . . .
. . . . .
. . Y . .
. . . . .
. . . . .
``````

Expected Output:

``````23
``````

This one shows that the seed could be placed under a space occupied by â€śa tree when you donâ€™t plant the initial seedâ€ť.

It may seems like a corner case, but my initial solution passed all existing test cases but failed 2 validators. It goes without saying that it was not hard-coded

1 Like

@AdrienLB Did you have a look ?

The author is last seen on the forum around 2 months ago, so they probably havenâ€™t read your messageâ€¦

Could any approver @Timinator,@lllllllllllllllllll1 and @FredericLocquet take a look?

What language did you write your initial solution in? Is it published? Iâ€™d like to explore this a bit more with you and see how your solution can pass all test cases, but not all validators.

Letâ€™s assume we have your 5x5 plot of land with one tree already on the middle spot. Even if you donâ€™t plant any seed at all, the resulting forest will cover the entire 5x5 plot except for the four corners. A single seed placed in the middle row or the middle column on a 5x5 plot of land will produce a pattern that will cover the two closest corners, but not the two distant corners. So, yes, I believe your proposed test case is accurate. However, I need help understanding what situation is covered by this test case that is not covered in the existing test cases?

Hey @Timinator thank you for looking into this !
My solution is published, in Rust.

I also have the code that passes all tests but not the all validators.
Can we discuss the solution here without spoiling people or should we take it elsewhere ?

ps: @5DN1L thanks for the heads up

1 Like

I will send you a PM where you can share your code privately.

Hello, sorry I didnâ€™t know this forum part existed, I havenâ€™t had notifications before.
I will look at your problem asap !!

I donâ€™t think there are any notification on the website, which is a shame !

Did I miss something? Are we going to look at the code that passes all test cases but not all validators? I never saw any code. I miss things all the time, so I might just need to be pointed in the right direction.

Sorry, I was in the process of answering you yesterday, and got taken in by some code
You have the code in PM, and I added @AdrienLB to the discussion.

1 Like

I will answer there too :
I didnâ€™t read and understand your code, donâ€™t know rust, but I think I donâ€™t need.
The output is somewhat clear, you are doing a simple run without planting seed and then you determine what is the best place from the places left.

YEAR 33
,Y,Y,Y,
Y,Y,Y,Y,Y
Y,Y,Y,Y,Y
Y,Y,Y,Y,Y
,Y,Y,Y,

YEAR 0
X, , , ,
, , , ,
, ,Y, ,
, , , ,
, , , ,

Like above you put the seed in the corner, to fill one of the four empty spaces, but if you put it at equal distance from two empty spot it will cover in the end two corner not one.
Solution should be:
, , X , ,
, , , ,
, ,Y, ,
, , , ,
, , , ,
So you will have one more tree in the end.
Thank you @OoLaVache for pointing this problem
Thank you @Timinator for asking for the code

Tell me if everything is ok now

I need some time to implement the difficult version of this puzzle, but diablo4 just went out, so later xD

1 Like

The new test case correctly failed with my code that wasnâ€™t passing the validators.

1 Like

Great puzzle, but the instructions need minor clarification.

You say that â€śseeds need 10 years to grow into a treeâ€ť. This can only mean that a seed that is less than ten years old is not a tree.

The task is to â€śfind the maximum number of trees after 33 years you can have by planting the seed at the best placeâ€ť. From the first statement, one can only conclude that seeds less than 10 years old at the 33rd year should not be counted as trees for this purpose.

Only from running the test cases does it becomes clear that your intent was to say that â€śA seed is counted as a tree, but does not produce more seeds for 10 years after it is planted or dropped by a parent tree.â€ť

Actually, i hv also tried to solve it. During its solving , i just wanted to know how to determine seeds nd trees specific positions over the iterations.

[nope]
pfa(attached_proof):