algorithm-archivists / algorithm-archive

A collaborative book on algorithms
https://www.algorithm-archive.org
MIT License
2.35k stars 354 forks source link

Flood fill in C# #1011

Open DimYfantidis opened 1 year ago

DimYfantidis commented 1 year ago

C# implementation of Flood fill. Added the code in flood_fill.md

Amaras commented 1 year ago

Hello @DimYfantidis and thank you for your interest in the AAA.

We'll try to review your PR as soon as possible, but be aware that it might take a while, as I'm not sure we currently have available C# reviewers.

From what I see, there is a lot of boilerplate code, which seems like a lot to me, but I'm not a C# expert.

I'll nonetheless get a first review path going soon-ish, so that it doesn't get too stuck in review limbo

Amaras commented 1 year ago

I tried compiling on my machine, and it simply didn't. I'm using an Ubuntu 20.04 machine, with the mono-complete package. Could you provide compilation instructions for Linux? Here's the output:

❯ mcs FloodFill.cs 
FloodFill.cs(65,33): error CS1525: Unexpected symbol `+', expecting `)', `,', or `identifier'
FloodFill.cs(65,36): error CS1525: Unexpected symbol `)', expecting `)', `,', or `identifier'
FloodFill.cs(66,16): error CS1525: Unexpected symbol `new', expecting `)', `,', or `identifier'
FloodFill.cs(66,34): error CS1525: Unexpected symbol `.', expecting `)', `,', or `identifier'
FloodFill.cs(67,16): error CS1525: Unexpected symbol `new', expecting `)', `,', or `identifier'
FloodFill.cs(67,30): error CS1525: Unexpected symbol `.', expecting `)', `,', or `identifier'
FloodFill.cs(68,16): error CS1525: Unexpected symbol `new', expecting `)', `,', or `identifier'
FloodFill.cs(68,34): error CS1525: Unexpected symbol `.', expecting `)', `,', or `identifier'
FloodFill.cs(156,20): error CS1525: Unexpected symbol `)', expecting `(' or `type'
FloodFill.cs(156,25): error CS1525: Unexpected symbol `0', expecting `(' or `type'
FloodFill.cs(156,28): error CS1525: Unexpected symbol `1', expecting `(' or `type'
FloodFill.cs(156,31): error CS1525: Unexpected symbol `0', expecting `(' or `type'
FloodFill.cs(156,34): error CS1525: Unexpected symbol `0', expecting `(' or `type'
FloodFill.cs(157,16): error CS1525: Unexpected symbol `new', expecting `(' or `type'
FloodFill.cs(157,25): error CS1525: Unexpected symbol `0', expecting `(' or `type'
FloodFill.cs(157,28): error CS1525: Unexpected symbol `1', expecting `(' or `type'
FloodFill.cs(157,31): error CS1525: Unexpected symbol `0', expecting `(' or `type'
FloodFill.cs(157,34): error CS1525: Unexpected symbol `0', expecting `(' or `type'
FloodFill.cs(158,16): error CS1525: Unexpected symbol `new', expecting `(' or `type'
FloodFill.cs(158,25): error CS1525: Unexpected symbol `0', expecting `(' or `type'
FloodFill.cs(158,28): error CS1525: Unexpected symbol `1', expecting `(' or `type'
FloodFill.cs(158,31): error CS1525: Unexpected symbol `0', expecting `(' or `type'
FloodFill.cs(158,34): error CS1525: Unexpected symbol `0', expecting `(' or `type'
FloodFill.cs(159,16): error CS1525: Unexpected symbol `new', expecting `(' or `type'
FloodFill.cs(159,25): error CS1525: Unexpected symbol `0', expecting `(' or `type'
FloodFill.cs(159,28): error CS1525: Unexpected symbol `1', expecting `(' or `type'
FloodFill.cs(159,31): error CS1525: Unexpected symbol `1', expecting `(' or `type'
FloodFill.cs(159,34): error CS1525: Unexpected symbol `1', expecting `(' or `type'
FloodFill.cs(160,16): error CS1525: Unexpected symbol `new', expecting `(' or `type'
FloodFill.cs(160,25): error CS1525: Unexpected symbol `0', expecting `(' or `type'
FloodFill.cs(160,28): error CS1525: Unexpected symbol `0', expecting `(' or `type'
FloodFill.cs(160,31): error CS1525: Unexpected symbol `0', expecting `(' or `type'
FloodFill.cs(160,34): error CS1525: Unexpected symbol `0', expecting `(' or `type'
FloodFill.cs(164,20): error CS1525: Unexpected symbol `)', expecting `(' or `type'
FloodFill.cs(164,25): error CS1525: Unexpected symbol `3', expecting `(' or `type'
FloodFill.cs(164,28): error CS1525: Unexpected symbol `1', expecting `(' or `type'
FloodFill.cs(164,31): error CS1525: Unexpected symbol `0', expecting `(' or `type'
FloodFill.cs(164,34): error CS1525: Unexpected symbol `0', expecting `(' or `type'
FloodFill.cs(165,16): error CS1525: Unexpected symbol `new', expecting `(' or `type'
FloodFill.cs(165,25): error CS1525: Unexpected symbol `3', expecting `(' or `type'
FloodFill.cs(165,28): error CS1525: Unexpected symbol `1', expecting `(' or `type'
FloodFill.cs(165,31): error CS1525: Unexpected symbol `0', expecting `(' or `type'
FloodFill.cs(165,34): error CS1525: Unexpected symbol `0', expecting `(' or `type'
FloodFill.cs(166,16): error CS1525: Unexpected symbol `new', expecting `(' or `type'
FloodFill.cs(166,25): error CS1525: Unexpected symbol `3', expecting `(' or `type'
FloodFill.cs(166,28): error CS1525: Unexpected symbol `1', expecting `(' or `type'
FloodFill.cs(166,31): error CS1525: Unexpected symbol `0', expecting `(' or `type'
FloodFill.cs(166,34): error CS1525: Unexpected symbol `0', expecting `(' or `type'
FloodFill.cs(167,16): error CS1525: Unexpected symbol `new', expecting `(' or `type'
FloodFill.cs(167,25): error CS1525: Unexpected symbol `3', expecting `(' or `type'
FloodFill.cs(167,28): error CS1525: Unexpected symbol `1', expecting `(' or `type'
FloodFill.cs(167,31): error CS1525: Unexpected symbol `1', expecting `(' or `type'
FloodFill.cs(167,34): error CS1525: Unexpected symbol `1', expecting `(' or `type'
FloodFill.cs(168,16): error CS1525: Unexpected symbol `new', expecting `(' or `type'
FloodFill.cs(168,25): error CS1525: Unexpected symbol `3', expecting `(' or `type'
FloodFill.cs(168,28): error CS1525: Unexpected symbol `3', expecting `(' or `type'
FloodFill.cs(168,31): error CS1525: Unexpected symbol `3', expecting `(' or `type'
FloodFill.cs(168,34): error CS1525: Unexpected symbol `3', expecting `(' or `type'
Compilation failed: 58 error(s), 0 warnings
DimYfantidis commented 1 year ago

Thank you for your time, I'm very sorry but it seems that there are no special compilation instructions for Linux. Normally, "mcs FloodFill.cs" should be enough, but it seems that I've written code that could compile and execute due to specific IDE configurations that I had on my machine. I have made changes to the code and it now compiles successfully on Ubuntu 22.04.3 simply by typing the aforementioned command (It would be very unlucky if it was to fail Ubuntu 20.04 though very unlikely; I believe it should compile fine on your machine now).

I'm not sure on how I could change the code I have commited. Is it possible that, in this specific pull request, I could change the contents of FloodFill.cs? Or should I create a new pull request? If the former is possible, notify me so that we could come in contact on Discord. (I'm a new at contributing to open source projects and github projects)

Thanks again and I'm very sorry.

Amaras commented 1 year ago

You can simply modify the code and git add FloodFill.cs and then git commit with a relevant message. When you then git push, we'll get the up to date code in this PR. :)

DimYfantidis commented 1 year ago

Done. I'm on standby in case another problem occurs, although now I suppose everything is fine. 👍

Amaras commented 1 year ago

Thanks, it compiles now. I'll try to get a PR going to get C# into our build system to make sure we don't have a problem like that any more. Hopefully we can get a competent C# developer who can look at your PR soon :)

Amaras commented 1 year ago

Alright, the PR to get C# in our build system is up (#1012)

DimYfantidis commented 1 year ago

Alright, I have refactored code and markdown according to the above discussion.