# Shortest Code

Write a piece of code to solve some mathematical expressions.
These mathematical expressions will be very simple - each expression will consist of two numbers and a single operation.
All numbers will be positive integers less than 100, and the only operations will be +,- and *.
There will be multiple test cases - the first line will indicate the number of tests.

Oh, I almost forgot to mention: you can't use semicolons!
Your score will be (88 / N)^2 x 10, where N is the number of non-whitespace characters in your code.

Sample Input

3
6*7
67-25
31+11

Sample Output

42
42
42

ANY IDEA??

• : Write a piece of code to solve some mathematical expressions.
: These mathematical expressions will be very simple - each expression
: will consist of two numbers and a single operation.
: All numbers will be positive integers less than 100, and the only
: operations will be +,- and *.
: There will be multiple test cases - the first line will indicate the
: number of tests.
:
: Oh, I almost forgot to mention: you can't use semicolons!
: Your score will be (88 / N)^2 x 10, where N is the number of
: non-whitespace characters in your code.
:
: Sample Input
:
: 3
: 6*7
: 67-25
: 31+11
:
: Sample Output
:
: 42
: 42
: 42
:
: ANY IDEA??
:

As far as I know, with TP the only time you could omit the semicolon is before the "end" and "else", unless is a way to work around this. I would like to see a code myself too...
• : :
: : Oh, I almost forgot to mention: you can't use semicolons!
:
: As far as I know, with TP the only time you could omit the semicolon
: is before the "end" and "else", unless is a way to work around this.
: I would like to see a code myself too...
:
Even if there is some way around the use of semicolons, such an approach amounts to trickery of little use in day to day programming.

• : Write a piece of code to solve some mathematical expressions.
: These mathematical expressions will be very simple - each expression
: will consist of two numbers and a single operation.
: All numbers will be positive integers less than 100, and the only
: operations will be +,- and *.
: There will be multiple test cases - the first line will indicate the
: number of tests.
:
: Oh, I almost forgot to mention: you can't use semicolons!
: Your score will be (88 / N)^2 x 10, where N is the number of
: non-whitespace characters in your code.
:
: Sample Input
:
: 3
: 6*7
: 67-25
: 31+11
:
: Sample Output
:
: 42
: 42
: 42
:
: ANY IDEA??
:

Judging by the scoring, it can be done in 88 characters. I don't believe it though. Even using inline assembly I think would be too long, although it would support the no semicolons thing.
I as well would like to see this.
• [color=Blue]Can it be done using semi colons?[/color]

• : [color=Blue]Can it be done using semi colons?[/color]
:
:
Using semi colons is quite simple:

[color=Blue][code]
function parse:integer; {Only addition is implemented here}
const t:integer=-1;
var s,s1,s2:string;
b:byte;
a1,a2,err:integer;
begin
write(
• : [color=Blue]Can it be done using semi colons?[/color]
:
:
Certainly it canbe done [italic]with[/italic] semicolons, but I am convinced it is impossible to do it without semicolons, and I will remain convinced until someone shows me some code that proves otherwise! That's assuming that doing it in Pascal is also a requirement (this [italic]is[/italic] a Pascal forum). In Fortran, Cobol, Basic and probably a multitude of other languages semicolons are not needed. Fortran and Basic use newlines as statement separators and Cobol (if memory serves) uses periods.

Where did this project originate anyway?

• Here's the best I can do quickly. I suppose you could convert some to assembly and maybe remove some semi-colons.
Anyways it has 7 semicolons and is well over 88 bytes. Harder to read as I rename the procedure from "ToVal" to "V" for less characters. Definitely not optimized, but who knows how else.

[code]
VAR
S : String;

FUNCTION V(S : String) : Word;
VAR X, Y : Byte;
Begin
Y := 0;
For X := 1 to Length(S) Do
Y := Y*10 + Ord(S[X])-48;
V := Y
End;

Begin
If Pos('+',S) <> 0 Then
Begin
WriteLn(V(Copy(S,1,Pos('+',S)-1))+V(Copy(S,Pos('+',S)+1,Length(S))))
End
ELSE
If Pos('-',S) <> 0 Then
Begin
WriteLn(V(Copy(S,1,Pos('-',S)-1))-V(Copy(S,Pos('-',S)+1,Length(S))))
End
ELSE
If Pos('*',S) <> 0 Then
Begin
WriteLn(V(Copy(S,1,Pos('*',S)-1))*V(Copy(S,Pos('*',S)+1,Length(S))))
End
End.
[/code]