r/ProgrammerHumor • • 19h ago

Meme technicallyCorrect

Post image
1.0k Upvotes

42 comments sorted by

View all comments

245

u/zx48 15h ago • Bravo
void Main() {
    string[] pattern = {
        "##########",
        "##      ##",
        "# #    # #",
        "#  #  #  #",
        "#   ##   #",
        "#  #  #  #",
        "# #    # #",
        "##      ##",
        "##########"
    };

    string result = "";

    for (int i = 0; i < pattern.Length; ++i) {
        for (int j = 0; j < pattern[i].Length; ++j) {
            result += pattern[i][j];
        }
        result += "\n";
    }

    Console.Write(result);
}

In case the first answer isn't accepted.

92

u/AlwaysHopelesslyLost 13h ago • Heartwarming

.... Woah

If an interviewee gave me this answer I would seriously lose my train of thought. Obviously not what was intended but it conveys your understanding well AND it seems like a more technically correct solution from a requirements perspective. amazing answer lol

41

u/MisinformedGenius 12h ago

I actually used to kick off phone screens with asking how they would print out a multiplication table. A nested for loop was the correct answer, but suggesting hard-coding the tables (and better yet, explaining when that would be appropriate and when it wouldn’t) was some bonus points. 

16

u/dangderr 11h ago

How many points for saying data should be in a database, and then just making a query to grab the records?

2

u/MisinformedGenius 7h ago

Do you mean rather than hard-coding individual examples? That’s fine.

9

u/UrineArtist 11h ago

Yeah 100%, outside the box A+ answer, if someone gave this to me in an interview I'd be very impressed. Its the work of an idiot or a genius and that's worth pursuing.

9

u/Odd_Soil_8998 8h ago

It's the work of a smartass. Which honestly is the kind of people I work best around. 100% would hire.

2

u/zx48 8h ago

The jury's still out on that one 😆

14

u/intellectual_printer 15h ago

I like your way of thinking

4

u/radobot 9h ago

It kind of bothers me how the variable result is redundant. You could have just printed each character directly instead of accumulating them in a string.

1

u/zx48 8h ago

Oh yeah, nice optimisation. Would save a bit of memory too 😁

2

u/MulfordnSons 10h ago

simple but effective very nice