cd155 / algorithm-design-with-haskell

Using Haskell to Cracking the Code Interview
0 stars 0 forks source link

Paint fill function for an image #3

Open cd155 opened 1 year ago

cd155 commented 1 year ago

This is the paint-fill function. @balacij

https://github.com/cd155/algorithm-design-with-haskell/blob/b3f39e54e38a4f067fb10c3ced4c1ef04ada3432/src/Recursion.hs#L372-L499

Let me know what you think. I think there should be a way to simplify the findAreaOnDir method. It looks very cumbersome.

cd155 commented 1 year ago

I made a better version for the fill-up painting function. @balacij

https://github.com/cd155/haskell-leetcode/blob/318932061f78ee5ecfccef00c33def5e88ae00a1/main/WeekOne.hs#L329-L399

balacij commented 1 year ago

Looks much better! :smile:

Are you able to do it row-wise instead of point-wise out of curiosity?

cd155 commented 1 year ago

Looks much better! smile

Are you able to do it row-wise instead of point-wise out of curiosity?

@balacij I actually not sure how to this question row-wise. The current way is to find all the coordinates of possible points that need to be painted. Once find all of them, then paint them accordingly.

cd155 commented 1 year ago

The ideology of row-wise seems very interesting. Thanks for pointing it out. It's doable, and I will keep you in the post.

balacij commented 1 year ago

It was just a thought on how an algorithm could be done if you know the ranges of the "insides" of the shape by length along the horizontal axis. I hope it works :smile: