Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   My baby (https://forums.graalonline.com/forums/showthread.php?t=65269)

Yen 04-09-2006 05:20 AM

My baby
 
PHP Code:

function onFactorSynDiv(equation) {
  
this.result "";
  
this.equation equation;
  
this.oequation equation;
  
this.factors "";
  
temp.checkfactor this.equation[this.equation.size()-1];
  for (
abs(temp.checkfactor)*-1<= abs(temp.checkfactor); a++) {
    if ((
temp.checkfactor a) == int(temp.checkfactor a)) {
      if (
== 0) continue;
      if (
temp.used.index(temp.checkfactor a) == -1) {
        
this.factors.add(temp.checkfactor a);
        
temp.used.add(temp.checkfactor a);
      }
    }
  }

  
onSyntheticDivision(this.factors[0],this.equation);
}

function 
NextDiv() {
  
this.factors.delete(0);
  if (
this.factors.size() > 0onSyntheticDivision(this.factors[0],this.equation);
  else {
    if (
this.result == "") {
      echo(
ParseEquation(this.equationSPC "cannot be factored by this method.");
      return;
    }
    echo(
ParseEquation(this.oequation));
    echo(
"Divided down to" SPC this.result);
    if (
this.equation.size() > 0) {
      if (
this.equation[0] != 1) {
        echo(
ParseEquation(this.equationSPC "is left over.");
      }
    }
    echo(
"Result:" SPC this.result ParseEquation(this.equation));
  }
}

function 
onSyntheticDivision(factor,equation) {
  if ((
equation[equation.size()-1] / factor) != int(equation[equation.size()-1] / factor)) {
    
NextDiv();
    return;
  }
  
temp.arr1 = new[equation.size()];
  
temp.arr2 = new[equation.size()];
  
  
temp.arr2[0] = equation[0];
  
  for (
1equation.size(); a++) {
    
temp.arr1[a] = temp.arr2[a-1] * factor;
    
temp.arr2[a] = temp.arr1[a] + equation[a];
  }
  if (
temp.arr2[temp.arr2.size()-1] == 0) {
    
temp.arr2.delete(temp.arr2.size()-1);
    
this.equation temp.arr2;
    
this.result @= "(x";
    if ((
factor*-1) < 0this.result @= " - ";
    else 
this.result @= " + ";
    
this.result @= abs(factor) @ ")";
  }
  
NextDiv();
}

function 
ParseVar(factor) {
  if (
factor 0) return "+" factor;
  else return 
factor;
}

function 
ParseEquation(equation) {
  for (
0equation.size(); e++) {
    if (
equation[e] == 0) continue;
    if (
equation.size() - 1) {
      if (
abs(equation[e]) == 1temp.toreturn @= "x";
      else 
temp.toreturn @= abs(equation[e]) @ "x";
    }
    else 
temp.toreturn @= abs(equation[e]);
    if (
equation.size() - 2temp.toreturn @= "^" equation.size() - e;
    if (
equation.size() - 1) {
      if (
equation[e] < 0temp.toreturn @= " - ";
      else 
temp.toreturn @= " + ";
    }
  }
  if (
temp.toreturn == 1) return "";
  return 
temp.toreturn;


Synthetic division, anyone?

Googi 04-09-2006 05:26 AM

Huh? It's just a calculator.

Yen 04-09-2006 05:31 AM

>:|
Can your calculator factor x^2 + 5x + 6!?

Of course it can by finding the zero values, but can it actually give (x+2)(x+3) at once?

napo_p2p 04-09-2006 06:59 AM

Quote:

Originally Posted by Yen
>:|
Can your calculator factor x^2 + 5x + 6!?

Yea. >_<

xXziroXx 04-09-2006 11:46 AM

So can my calculator, nothing special. I can even make games with mine! (seriously!)

napo_p2p 04-09-2006 11:50 AM

Quote:

Originally Posted by xXziroXx
So can my calculator, nothing special.

Nah, I still think it's nice though. And it's special on Graal. I never saw one before (on Graal).

Goob job Yen!

Omini 04-09-2006 12:24 PM

Kinda makes me wish I could script... well I can but only a little in GS1, when it comes to GS2 I havn't got a chance. :p

excaliber7388 04-09-2006 05:13 PM

^^ nice

Python523 04-09-2006 05:20 PM

Just what I always wanted, a factor tool that can't handle fraction factors

ZeLpH_MyStiK 04-09-2006 06:03 PM

Quote:

Originally Posted by Python523
Just what I always wanted, a factor tool that can't handle fraction factors

Great! I'll be sure to sign on Graal to use a calculator when my TI runs out of battery. I hope you update this calculator to perform multivariable calculus functions.

Damix2 04-09-2006 06:51 PM

Quote:

Originally Posted by Yen
>:|
Can your calculator factor x^2 + 5x + 6!?

Of course it can by finding the zero values, but can it actually give (x+2)(x+3) at once?

Yes.

Yen 04-09-2006 07:33 PM

:( My calculator can't.
I feel gimp..
BRB slitting wrists.

ApothiX 04-11-2006 02:34 PM

Quote:

Originally Posted by Yen
:( My calculator can't.
I feel gimp..
BRB slitting wrists.

Go spend $200 on a TI calculator :(

Yen 04-12-2006 01:25 AM

I have one. :(

It can't do factors as far as I know, though.

jake13jake 04-12-2006 01:43 AM

Ugh I hate stacks.

Prozac 04-12-2006 06:27 AM

... so am I the only one who loves programming
but hates math?

Andy0687 04-12-2006 09:38 AM

Quote:

Originally Posted by Prozac
... so am I the only one who loves programming
but hates math?

nope, i despised all my math classes.

jake13jake 04-12-2006 04:20 PM

Yen, you should just make a stack loader that will take in for a string of numbers and operators... and perhaps make some sort of interpretation for variable names.

Prozac 04-12-2006 06:01 PM

since there is talk of a data structure (a stack)
let's see a gscript bubble sort
or better yet
a red-black threaded binary search tree
(the data structure used on most operating systems to store and access information on hard drives)

jake13jake 04-12-2006 06:06 PM

Quote:

Originally Posted by Prozac
since there is talk of a data structure (a stack)
let's see a gscript bubble sort
or better yet
a red-black threaded binary search tree
(the data structure used on most operating systems to store and access information on hard drives)

ewww @ bubblesort... takes too long... ewwwwww


All times are GMT +2. The time now is 10:07 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.