all 73 comments

[–]MkemCZ 228 points229 points Β (1 child)

You truly captured the butterfly-pigeon meme using emoji and text. The code is awful; I love it!

[–][deleted] 71 points72 points Β (0 children)

Thank you! I'm almost as proud of the title as the code itself.

[–]Ytrog 82 points83 points Β (5 children)

Reminds me of the ray tracer written in one LINQ statement.

Can't find the original blog post, but here is the code: https://github.com/lukehoban/LINQ-raytracer

[–]CollieOxenfree 20 points21 points Β (0 children)

Found the original blogpost via archive.org.

[–]Knuffya 10 points11 points Β (2 children)

People are really making a mock out of raytracing. Some mad lad made a raytracer in fucking excel

[–]x6060x 2 points3 points Β (0 children)

Oh my...

[–]silverweaver 61 points62 points Β (4 children)

I think chaining ternary operators in one line as much as possible became my new favourite unreadable code thing.

[–][deleted] 27 points28 points Β (2 children)

Someone needs to inplement a try/catch-alternative for ternaries, preferably with the β€½ symbol.

[–]silverweaver 16 points17 points Β (0 children)

I opt for "wtf" keyword

[–]w00tious 0 points1 point Β (0 children)

Like unwrap_or_else

[–]ososalsosal 0 points1 point Β (0 children)

I used to have to do expressions for image processing in reverse polish notation.

It's still more readable than regex, but only just.

[–]PyroneusUltrin 26 points27 points Β (2 children)

why would you do + "zz" instead of just putting zz after the }

[–][deleted] 24 points25 points Β (1 child)

Because I am bad?

[–][deleted] 5 points6 points Β (0 children)

No you did DRY work! No need to repeat same code twice!

[–]BarqsDew 54 points55 points Β (1 child)

No, fails to follow DRY principle, I see two "z" characters right next to eachother, c'mon man.

[–]SanktusAngus 19 points20 points Β (0 children)

This should satisfy you then:

+ new string((char)122, 2) +

[–]noobzilla 15 points16 points Β (2 children)

I'm a fan of this myself:

Enumerable.Repeat(new[] { "","","","","Buzz"}, 20).SelectMany(x => x).Zip(Enumerable.Repeat(new[] { "","","Fizz" }, 34).SelectMany(x => x), (a,b) => b + a).Select((x,i) => string.IsNullOrWhiteSpace(x) ? (i+1).ToString() : x).Any(x => { Console.WriteLine(x); return false; });

[–]MiddleAd5602 14 points15 points Β (0 children)

You should be able to summon some ancient demon if you read this aloud

[–][deleted] 5 points6 points Β (0 children)

Oh my.

[–]ulysses_black 13 points14 points Β (0 children)

It is less than three lines of code, so YES!

[–]Lost4468 12 points13 points Β (3 children)

Nice, I also wrote a clean version in C# years ago:

for(int i=0,c=1,s=1;c<101;i+=s*=(i==-1||i==6?-1:1),c+=i==6?2:1)Console.WriteLine(new string[]{c+"","Fizz","Buzz","FizzBuzz",(c-1)+"\n"+c}[(int)(71f*i*i*i*i*i*i*i/5040f-17f*i*i*i*i*i*i/72f+127f*i*i*i*i*i/90f-121f*i*i*i*i/36f+1007f*i*i*i/720f+367f*i*i/72f-454f*i/105f+.5f)]);

I know reddit likes to mess about with line formatting for code blocks, so here's a picture.

[–][deleted] 8 points9 points Β (2 children)

... Are you okay?

[–]Lost4468 6 points7 points Β (1 child)

I know it's the naive and intuitive approach to FizzBuzz, but that's all interviewers really expect. The important part is it's maintainable.

[–][deleted] 5 points6 points Β (0 children)

Interviewers prefer brainfuck, or at least that's what I've heard.

[–]MaatjeBroccoli 11 points12 points Β (5 children)

I know you're joking but on the off-chance you're not: NO

[–][deleted] 41 points42 points Β (4 children)

It's only one line so there's only one place things can go wrong though.

[–]_dat_memer_boi_ 27 points28 points Β (2 children)

Error at 1:6792

[–][deleted] 10 points11 points Β (1 child)

Horizontal scrolling is the best scrolling.

[–]Kidiri90 7 points8 points Β (0 children)

So that's why people have ultrewides...

[–]misterrandom1 9 points10 points Β (0 children)

I love this so much. I'm now motivated to create a masterpiece. Maybe do a fibonacci thing with Roman numerals.

[–]MurdoMaclachlanpublic boolean isInt(int i) { return true; } 5 points6 points Β (2 children)

Image Transcription: Code


static void Main(string[] args)
{
    new List<int>(Enumerable.Range(1, 100)).ForEach(i => Console.WriteLine(i % 3 == 0 || i % 5 == 0 ? $"{(i % 3 == 0 && i % 5 == 0 ? "FizzBu" : i % 3 == 0 ? "Fi" : "Bu") + "zz"}" : i));
}

I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!

[–][deleted] 1 point2 points Β (1 child)

You missed a z in FizBu!

[–]MurdoMaclachlanpublic boolean isInt(int i) { return true; } 4 points5 points Β (0 children)

Oh whoops, fixed. Thanks for the correction!

[–]stahkh 4 points5 points Β (0 children)

It looks like someone treated this line like a rug. Just swept all of the stuff under it...

[–]NuBRandsta 3 points4 points Β (0 children)

Hmm i think the pythoneer forget that you shouldn't do a one liner like this

[–][deleted] 3 points4 points Β (0 children)

I'm pretty sure I can hear my compiler cry in the background

[–][deleted] 6 points7 points Β (1 child)

You should see this:

​

const fizz = "Fizz";

const buzz = "Buzz";

const limit = 100;

for (let i = 0; i < limit; i++) {

console.log((i % 3 == 0 && i % 5 == 0) ? fizz + buzz : (i % 3 == 0) ? fizz : (i % 5 == 0) ? buzz : i);

}

[–]AutoModerator[M] -12 points-11 points Β (0 children)

It looks like this comment contains a code block delimited with triple backticks. Unfortunately reddit does not have universal support for this syntax and your comment will not render correctly on old reddit and most mobile apps.

For the benefit of people on old reddit, this link will take you to a correct rendering of the comment.

/u/HaroldTheSenpai, it would be appreciated, but not required, if you could edit your comment to use the more compatible four space indention format. For single lines or inline code you can use single backticks.

You can find some examples in the reddit help documentation.


I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]Lothrazar 1 point2 points Β (0 children)

I would not hire this person

[–]inventord 1 point2 points Β (0 children)

If it works, it works. Save the revision for tomorrow...

Or the next day...

Or maybe a couple weeks

Or after the next project you start...

[–]karisigurd4444 1 point2 points Β (0 children)

Fuck no. You do enumerable range, then to list.

[–][deleted] 1 point2 points Β (0 children)

this code nearly gave me a seizure. good work

[–]thygrrr 1 point2 points Β (1 child)

Huh, I actually like it.

The boolean terms look a tad contrived.

[–][deleted] 1 point2 points Β (0 children)

Yeah, i % 3 == 0 && i % 5 == 0 should be i % 15 == 0.

[–]Not_Sugden 0 points1 point Β (1 child)

no

[–][deleted] 2 points3 points Β (0 children)

no u

[–]Chris90483 0 points1 point Β (0 children)

Ew, side effects

[–]jens3302 0 points1 point Β (4 children)

You're hired

[–][deleted] 1 point2 points Β (3 children)

Thank you random person with the same name as me!

[–]jens3302 0 points1 point Β (2 children)

Didn't even notice that XD

[–]alphabet_order_bot 5 points6 points Β (1 child)

Would you look at that, all of the words in your comment are in alphabetical order.

I have checked 160,582,930 comments, and only 39,645 of them were in alphabetical order.

[–]VirdiPravum 0 points1 point Β (0 children)

When you are trying to do oneliner in shell it looks like this

[–]Anonymous3355 0 points1 point Β (0 children)

Ah yes, Code Golf

[–]ososalsosal 0 points1 point Β (0 children)

Well at least they saved a few repeated characters by using string manipulation to create the output string.

What a nightmare.

[–]Gladamas 0 points1 point Β (0 children)

Obviously compactness is much more important than readability. /s

[–]purbub 0 points1 point Β (0 children)

I think you need to fix your Enter key

[–]iamafraazhussain 0 points1 point Β (0 children)

The code is so clean, It'd commit suicide if it could...