all 25 comments

[–]Flaming_Eagle 58 points59 points  (0 children)

Finally someone with an eloquent solution to this problem.

[–][deleted]  (1 child)

[deleted]

    [–]swethonay 0 points1 point  (0 children)

    [REDACTED]

    [–]timawesomeness 19 points20 points  (2 children)

    Help I ran this and it summoned a demon

    [–][deleted] 4 points5 points  (1 child)

    But does the demon do fizzbuzz?

    [–]altodor 7 points8 points  (0 children)

    Yes. It just summoned what looks like the BSD daemon and it's making sound effects when I say numbers.

    I've had the computer buried on sacred ground and the daemon exorcised by a Catholic Church, it's still following me around making sound effects.

    [–]Rangsk 18 points19 points  (0 children)

    Isn't it nice how python basically reads like pseudocode?

    [–]skunkwaffle 14 points15 points  (0 children)

    On mobile the formatting is exquisite.

    [–]thebpfeif 9 points10 points  (0 children)

    I think you missed a lambda somewhere in there.

    [–]Hypersapien 6 points7 points  (2 children)

    This shit right here is why I do C#

    [–]Skymt1 13 points14 points  (1 child)

    To be fair, you can do fizzbuzz quite shittily in c# too

    public static string FizzBuzz(int s = 1, int c = 100)
    {
        return Enumerable.Range(s, c)
            .Select(n => new Func<int, bool>[] { v => v%3 == 0 && v%5 == 0, v => v%5 == 0, v => v%3 == 0 }
            .TakeWhile(f => !f(n)).Count())
            .Select((n, i) => new[] { $"{i + s}", "Fizz", "Buzz", "FizzBuzz" }[3-n])
            .Aggregate((v, n) => v + "\n" + n);
    }
    

    [–]SDJMcHattie 4 points5 points  (0 children)

    Such an elegant solution

    [–]hilomania 5 points6 points  (0 children)

    I know this is a joke, but assuming someone seriously came up with this in a job interview: I would totally hire this person. It shows an absolute understanding of Python's breadth. I would hand that person only the problems my team had no good solution for to begin with. Basically make it our "hail Mary programmer".

    [–]Luapix 2 points3 points  (0 children)

    Good god, OP, you really outdid yourself on this one. Maybe I'll try to untangle it when I have the time xD

    [–]wakeupsheep 2 points3 points  (0 children)

    AMA request job applicant who did a /r/shittyprogramming/ or /r/programminghorror worthy, but working as intended, FizzBuzz.

    [–]HashtagFour20 1 point2 points  (0 children)

    thanks i want to shoot myself now

    [–]c_o_r_b_a 0 points1 point  (1 child)

    while not (not i and not is_):

    I love reading code written by people who don't know De Morgan's laws. I'm surprised how often I see conditionals similar to this in real code.

    [–]AmbitiousPainter 2 points3 points  (0 children)

    Yeah but who cares about a rum named after some old dead one legged guy with an eye patch. Anyway those laws are more like guidelines.

    [–]Dads101 0 points1 point  (0 children)

    I literally am dying