suggestions for pattern diff?

z
zoe_matrullo (2090 points)
4 8 12
asked Dec 18, 2021 in HW8 by zoe_matrullo (2,090 points)
edited Dec 18, 2021 by zoe_matrullo
Hi everyone!

I currently pass all the tests except the ones with pattern_diff_ since I can't manage to remove the images that don't check the conditions. I know that the consecutive lines of pixels have to be different and that I should make sure every pixel with index x in a line is different from the pixels with index x-1, x and x+1 of the following line. I wrote a function that checks that condition but apparently it doesn't work. Since I work with trees I even try to build it while checking the condition to avoid making not valid images but it still returns all the possible combinations.

Can someone maybe give me some other ideas to approach the problem so that I can try to rethink it in a different way?

Thanks!!!
148 views

2 Answers

Best answer
gabrimat (5630 points)
2 2 25
answered Dec 19, 2021 by gabrimat (5,630 points)
selected Dec 19, 2021 by zoe_matrullo
While building the tree you should try to build the image already in perfect state. When the image is built in this way there are some cases where it will be incomplete, because not enough colors will be available. In that case the branch should stop there, and that "cut" branch should not be considered as a valid image.
z
zoe_matrullo (2090 points)
4 8 12
commented Dec 19, 2021 by zoe_matrullo (2,090 points)
ok thanks, I’ll work on that
Simone Russolillo (5790 points)
5 10 22
commented Dec 19, 2021 by Simone Russolillo (5,790 points)
I did the same!!!
z
zoe_matrullo (2090 points)
4 8 12
commented Dec 19, 2021 by zoe_matrullo (2,090 points)
I managed!! thanks a lot, your suggestion was very helpful!!!
gabrimat (5630 points)
2 2 25
commented Dec 19, 2021 by gabrimat (5,630 points)
Happy to help.
KilianS (3590 points)
5 9 27
answered Dec 18, 2021 by KilianS (3,590 points)
Maybe try other ideas to approach the problem or rethinking it in a different way
z
zoe_matrullo (2090 points)
4 8 12
commented Dec 18, 2021 by zoe_matrullo (2,090 points)
very useful Kilian, thanks