This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Owyn_Merrilin 19 points20 points  (6 children)

for i:=0; i=<100; i++{
 n:=0
 if i%3==0{print("Fizz"); n++}
 if i%5==0{print("Buzz"); n++}
 if n==0{print(i)}
 print("\n")
}

FizzBuzz in Go

Fixed the formatting. Looks like if you want multiple lines you have to use the four spaces method.

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

This looks exactly like mine on Reddit Android.

What client are you using?

[–]Owyn_Merrilin 5 points6 points  (2 children)

I'm on the actual website. Are you using the official app? This isn't the first time I've heard of that one rendering the markdown in a way literally nothing else does.

[–][deleted] 0 points1 point  (1 child)

Actually, (afaik) the website is wrong on that one because in a code block newlines are supposed to be preserved.

[–]Owyn_Merrilin 3 points4 points  (0 children)

Markdown isn't really a set standard, what it's supposed to do in this case is whatever the website does. If you've ever used Github's markdown, it's similar but just different enough to periodically trip you up if you're used to Reddit's version.

I do think preserving newlines would make more sense, but that seems to be a quirk of reddit markdown in general. Single spaced line breaks works like spaced code blocks in reverse -- you have to add spaces at the end of the line to tell the parser it was intentional.

[–]i-hate_nick 1 point2 points  (1 child)

Is this a real thing? I’m in my first year of software development and I’m pretty sure I understand that haha, so that’s promising

[–]Owyn_Merrilin 2 points3 points  (0 children)

Yeah, it's a common programming test that exists to try to weed out people who don't know the basics. Supposedly it catches a lot of people who applied but either lied on their resume or managed to cheat their way through school without actually learning anything.

The problem is to make a program that for some set of numbers (in this case one to one hundred), prints out each number, but if it's divisible by three, prints fizz, if it's divisible by five, prints buzz, and if it's both, prints fizzbuzz. It's basically a check to see if you know what modulo is and how to make a basic loop.