A place to discuss whatever.
2 posts Page 1 of 1
Postby Jeanolos » Sun Oct 11, 2015 10:00 am
Hey guys!

I'm fairly new to LOLCODE but I tried writing the FizzBuzz program in LOLCODE, except that I don't get any output using lci:

Code: Select all
AI 1.2
I HAS A ITEM ITZ 1
IM IN YR LOOP UPPIN YR ITEM WILE SMALLR OF ITEM AN 101
    I HAS A STRING ITZ ""
    BOTH SAEM MOD OF ITEM AN 3 AN 0, O RLY?
        YA RLY
            SMOOSH STRING AN "FIZZ" MKAY
    OIC
    BOTH SAEM MOD OF ITEM AN 5 AN 0, O RLY?
        YA RLY
            SMOOSH STRING AN "BUZZ" MKAY
    OIC
    BOTH OF STRING AN "", O RLY?
        YA RLY
            SMOOSH STRING AN ":{ITEM}" MKAY
    OIC
    VISIBLE STRING
IM OUTTA YR LOOP
KTHXBYE


Can someone help me on this one? ^^
Postby jjm » Sat Oct 17, 2015 7:37 pm
Hey Jeanolos!

There are two things that should be changed:

1. The loop's WILE condition needs an additional check to see if SMALLR OF ITEM AN 101is equal to ITEM.
2. The SMOOSH concatenation needs to be assigned back to STRING in order to update its contents.

Here is a revised code snippet:

Code: Select all
HAI 1.2
I HAS A ITEM ITZ 1
IM IN YR LOOP UPPIN YR ITEM WILE...
        BOTH SAEM SMALLR OF ITEM AN 101 AN ITEM
    VISIBLE "LOOPIN " AN ITEM
    I HAS A STRING ITZ ""
    BOTH SAEM MOD OF ITEM AN 3 AN 0, O RLY?
        YA RLY
            STRING R SMOOSH STRING AN "FIZZ" MKAY
    OIC
    BOTH SAEM MOD OF ITEM AN 5 AN 0, O RLY?
        YA RLY
            STRING R SMOOSH STRING AN "BUZZ" MKAY
    OIC
    BOTH OF STRING AN "", O RLY?
        YA RLY
            STRING R SMOOSH STRING AN ":{ITEM}" MKAY
    OIC
    VISIBLE STRING
IM OUTTA YR LOOP
KTHXBYE


Happy coding!
2 posts Page 1 of 1

Login

Who is online

Users browsing this forum: No registered users and 1 guest