Update
I think I finally did it.
I have ONE source code, with a hard coded algorithm to test with..
It can resize the original entrants using the rule first value = iterator, operand = iterator, and second value = iterator+1 and result is integerarray(t+1)
or integerarray( iterator+1)
Yes..
and because it shifts all the numbers around the only thing I had left to do was to flag the ones to be removed..
both integers and numbers
leaving only valid integers in the list of ints and only valid integers in the list of ints
with the operands list still being 1 less in length or numerical indexes than the integer list
my god this was hard to solve... took nearly 3 days lol
But I basically here and for the most part have solved all the math stack problems.
REJOICE TinySB development is near completion! (for the alpha anyways... *ahem* )
Let's get some cake.. I mean coke.. I mean coca cola.
Here's the frikkin awesome code that runs inside PlayBasic
Spoiler
; PROJECT : TestingAgain
; AUTHOR : Microsoft
; CREATED : 5/24/2016
; EDITED : 5/24/2016
; ---------------------------------------------------------------------
//I don't want to write the functions so i'll define some of these things specifically
inputstr$="1800-3/3+28*8/9-8/2"
//inputstr$="1800-1+28*8/9-8/2"
//inputstr$="1800-1+224/9-8/2"
//inputstr$="1800-1+24-8/2"
//inputstr$="1800-1+24-4"
dim intslist(8)
intslist(1)=1800
intslist(2)=3
intslist(3)=3
intslist(4)=28
intslist(5)=8
intslist(6)=9
intslist(7)=8
intslist(8)=2
dim intslist$(8)
//make a list of the ints that are flagged
for t=1 to 8
intslist$(t)=str$(intslist(t))
next t
dim operandslist$(7)
operandslist$(1)="-"
operandslist$(2)="/"
operandslist$(3)="+"
operandslist$(4)="*"
operandslist$(5)="/"
operandslist$(6)="-"
operandslist$(7)="/"
//first divide or multiply
for divmult=1 to 7
if operandslist$(divmult) ="/" then inputstr$ = divide(divmult, inputstr$)
if operandslist$(divmult) ="*" then inputstr$ = multiply(divmult, inputstr$)
next divmult
//Now we have our flag list
//first count the remaining operands
dim newlist$(1)
for tt=1 to 7
if operandslist$(tt) !="!"
inc operandcount
redim newlist$(operandcount)
newlist$(operandcount) = operandslist$(tt)
endif
next tt
dim newintlist$(1)
for tt=1 to 8
if intslist$(tt) !="!"
inc intcount
redim newintlist$(intcount)
newintlist$(intcount) = intslist$(tt)
endif
next tt
//after generating a new list proper for this
//We want to copy it to the old lists
redim intslist(intcount)
redim operandslist$(operandcount)
for tt=1 to intcount
intslist(tt) = val (newintlist$(tt))
next tt
for gg=1 to operandcount
operandslist$(gg) = newlist$(gg)
next gg
//finally attempt solving
for cc=1 to operandcount
if operandslist$(cc) = "-" then inputstr$ = subtract(cc, inputstr$)
#print inputstr$
if operandslist$(cc) = "+" then inputstr$ = add(cc, inputstr$)
next cc
//The values in the code above evaluate to : startps =
//inputstr$ = replace$(inputstr$, mid$(inputstr$, 0, 5), "!", 0, 0, 1)
print inputstr$
print "hi"
waitkey
waitnokey
psub getchar(str_$, ptr)
char_$ = mid$(str_$, ptr, 1)
endpsub char_$
psub divide(t, inputstr$)
found=false
if operandslist$(t) = "/"
first_value =intslist(t)
second_value =intslist(t+1)
firstvalue$ =str$(first_value)
secondvalue$= str$(second_value)
firstlength = len(firstvalue$)
secondlength = len(secondvalue$)
//try the divide and conquer!!
result = first_value / second_value
#print "Divide " +str$(first_value ) +" "+ str$(second_value)
for gx=1 to len(inputstr$)
//this part tries to find the symbol in the source string and replace it
if getchar(inputstr$, gx) ="/" //symbol found
operandslist$(t)="!"
startps = gx
extractst = startps -firstlength
endps = firstlength + secondlength+1
removed$ = mid$(inputstr$, extractst, endps )
//#print removed$
#print result
//Convert the result number to a string for injection into the source string
solution$ = str$(result)
intslist(t+1)= result //Update the ints list?
//try to flag the integer list
intslist$(t)="!" //flagged
intslist$(t+1) = str$(result) //store this result too
//Inject a "!" instead of the sub string we just solved
inputstr$ = replace$(inputstr$, removed$, "!", extractst-firstlength+secondlength, 0, 1) //only replace the first occurence
//start at 0
//Inject the result
inputstr$ = replace$(inputstr$, "!", solution$, extractst-firstlength+secondlength, 0, 1 )
bb =gx
n$ =inputstr$
exitfor
endif
next gx
endif
endpsub n$
psub multiply(t, inputstr$)
found=false
if operandslist$(t) = "*"
first_value =intslist(t)
second_value =intslist(t+1)
firstvalue$ =str$(first_value)
secondvalue$= str$(second_value)
firstlength = len(firstvalue$)
secondlength = len(secondvalue$)
//try the divide and conquer!!
result = first_value * second_value
#print "Multiply " +str$(first_value ) +" " +str$(second_value)
for gx=1 to len(inputstr$)
//this part tries to find the symbol in the source string and replace it
if getchar(inputstr$, gx) ="*" //symbol found
operandslist$(t) ="!"
startps = gx
extractst = startps -firstlength
endps = firstlength + secondlength+1
removed$ = mid$(inputstr$, extractst, endps )
//#print removed$
//#print result
//Convert the result number to a string for injection into the source string
solution$ = str$(result)
intslist(t+1)= result //Update the ints list?
//try to flag the integer list
intslist$(t)="!" //flagged
intslist$(t+1) = str$(result) //store this result too
//Inject a "!" instead of the sub string we just solved
inputstr$ = replace$(inputstr$, removed$, "!", extractst-firstlength+secondlength, 0, 1) //only replace the first occurence
//start at 0
//Inject the result
inputstr$ = replace$(inputstr$, "!", solution$, extractst-firstlength+secondlength, 0, 1 )
bb =gx
n$ =inputstr$
exitfor
endif
next gx
endif
endpsub n$
psub subtract(t, inputstr$)
found=false
if operandslist$(t) = "-"
first_value =intslist(t)
second_value =intslist(t+1)
firstvalue$ =str$(first_value)
secondvalue$= str$(second_value)
firstlength = len(firstvalue$)
secondlength = len(secondvalue$)
//try the divide and conquer!!
result = first_value - second_value
#print "subtract " +str$(first_value ) +" "+ str$(second_value)
for gx=1 to len(inputstr$)
//this part tries to find the symbol in the source string and replace it
if getchar(inputstr$, gx) ="-" //symbol found
startps = gx
extractst = startps -firstlength
endps = firstlength + secondlength+1
removed$ = mid$(inputstr$, extractst, endps )
//#print removed$
//#print result
//Convert the result number to a string for injection into the source string
solution$ = str$(result)
intslist(t+1)= result //Update the ints list?
//Inject a "!" instead of the sub string we just solved
inputstr$ = replace$(inputstr$, removed$, "!", extractst-firstlength+secondlength, 0, 1) //only replace the first occurence
//start at 0
//Inject the result
inputstr$ = replace$(inputstr$, "!", solution$, extractst-firstlength+secondlength, 0, 1 )
bb =gx
n$ =inputstr$
exitfor
endif
next gx
endif
endpsub n$
psub add(t, inputstr$)
found=false
if operandslist$(t) = "+"
first_value =intslist(t)
second_value =intslist(t+1)
firstvalue$ =str$(first_value)
secondvalue$= str$(second_value)
firstlength = len(firstvalue$)
secondlength = len(secondvalue$)
//try the divide and conquer!!
result = first_value + second_value
#print "Add " +str$(first_value ) +" " +str$(second_value)
for gx=1 to len(inputstr$)
//this part tries to find the symbol in the source string and replace it
if getchar(inputstr$, gx) ="+" //symbol found
startps = gx
extractst = startps -firstlength
endps = firstlength + secondlength+1
removed$ = mid$(inputstr$, extractst, endps )
//#print removed$
//#print result
//Convert the result number to a string for injection into the source string
solution$ = str$(result)
intslist(t+1)= result //Update the ints list?
//Inject a "!" instead of the sub string we just solved
inputstr$ = replace$(inputstr$, removed$, "!", extractst-firstlength+secondlength, 0, 1) //only replace the first occurence
//start at 0
//Inject the result
inputstr$ = replace$(inputstr$, "!", solution$, extractst-firstlength+secondlength, 0, 1 )
bb =gx
n$ =inputstr$
exitfor
endif
next gx
endif
endpsub n$
I'm not posting it in the code tag as it would probably mangle it.