Thursday, June 17, 2010

Logic Puzzles



Something new thought I would toss out one of the bugs I had earlier for otherworld that was actually a fun little logic puzzle that I scratched my head on for about an hour before finally seeing it. The picture above is what the bug outputs and then what it should output.

As a last hint there is no problems with the other functions.

catsPawTradingFirst(); //the text added to the hopper
return fillLongString(); //sent to output

function fillLongString():String {
var stringy:String = new String;
for (var i:Number = 0; i < storyHopper.length; i++) {
stringy = storyHopper.pop() + "(htmlbreak blog eats it)" + stringy ;
}
return stringy;
}

Have fun

Edit: Wanted to show what the quest screen actually is looking like now.


Daisy

2 comments:

  1. the awnser to the puzzle... popping off the story hopper and was measuring the length on a shorter and shorter storyhopper meant that it kept getting cut off. a temp variable fixes this issue.

    function fillLongString():String {
    var stringy:String = new String;
    var temp:int = new int;
    stringy = "";
    temp = storyHopper.length;
    for (var i:Number = 0; i < temp; i++) {
    stringy = storyHopper.pop() + "
    " + stringy ;
    }
    return stringy;
    }

    ReplyDelete
  2. I didn't see it. My intuition was alike (I guess it was "i+1" or "i-1" the count of element in the array). For defense: I'm not versed in flash, but I now other programming language.
    And thus, another question:
    Isn't this faster?
    for (var i:Number = temp; i > 0; i--) {
    stringy += storyHopper.pop() + "
    ";
    }

    ReplyDelete