PDA

View Full Version : Number puzzle


mayur.bais
01-29-2006, 07:42 AM
If lines are counted for switch case and break then this entry is not valid..else it is just 25 lines..
i hope they consider me




opArry = ["*", "+", "-", "/"];
function createTextFiled(ref, instName, dep, str, x, y, ty, br, w, h, mchar) {
ref.createTextField(instName, dep, x, y, w, h);
ref[instName].border = br;
ref[instName].text = str+"";
ref[instName].type = ty;
ref[instName].maxChars = mchar;
}
function createRow(i, x, y, depth) {
createTextFiled(this, ("txtnum1"+i), depth++, "", x, y, "input", true, 20, 20, 2);
createTextFiled(this, ("txtop"+i), depth++, opArry[random(4)], 50, y, "", false, 20, 20, 2);
createTextFiled(this, ("txtnum2"+i), depth++, "", 75, y, "input", true, 20, 20, 2);
createTextFiled(this, ("equlas"+i), depth++, "=", 120, y, "", false, 20, 20, 2);
createTextFiled(this, ("Answer"+i), depth++, random(100), 150, y, "dynamic", false, 20, 20, 2);
createTextFiled(this, ("Status"+i++), depth++, "", 175, y, "dynamic", true, 100, 20, 10);
i<5 ? createRow(i, 10, (i*50), depth++) : trace("nothing");
}
createRow(1, 10, 50, 2);
create(200, 300, 0x339966, "evaluate");
create(0, 300, 0x339966, "createME");
function create(x, y, c, txt) {
var k = _root.createEmptyMovieClip(txt, this.getNextHighestDepth());
createTextFiled(k, "txt_name", depth++, txt, 10, 25, "dynamic", true, 50, 20, 50);
k._x = x;
k._y = y;
}
evaluate.onRelease = function() {
for (var i = 1; i<=5; i++) {
switch (this._parent["txtop"+i].text) {
case "-" :
(Number(this._parent["txtnum1"+i].text)-Number(this._parent["txtnum2"+i].text)) == this._parent["Answer"+i].text ? this._parent["Status"+i].text="Correct" : this._parent["Status"+i].text="wrong";
break;
case "+" :
(Number(this._parent["txtnum1"+i].text)+Number(this._parent["txtnum2"+i].text)) == this._parent["Answer"+i].text ? this._parent["Status"+i].text="Correct" : this._parent["Status"+i].text="wrong";
break;
case "*" :
(Number(this._parent["txtnum1"+i].text)*Number(this._parent["txtnum2"+i].text)) == this._parent["Answer"+i].text ? this._parent["Status"+i].text="Correct" : this._parent["Status"+i].text="wrong";
break;
case "/" :
(Number(this._parent["txtnum1"+i].text)/Number(this._parent["txtnum2"+i].text)) == this._parent["Answer"+i].text ? this._parent["Status"+i].text="Correct" : this._parent["Status"+i].text="wrong";
break;
}
}
};
createME.onRelease = function() {
createRow(1, 10, 50, 2);
};

ElectricGrandpa
01-29-2006, 07:24 PM
You should make it so that 1 and 0 are outlawed, or else it's way too easy :D

freeskier89
01-29-2006, 07:38 PM
Even if you count (case N : actions) as 1 line and you do not count the breaks, it is over 25 lines. I counted 28. if the cases didn't count as a line wouldn't every one use switches and cases to get infinitely many lines?

Gelatine Cow
01-30-2006, 07:13 AM
I don't know about legality (I'm not counting ANYONE'S lines), but it doesn't seem to work very well :-/

__ / __ = 99, and only have two characters in each space? not possible!

(btw, I had three such equations on one page, this was just the most ridiculous)

I dunno how hard this would be to fix, but IMHO unless it's 90+ percent free of bugs, I wouldn't enter it. </high horse>

kirupa
01-30-2006, 09:54 AM
switch, case, and break do factor into the line count :(

ElectricGrandpa
01-31-2006, 02:48 AM
I don't know about legality (I'm not counting ANYONE'S lines), but it doesn't seem to work very well :-/

__ / __ = 99, and only have two characters in each space? not possible!

(btw, I had three such equations on one page, this was just the most ridiculous)

I dunno how hard this would be to fix, but IMHO unless it's 90+ percent free of bugs, I wouldn't enter it. </high horse>

*Cough* 99 / 1 = 99;