# Number puzzle

**URL:** <https://forum.kirupa.com/t/number-puzzle/177024>\
**Category:** contests\
**Created:** [January 29, 2006, 12:42pm UTC](https://forum.kirupa.com/t/number-puzzle/177024 "2006-01-29T12:42:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mayur\_bais](https://avatars.discourse-cdn.com/v4/letter/m/5fc32e/32.png) [@mayur\_bais](https://forum.kirupa.com/u/mayur_bais)\
**Post date:** [January 29, 2006, 12:42pm UTC](https://forum.kirupa.com/t/number-puzzle/177024/1 "2006-01-29T12:42:22Z")

</div>

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

```php

 
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);
};

 
 
 

```
