patternCritical
NUMAH LITTERS OV KITTEHS ON TEH NETZ
Viewed 0 times
numahtehkittehslittersnetz
Problem
It's not fair that 1% of the users hold 75% of the lolcode questions. #OccupyMatsMug
~ user2296177
I agree. Without further ado, here's the LOLCODE version of 99 bottles of beer on the wall:
Disclaimer: No actual kittens were harmed while writing this program.
The number of iterations is held in the variable
The above is compiled using the latest lci using the 1.3 specification (thanks to Pimgd for the link). Since the 1.3 specification doesn't contain every feature of the language, see the 1.2 specification as well.
I don't think LOLCODE has templates or the likes, so getting all the output on screen is a bit tedious.
Output:
etc.
Is this idiomatic LOLCODE?
~ user2296177
I agree. Without further ado, here's the LOLCODE version of 99 bottles of beer on the wall:
OBTW
PRINT TEH LOLCODE VERSHUN OV N BOTTLEZ OV BER ON TEH WALL.
TLDR
HAI 1.3
HOW IZ I COUNTDOWN YR NUMAH
I HAS A NAUW ITZ A NUMBR
I HAS A LEZZ ITZ A NUMBR
IM IN YR LOOPZ NERFIN YR COWNTR TIL BOTH SAEM COWNTR AN DIFF OF 1 AN NUMAH
NAUW R SUM OF NUMAH AN COWNTR
LEZZ R DIFF OF NAUW AN 1
VISIBLE SMOOSH NAUW AN " LITTERS OV KITTEHS ON TEH NETZ" MKAY
VISIBLE SMOOSH NAUW AN " LITTERS OV KITTEHS" MKAY
VISIBLE "WAN FALLS DOWN AN BREAKZ PAH"
VISIBLE SMOOSH LEZZ AN " LITTERS OV KITTEHS ON TEH NETZ" MKAY
VISIBLE ""
IM OUTTA YR LOOPZ
VISIBLE "1 LITTER OV KITTEHS ON TEH NETZ"
VISIBLE "1 LITTER OV KITTEHS"
VISIBLE "WAN FALLS DOWN AN BREAKZ PAH"
VISIBLE "NO MOAR LITTERs OV KITTEHS ON TEH NETZ"
IF U SAY SO
I IZ COUNTDOWN YR 99 MKAY
KTHXBYE
Disclaimer: No actual kittens were harmed while writing this program.
The number of iterations is held in the variable
NUMAH. I know NUMBR is a more fitting name, but that's already claimed as a type.The above is compiled using the latest lci using the 1.3 specification (thanks to Pimgd for the link). Since the 1.3 specification doesn't contain every feature of the language, see the 1.2 specification as well.
I don't think LOLCODE has templates or the likes, so getting all the output on screen is a bit tedious.
Output:
99 LITTERS OV KITTEHS ON TEH NETZ
99 LITTERS OV KITTEHS
WAN FALLS DOWN AN BREAKZ PAH
98 LITTERS OV KITTEHS ON TEH NETZ
etc.
1 LITTER OV KITTEHS ON TEH NETZ
1 LITTER OV KITTEHS
WAN FALLS DOWN AN BREAKZ PAH
NO MOAR LITTERs OV KITTEHS ON TEH NETZ
Is this idiomatic LOLCODE?
Solution
Variable capitalization
IT IZ PRETTY GUD LOLCODE
HOWEVEZ ME THINKS THAT TEH LOLCODEZ R EZYR 2 READ IF TEH VARZ R lowercase
ZIS BECUZ ALL CAPS IS HARD TOO READ
(all spelling "mistakes" made by my cat, who assisted me in that part of this review)
More seriously, it is an issue that there are no good LOLCODE syntax highlighters. To be "stylish" and keep everything uppercase is a choice you can make, but personally I prefer to use lowercase or camelCase variable names whilst keeping the language constructs all caps. Similar to SQL, this allows you to see what parts of the code are variables, and what parts are language constructs.
Compare:
with...
Variable naming
Regarding
Working around the spec
This construct is non-obvious. You had to work around the spec to do something that you wanted to do, and I think it warrants explanation. Add a comment via
Correctness in corner cases
Your function doesn't check if the value passed in is greater than 0. This means that it falsely forces a KITTEH to break their paw when it wasn't necessary.
Add a guard clause at the top of the function; you can do an early return via
Program definition
Aside from the weird phrasing (does this code print the lolcode version of/and bottles of beer on the wall?), there's something else wrong here: Your comment is before the
Possible alternative dialects
Did you make a typo here, is this an alternative kitty dialect that uses lower case 's' for certain plurals? I'm not sure.
Lastly, I think this version of 99 LITTERS OV KITTEHS ON TEH NETZ is not authentic, as anyone knows that when KITTEHS fall, they'll be alright. This version is sad, as all the KITTEHS just break their paws. Proper LOLCODE uses cats, it doesn't abuse them.
IT IZ PRETTY GUD LOLCODE
HOWEVEZ ME THINKS THAT TEH LOLCODEZ R EZYR 2 READ IF TEH VARZ R lowercase
ZIS BECUZ ALL CAPS IS HARD TOO READ
(all spelling "mistakes" made by my cat, who assisted me in that part of this review)
More seriously, it is an issue that there are no good LOLCODE syntax highlighters. To be "stylish" and keep everything uppercase is a choice you can make, but personally I prefer to use lowercase or camelCase variable names whilst keeping the language constructs all caps. Similar to SQL, this allows you to see what parts of the code are variables, and what parts are language constructs.
Compare:
I HAS A NAUW ITZ A NUMBR
I HAS A LEZZ ITZ A NUMBR
IM IN YR LOOPZ NERFIN YR COWNTR TIL BOTH SAEM COWNTR AN DIFF OF 1 AN NUMAH
NAUW R SUM OF NUMAH AN COWNTR
LEZZ R DIFF OF NAUW AN 1
VISIBLE SMOOSH NAUW AN " LITTERS OV KITTEHS ON TEH NETZ" MKAY
VISIBLE SMOOSH NAUW AN " LITTERS OV KITTEHS" MKAY
VISIBLE "WAN FALLS DOWN AN BREAKZ PAH"
VISIBLE SMOOSH LEZZ AN " LITTERS OV KITTEHS ON TEH NETZ" MKAY
VISIBLE ""
IM OUTTA YR LOOPZwith...
I HAS A nauw ITZ A NUMBR
I HAS A lezz ITZ A NUMBR
IM IN YR LOOPZ NERFIN YR cowntr TIL BOTH SAEM cowntr AN DIFF OF 1 AN numah
nauw R SUM OF numah AN cowntr
lezz R DIFF OF nauw AN 1
VISIBLE SMOOSH nauw AN " LITTERS OV KITTEHS ON TEH NETZ" MKAY
VISIBLE SMOOSH nauw AN " LITTERS OV KITTEHS" MKAY
VISIBLE "WAN FALLS DOWN AN BREAKZ PAH"
VISIBLE SMOOSH lezz AN " LITTERS OV KITTEHS ON TEH NETZ" MKAY
VISIBLE ""
IM OUTTA YR LOOPZVariable naming
Regarding
NUMAH, have you considered using NUMBAH? Similar meaning, but uses a more common mispronunciation.Working around the spec
IM IN YR LOOPZ NERFIN YR COWNTR TIL BOTH SAEM COWNTR AN DIFF OF 1 AN NUMAH
NAUW R SUM OF NUMAH AN COWNTRThis construct is non-obvious. You had to work around the spec to do something that you wanted to do, and I think it warrants explanation. Add a comment via
BTW:IM IN YR LOOPZ NERFIN YR COWNTR TIL BOTH SAEM COWNTR AN DIFF OF 1 AN NUMAH
NAUW R SUM OF NUMAH AN COWNTR BTW workaround loop counters starting at 0Correctness in corner cases
Your function doesn't check if the value passed in is greater than 0. This means that it falsely forces a KITTEH to break their paw when it wasn't necessary.
Add a guard clause at the top of the function; you can do an early return via
GTFO.DIFFRINT numbah AN BIGGR OF numbah AN 0
O RLY? YA RLY
GTFO
OICProgram definition
OBTW
PRINT TEH LOLCODE VERSHUN OV N BOTTLEZ OV BER ON TEH WALL.
TLDR
HAI 1.3Aside from the weird phrasing (does this code print the lolcode version of/and bottles of beer on the wall?), there's something else wrong here: Your comment is before the
HAI 1.3. So any interpreter loading your file might not know what version you are using. Put your version number at the top. Possible alternative dialects
VISIBLE "NO MOAR LITTERs OV KITTEHS ON TEH NETZ"Did you make a typo here, is this an alternative kitty dialect that uses lower case 's' for certain plurals? I'm not sure.
Lastly, I think this version of 99 LITTERS OV KITTEHS ON TEH NETZ is not authentic, as anyone knows that when KITTEHS fall, they'll be alright. This version is sad, as all the KITTEHS just break their paws. Proper LOLCODE uses cats, it doesn't abuse them.
Code Snippets
I HAS A NAUW ITZ A NUMBR
I HAS A LEZZ ITZ A NUMBR
IM IN YR LOOPZ NERFIN YR COWNTR TIL BOTH SAEM COWNTR AN DIFF OF 1 AN NUMAH
NAUW R SUM OF NUMAH AN COWNTR
LEZZ R DIFF OF NAUW AN 1
VISIBLE SMOOSH NAUW AN " LITTERS OV KITTEHS ON TEH NETZ" MKAY
VISIBLE SMOOSH NAUW AN " LITTERS OV KITTEHS" MKAY
VISIBLE "WAN FALLS DOWN AN BREAKZ PAH"
VISIBLE SMOOSH LEZZ AN " LITTERS OV KITTEHS ON TEH NETZ" MKAY
VISIBLE ""
IM OUTTA YR LOOPZI HAS A nauw ITZ A NUMBR
I HAS A lezz ITZ A NUMBR
IM IN YR LOOPZ NERFIN YR cowntr TIL BOTH SAEM cowntr AN DIFF OF 1 AN numah
nauw R SUM OF numah AN cowntr
lezz R DIFF OF nauw AN 1
VISIBLE SMOOSH nauw AN " LITTERS OV KITTEHS ON TEH NETZ" MKAY
VISIBLE SMOOSH nauw AN " LITTERS OV KITTEHS" MKAY
VISIBLE "WAN FALLS DOWN AN BREAKZ PAH"
VISIBLE SMOOSH lezz AN " LITTERS OV KITTEHS ON TEH NETZ" MKAY
VISIBLE ""
IM OUTTA YR LOOPZIM IN YR LOOPZ NERFIN YR COWNTR TIL BOTH SAEM COWNTR AN DIFF OF 1 AN NUMAH
NAUW R SUM OF NUMAH AN COWNTRIM IN YR LOOPZ NERFIN YR COWNTR TIL BOTH SAEM COWNTR AN DIFF OF 1 AN NUMAH
NAUW R SUM OF NUMAH AN COWNTR BTW workaround loop counters starting at 0DIFFRINT numbah AN BIGGR OF numbah AN 0
O RLY? YA RLY
GTFO
OICContext
StackExchange Code Review Q#134756, answer score: 54
Revisions (0)
No revisions yet.