Calculator Challenge

Post Reply
MerickOWA
Posts: 182
Joined: Mon Apr 07, 2008 5:54 pm
Location: HkRkoz al KuwaiT 2019 HaCkEr 101

Calculator Challenge

Post by MerickOWA »

Are we suppose to implement a unary negatate operator "-" or just the binary form?

Edit: and i'm assuming we dont need any error handling? like verifying an ending ')' or such stuff?
Edit2: do we have to handle empty string without error? ;)
User avatar
adum
Posts: 392
Joined: Thu Apr 19, 2007 12:49 pm
Contact:

Post by adum »

oh, it's a friendly challenge! =)

no unary negative.

no negative tests: all input will be well formed and non-empty.

adum
MerickOWA
Posts: 182
Joined: Mon Apr 07, 2008 5:54 pm
Location: HkRkoz al KuwaiT 2019 HaCkEr 101

Post by MerickOWA »

adum wrote:oh, it's a friendly challenge! =)

no unary negative.

no negative tests: all input will be well formed and non-empty.

adum
Might make a note on the challenge that multi digit numbers has to be handled ;)
User avatar
lechat
Posts: 12
Joined: Wed Feb 27, 2008 10:16 am

Post by lechat »

Do we have multi digit numbers?
MerickOWA
Posts: 182
Joined: Mon Apr 07, 2008 5:54 pm
Location: HkRkoz al KuwaiT 2019 HaCkEr 101

Post by MerickOWA »

lechat wrote:Do we have multi digit numbers?
We dont have the ability in hvm language to enter multidigit numbers no... but we still have to be able to support it in the calculator challenge. Example: "10+5" must print out 15 not 5 or 6
Tenebrar
Posts: 18
Joined: Sun Jan 13, 2008 1:38 pm

Post by Tenebrar »

Are the strings null-terminated?

Also, I assume numbers stored as the integer representing their character values?

("8+5*(1+2)" would be in memory as 56,43,53,42,40,49,43,50,41,0)
User avatar
lechat
Posts: 12
Joined: Wed Feb 27, 2008 10:16 am

Post by lechat »

What you wrote is exactly how it is represented.
micha
Posts: 2
Joined: Mon Dec 22, 2008 1:38 pm

Post by micha »

MerickOWA wrote:
lechat wrote:Do we have multi digit numbers?
We dont have the ability in hvm language to enter multidigit numbers no... but we still have to be able to support it in the calculator challenge. Example: "10+5" must print out 15 not 5 or 6
oh do we? so may I assume that the representation of 10+5 is "49,48,43,53"?
MerickOWA
Posts: 182
Joined: Mon Apr 07, 2008 5:54 pm
Location: HkRkoz al KuwaiT 2019 HaCkEr 101

Post by MerickOWA »

yep thats how its represented in memory. As lechat noted too, a null (zero) terminator denotes the end of the string.
cyberwoozle
Posts: 60
Joined: Fri Nov 07, 2008 10:43 am
Location: Germany

Post by cyberwoozle »

Do we have to expect nested parentheses like (3-(7+6))*5 ?
User avatar
teebee
Posts: 89
Joined: Mon Nov 10, 2008 3:21 pm
Location: Germany

Post by teebee »

I entered as solution

Code: Select all

0<p
and got
Expected: '2', got: '49' for input '10/(2+3)'
Expected: '145', got: '49' for input '1*27+(23-26+18-6)*10+(13+15)'
Expected: '-368', got: '49' for input '16*3-22+8*12-27*18-4'
Expected: '470', got: '40' for input '(7+15+15-20+15+2*(19-16+14)*24-27*14)'
Expected: '-38104', got: '50' for input '22-15*4-5-10*28*17*8+12+1*7'
Expected: '303', got: '49' for input '11-2-8-13+25+2-((11-19)*3)*12'
'0<p' is incorrect.
As you can see nested parentheses occur in some test cases. So, be prepared for them.
cyberwoozle
Posts: 60
Joined: Fri Nov 07, 2008 10:43 am
Location: Germany

Post by cyberwoozle »

Hmmm, i could have tried this myself ... :oops: Thanks anyway!
Post Reply