patternCritical
Down with FizzBuzz... LOL
Viewed 0 times
withdownlolfizzbuzz
Problem
This post is the result of reading through and following the LOLCODE Specification 1.2 ("smoking the manual", right?), and writing and executing my code on compileonline.com.
My "hello world" was going to be a fizzbuzz. I like it because it nicely illustrates the basics of a language - variables, operators, looping, conditionals, and the likes.
As far as naming goes, the specification allows for a wide variety, so I decided to go
I'm curious about how idiomatic my code is - this is my very first and probably last lolcode program. Did I overlook language constructs that would help readability? How's naming? Indentation? Any issues?
My "hello world" was going to be a fizzbuzz. I like it because it nicely illustrates the basics of a language - variables, operators, looping, conditionals, and the likes.
As far as naming goes, the specification allows for a wide variety, so I decided to go
PascalCase all the way, so as to ease up the reading a bit - otherwise the language is a bit harsh on the eyes, to say the least.I'm curious about how idiomatic my code is - this is my very first and probably last lolcode program. Did I overlook language constructs that would help readability? How's naming? Indentation? Any issues?
HAI 1.2
I HAS A Fizz ITZ 3
I HAS A Buzz ITZ 5
IM IN YR FrootLoopz UPPIN YR Frootz TIL BOTH SAEM Frootz AN 100
BTW Frootz runs 0 through 99
I HAS A Froot ITZ SUM OF Frootz AN 1
BTW Froot will run 1 through 100
BOTH SAEM 0 AN MOD OF Froot AN PRODUKT OF Fizz AN Buzz
O RLY?
YA RLY
Froot R "FizzBuzz"
NO WAI
BOTH SAEM 0 AN MOD OF Froot AN Fizz
O RLY?
YA RLY
Froot R "Fizz"
NO WAI
BOTH SAEM 0 AN MOD OF Froot AN Buzz
O RLY?
YA RLY
Froot R "Buzz"
OIC
OIC
OIC
VISIBLE Froot
IM OUTTA YR FrootLoopz
VISIBLE "DOWN WITH FIZZBUZZ LOL"
KTHXBYESolution
I like how you have declared the Fizz and Buzz 'constants'. It makes the code more readable.
The comments are useful too, though, for consistency, the second comment should be changed from:
to
The idea of generating
I only wish you used a better name than
I would suggest the name
This will reduce the ambiguity, and improve the readability and maintainability.
Finally, it is good that you put the
All in all, for a first go, I am very impressed with your result. I can't wait until you implement a fim++ interpreter in lolcode. Till then!
The comments are useful too, though, for consistency, the second comment should be changed from:
BTW Froot will run 1 through 100to
BTW Froot runs 1 through 100The idea of generating
Froot from Frootz is also good, because it reduces the computations later in the code.I only wish you used a better name than
Frootz because it conflicts with Froot. The similarity is.... uncanny.I would suggest the name
Loopz:I HAS A Loopz ITZ SUM OF Frootz AN 1This will reduce the ambiguity, and improve the readability and maintainability.
Finally, it is good that you put the
Fizz modulo check before the Buzz check because that improves performance. Many people put buzz first, but that means the modulo-5 check happens, and that fails more often than the modulo-3 check, so people who do the Buzz-loop first tend to do about 20% more conditional checks.All in all, for a first go, I am very impressed with your result. I can't wait until you implement a fim++ interpreter in lolcode. Till then!
Code Snippets
BTW Froot will run 1 through 100BTW Froot runs 1 through 100I HAS A Loopz ITZ SUM OF Frootz AN 1Context
StackExchange Code Review Q#61416, answer score: 72
Revisions (0)
No revisions yet.