1

Bonjour/bonsoir, je vous présente ici la première version de mon projet pour le zContest 2011.

Voici la présentation française (celle du site du concours)

Calcul exact par étapes      Auteur : sandro     Langage / Catégorie : TI-Basic Type : Programme 
Compatible : TI 82 STATS, TI 83, TI 83 Plus, TI 84 Plus. 

Voci un programme de calcul exact. Il s'effectue par étapes, chacune étant affichée (pratique pour les devoirs
de maths quand le prof demande les étapes intermédiaires).

Pour l'insant, ce programme ne gère que des résultats rationnels.

Les oppérations admises pour l'instant sont : l'addition, la soustraction, la multiplication, la division,
le carré, le cube, et l'inverse. Le programme gère également les parrenthèses et les fractions (sous
la forme {entier relatif:entier positif} ). Les constantes et autres oppérations ne son t pas accèptées pour l'instant.

A la fin, le programme affiche le résultat arrondit.

Pour afficher l'étape suivante, appuyez sur [entrer] ( [enter] ); si rien ne s'affiche de plus, c'est que la TI n'a
pas encore trouvée l'étape suivante.


Sandro


Voci les liens :
tromb Fichier joint : CALCAUTO.83p
tromb Fichier joint : _theta__theta_ADD.83p
tromb Fichier joint : _theta__theta_ADDF.83p
tromb Fichier joint : _theta__theta_CARCU.83p
tromb Fichier joint : _theta__theta_CARCUF.83p
tromb Fichier joint : _theta__theta_DETBC.83p
tromb Fichier joint : _theta__theta_DIV.83p
tromb Fichier joint : _theta__theta_DIVFPN.83p
tromb Fichier joint : _theta__theta_DIVPF.83p
tromb Fichier joint : _theta__theta_INV.83p
tromb Fichier joint : _theta__theta_MULT.83p
tromb Fichier joint : _theta__theta_MULTF.83p
tromb Fichier joint : _theta__theta_SIGNE.83p
tromb Fichier joint : _theta_DELPAR.83p
tromb Fichier joint : _theta_MONONIV.83p
tromb Fichier joint : _theta_NIVPAR.83p

Voici les codes :
programmeCALCAUTO (programme à lancer, veille à alterner entre le programme de calcul, et celui de supression de parrenthèses (pour l'instant très court, mais qui ce compliquera quand je rajouterrais les racines).

0 -> K
" " -> Str8
"{E,E -> L6
"{1,2 -> L5
Input "CALCUL:",Str0
Str0 -> Str6
"  "+Str0+"  " -> Str0
" " -> Str7
ClrHome
While Str7=/=Str0
Str0 -> Str7
prgm[théta]MONONIV
prgm[théta]DELPAR
End
sub(Str0,3,length(Str0)-4 -> Str9

1 -> A
While A
inString(Str9,"{",A -> A
If A:Then
"("+sub(Str9,A+1,length(Str9)-A -> Str2
If A=/=1
sub(Str9,1,A-1)+Str2 -> Str2
Str2 -> Str9
End
End

1 -> A
While A
inString(Str9,":",A+1 -> A
If A
sub(Str9,1,A-1)+"/"+sub(Str9,A+1,length(Str9)-A -> Str9
End

1 -> A
While A
inString(Str9,"}",A+1 -> A
If A
Then
sub(Str9,1,A-1)+")" -> Str2
If A=/=length(Str9
Str2+sub(Str9,A+1,length(Str9)-A -> Str2
Str2 -> Str9
End

Pause expr(Str9


programme[théta]NIVPAR  (trouve quels sont les "niveaux de parrenthèses" (combien siont ouverte à tel endroit) 
{0 -> L1
length(Str0 -> L
L -> dim(L1
For(A,1,L
sub(Str0,A,1 -> Str2
If Str2=")
-1 -> L1(A+1
If inString("(sin(cos(tan(sin-1(cos-1(tan-1([e^(][10^(][racine carré)[racine cube]Ýð(",Str2                    //les crochets servent juste pour signaler qu'il s'agit d'un seul et même symbol
1 -> L1(A+1
End
cumSum(L1 -> L2


programme[théta]MONONIV  (gère les sous-programmes propre à chaque oppération)

3 -> A
While A+3[inférieur ou égal]length(Str0
If Str8=/=Str0
Then
If K
Pause 
1 -> K
Disp sub(Str0,3,length(Str0)-4
Str0 -> Str8
End
A -> B
A+1 -> A
A+1 -> C
1 -> [théta]
sub(Str0,A,1 -> Str9
prgm[théta][théta]SIGNE
If Str9="+
prgm[théta][théta]ADD
If Str9="*
prgm[théta][théta]MULT
If Str9="[carré]
DelVar [théta]prgm[théta][théta]CARCU
If Str9="/
prgm[théta][théta]DIV
If Str9="[^-1]
prgm[théta][théta]INV
If Str9="[cube]
prgm[théta][théta]CARCU
End


programme[théta]DELPAR

If inString(Str0,"("
Then
1üB
While B
inString(Str0,"(",B+1 -> B
If B:B -> A
End

A -> B

1 -> C
B+1 -> A
While C
A+1 -> A
sub(Str0,A,1 -> Str2
If Str2=")
C-1 -> C
If inString("(sin(cos(tan(sin-1(cos-1(tan-1([10^(][e^(][racine carré][racine cube]",Str2
C+1 -> C
End
A -> C

sub(Str0,B+1,C-B-1 -> Str4


1 -> D
For(A,1,length(Str4
If not(inString("[moins des relatifs]0.123456789{:}",sub(Str4,A,1
0 -> D

If D
Then
sub(Str0,1,B-1)+Str4+sub(Str0,C+1,length(Str0)-C -> Str0
Return
End




sub(Str0,A-1,1 -> Str2
sub(Str0,B+1,1 -> Str3



programme[théta][théta]ADD (addition-soustraction)

"^/*) -> Str1
"^/*([inverse][carré][cube][pi]e -> Str7
If sub(Str0,A,2)="+{" or "}+"=sub(Str0,B,2
Then
1 -> X
prgm[théta][théta]ADDF
If not(X:Return
Else
prgm[théta][théta]DETBC
If not(X:Return

expr(Str2 -> E

LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str2
sub(Str2,4,length(Str2)-3 -> Str2

End

sub(Str0,1,B)+Str2+sub(Str0,C,length(Str0)-C+1 -> Str0
1 -> A


programme[théta][théta]ADDF (addition et soustractions avec fraction)

1 -> X
prgm[théta][théta]DETBC
If not(X:Return

sub(Str0,B+1,A-B-1 -> Str2
sub(Str0,A+1,C-A-1 -> Str3

inString(Str2,": -> H
inString(Str3,": -> M

If H
Then
expr(sub(Str2,2,H-2 -> N
expr(sub(Str2,H+1,length(Str2)-H-1 -> O
Else
expr(Str2 -> N
1 -> O
End

If M
Then
expr(sub(Str3,2,M-2 -> P
expr(sub(Str3,M+1,length(Str3)-M-1 -> Q
Else
expr(Str3 -> P
1 -> Q
End

While fPart(N) or fPart(O
10N -> N
10O -> O
End
While fPart(P) or fPart(Q
10P -> P
10Q -> Q
End

gcd(abs(N),abs(O))^-1 -> H
NH -> N
OH -> O

gcd(abs(P),abs(Q))^-1 -> M
PM -> P
QM -> Q

OQ -> V
NQ+PO -> U

(-2(V<0)+1)gcd(abs(U),abs(V))^-1 -> W
UW -> U
VW -> V

U -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str2
V -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str3

If U=0
Then
"0 -> Str2
Else
sub(Str2,4,length(Str2)-3 -> Str2
If V=/=1
"{"+Str2+":"+sub(Str3,4,length(Str3)-3)+"} -> Str2



programme[théta][théta]CARCU           (carré et cube)

If "}"=sub(Str0,B,1
Then
prgm[théta][théta]CARCUF
Else

While Bø1 and inString("0.123456789à",sub(Str0,B,1
B-1 -> B
End
If ")"=sub(Str0,B,1
Return

If B=1:0 -> B

sub(Str0,B+1,A-B -> Str2

expr(Str2 -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str2
sub(Str2,4,length(Str2)-3 -> Str2

End

sub(Str0,1,B)+Str2+sub(Str0,A+1,length(Str0)-A -> Str0
1 -> A


programme[théta][théta]CARCUF    (cube et carré de fractions)

While Bø1 and "{"øsub(Str0,B,1
B-1 -> B
End
B-1 -> B

If B=1:0 -> B

inString(Str0,":",B+2 -> H

sub(Str0,B+2,H-B-2 -> Str2
sub(Str0,H+1,A-H-2 -> Str3

expr(Str2)^(2+[theta]) -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str2

expr(Str3)^(2+[theta]) -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str3
"{"+sub(Str2,4,length(Str2)-3)+":"+sub(Str3,4,length(Str3)-3)+"}" -> Str2



PROGRAMME[théta][théta]DETBC      (calcule B et C, respectivement le rand du dernier carractère avant la chaîne exprimée et le premier après)

While Bø1 and inString("[le moins des relatifs]0.123456789à{:}",sub(Str0,B,1
B-1 -> B
End
If inString(Str1,sub(Str0,B,1
DelVar XReturn

If B=1:0 -> B

While Cølength(Str0) and inString("-0.123456789à{:}",sub(Str0,C,1
C+1 -> C
End
If inString(Str7,sub(Str0,C,1
DelVar XReturn

If C=length(Str0:C+1 -> C

sub(Str0,B+1,C-B-1 -> Str2


[théta][théta]DIV   (division d'un nombre décimal par un autre

"/^) -> Str1
"^([inverse][carré][cube][pi]e -> Str7                  //les crochets servent uniquement a marquer les carracteres speciaux
1 -> X
If "}"=sub(Str0,A-1,1) and inString("0.-123456789",sub(Str0,A+1,1
Then
prgm[theta][theta]DIVFPN
If not(X:Return
Else
If "/{"=sub(Str0,A,2
Then
prgm[thete][theta]DIVPF
If not(X:Return
Else

prgm[theta][theta]DETBC
If not(X:Return

expr(Str2 -> E
If not(fPart(E[E des puissances de 10]5
Then
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str2
sub(Str2,4,length(Str2)-3 -> Str2
Goto Q
End


sub(Str0,B+1,A-B-1 -> Str2
sub(Str0,A+1,C-A-1 -> Str3

expr(Str2 -> U
expr(Str3 -> V
While fPart(U) or fPart(V
10U -> U
10V -> V
End
(-2(V<0)+1)gcd(abs(U),abs(V))^-1 -> N
UN -> U
VN -> V
U -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str2
V -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str3

"{"+sub(Str2,4,length(Str2)-3)+":"+sub(Str3,4,length(Str3)-3)+"} -> Str2

Lbl Q

End
End

sub(Str0,1,B)+Str2+sub(Str0,C,length(Str0)-C+1 -> Str0
1 -> A


[théta][théta]DIVFPN           (division d'une fraction par un  un nombre)

prgm[theta][theta]DETBC
If not(X:Return

inString(Str0,":",B+1 -> H

sub(Str0,B+2,H-B-2 -> Str2
sub(Str0,H+1,A-H-2 -> Str3
sub(Str0,A+1,C-A-1 -> Str4

expr(Str2 -> U
expr(Str3 -> V
expr(Str4 -> W

VW -> V

(-2(V<0)+1)gcd(abs(U),abs(V))^-1 -> N
UN -> U
VN -> V

U -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str2
sub(Str2,4,length(Str2)-3 -> Str2
V -> E
LinReg(ax+b)L5,L6,Y9
EquåString(Y9,Str3
sub(Str3,4,length(Str3)-3 -> Str3

If V=/=0
"{"+Str2+":"+Str3+"}" -> Str2 



programme[théta][théta]DIVPF            (division par une fraction)

inString(Str0,":",A+2 -> H
inString(Str0,"}",H+2 -> I
sub(Str0,A+2,H-A-2 -> Str2
sub(Str0,H+1,I-H-1 -> Str3
"*{"+Str3+":"+Str2+"}" -> Str2
I+1 -> C
If inString("^[^-1][^2][^3][pi](e",sub(Str0,C,1
DelVar X



programme[théta][théta]INV          (inverse d'un nombre)

While inString("[moins des relatifs]0.123456789{:}",sub(Str0,B,1
B-1 -> B
End

sub(Str0,B+1,A-B-1 -> Str4

inString(Str4,":" -> H

If H
Then
sub(Str4,2,H-2 -> Str2
sub(Str4,H+1,length(Str4)-H-1 -> Str3
expr(Str2 -> V
expr(Str3 -> U
Else
expr(Str4) -> V
1 -> U
End

While fPart(U) or fPart(V
10U -> U
10V -> V
End

(-2(U<0)+1)gcd(abs(U),abs(V))^-1 -> H
UH -> U
VH -> V

U -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str2

V -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str3

If U=0
Then
"0 -> Str2
Else
sub(Str2,4,length(Str2)-3 -> Str2
If V=/=1
"{"+Str2+":"+sub(Str3,4,length(Str3)-3)+"}" -> Str2
sub(Str0,1,B)+Str2+sub(Str0,A+1,length(Str0)-A -> Str0



programme[théta][théta]MULT           (multiplication)

"^)/ -> Str1
"^([^-1][^2][^3][pi]e -> Str7
1 -> X
If "}"=sub(Str0,A-1,1) or "{"=sub(Str0,A+1,1
Then
prgm[theta][theta]MULTF
If not(X:Return
Else
prgm[theta][theta]DETBC
If not(X:Return

expr(Str2 -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str2
sub(Str2,4,length(Str2)-3 -> Str2

End


sub(Str0,1,B)+Str2+sub(Str0,C,length(Str0)-C+1 -> Str0
1 -> A




programme[théta][théta]MULTF         (multiplication avec fraction(s) )

While B=/=1 and inString(":{}-0.123456789",sub(Str0,B,1
B-1 -> B
End

If inString("^/)",sub(Str0,B,1
Return

If B=1:0 -> B

sub(Str0,B+1,A-B-1üStr2
inString(Str2,":" -> H

If H
Then

expr(sub(Str2,2,H-2 -> N

expr(sub(Str2,H+1,length(Str2)-H-1 -> O

Else

expr(Str2 -> N
1 -> O
While fPart(N
10N -> N
10O -> O
End
gcd(abs(N),O)^-1üG
NG -> N
OG -> O
End

A+1 -> C
While C=/=length(Str0) and inString(":{}-0.123456789",sub(Str0,C,1
C+1 -> C
End

If inString("^)sin(cos(tan(sin-1(cos-1(tan-1([pi]e[10^(][e^(][^-1][^2][^3][racine carre][racine cube] [racine X]",sub(Str0,C,1
DelVar XReturn

If C=length(Str0):C+1 -> C

sub(Str0,A+1,C-A-1 -> Str2
inString(Str2,":" -> H

If H
Then
expr(sub(Str2,2,H-2 -> P

expr(sub(Str2,H+1,length(Str2)-H-1 -> Q

Else

expr(Str2 -> P

1 -> Q
While fPart(P
10P -> P
10Q -> Q
End

gcd(abs(P),Q)^-1üG
PG -> P
QG -> Q
End


NP -> U
OQ -> V
(-2(V<0)+1)gcd(abs(U),abs(V))^-1üG
UG -> U
VG -> V

U -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str2

sub(Str2,4,length(Str2)-3 -> Str2

V -> E
LinReg(ax+b)L5,L6,Y9
Eq>String(Y9,Str3
sub(Str3,4,length(Str3)-3 -> Str3

If U=0
Then
"0 -> Str2

Else

If V=/=1
"{"+Str2+":"+Str3+"}" -> Str2



programme[théta][théta]SIGNE         (transforme la soustraction en addition)

1 -> Y
While Y
inString(Str0,"[moins des soustractions]",Y -> Y
If Y
Then
If "{"=sub(Str0,Y+1,1
Then
sub(Str0,1,Y-1)+"+{[moins des relatifs]"+sub(Str0,Y+2,length(Str0)-Y-1 -> Str0
Else
sub(Str0,1,Y-1)+"+[moins des relatifs]"+sub(Str0,Y+1,length(Str0)-Y -> Str0
End
End
End







Sandro

2

Tu as un sacré niveau en basic sandro O_O ...

3

Merci, je suis en train de mêttre les codes sources des autres sous-programmes, mais ça prend du temps avec tous les carractères spéciaux donc je ne finnirais peut-être pas aujourd'hui. Après, c'est sur que un programme comme ça, ça demande beaucoup de temps (enfin, ça je l'ai eut la semaine dernière, coinsé au pays basque sous la plui sans ordi. La plus grande difficulté pour moi pour l'instant à été de trouver à chaque fois la longueur correcte pour les sous-chaines (la plus part du temps, j'ai vérifié en comptant sur mes doits pour être sûr (surtout que si on à "expr(ChaîneX)" et que chaînex n'est pas "exprimable", l'erreur syntaxe renvoie pas à l'erreur)).

Sandro

EDIT : le code du programme est maintenant entièrement présent sur le premier post; s'il reste des carractères spéciaux, merci de bien vouloir les signaler (ce sont ceux de TIprogramEditor

4

http://tiforge.info/ti_editor/ permet de convertir les caractères spéciaux il me semble smile

Et si ton code source est finit ce serait possible de mettre les binaires (.83p etc...) sur le site ?

5

Pour le code, je ne pense pas qu'il soit finit, j'aimerais bien l'étendre à l'ensemble des réels (rajout des racines carrées(peu-être aussi cubes voir X), des constantes (pi et e), des puissances, la trigo (facile une fois qu'ion à les racines carrées),...). Bref, je ne pense pas finir de si tôt, la version actuelle n'estr que la première cohérent (pas de résultats non admis dans la limite des oppérations admises), mais sauf pour les collégieus ayant une TI82stats ou plus (ce qui n'est pas très fréqquent), l'interêt reste plutôt limité.

Pour TI éditor, serte le résultat est copiable, mais les carractères spéciaux sont convertis en codes bizzards.

Merci quand-même
Sandro

PS : est-ce que le même projet peut être présenté dans plusieures catégories? (par example un examplaire en basic pur, un autre avec des codes héxa pour certains algoritmes et un 3ème en assembleur pur?)

6

Le site va le gérer comme trois projets distincts, ce qui est plutôt vrai puisque le code source change... Mais bon je ne vois pas ce que ça apporterait à ton projet de le faire de différentes façons.

7

C'est vrai que ça ne changera pas grand chose, mais quelques codes héxa peuvent peut-être rendre le programme plus fluide (mais plus lourd et non recopiable saus risque à la main). Pour l'asm pur, c'était plus pour généralisr qu'autre chose (je n'ai pas le niveau nécéssaire).

Sandro

PS : je me trompe ou les débugueurs ASM de VTI et Wabbitemu donnent le code décompilé de la rom? (0000 à FFFFFF me semble bien trop gros pour être la RAM).

8

La RAM ne fait que 32ko et est située entre $8000 et $FFFF, comme indiqué ici : http://www.mworld.fr/html/projects/calc/ti-82/tutoriel/progasm/guide/lesson5.html#memorymap donc oui avec le débuggeur du peux théoriquement aller voir la ROM.

9

Et si tu regardes bien tu trouves normalement des correspondances avec "RAM.CLEARED" ou même "SELF.TEST" bref ce que tu vois est bien la rom tongue
(Mais je ne connais pas le debugger de VTI ou wabbitemu)

10

Merci beaucoup.