Page 1 of 1
Calculator Challenge
Posted: Tue Aug 19, 2008 10:40 pm
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?
Posted: Tue Aug 19, 2008 11:51 pm
by adum
oh, it's a friendly challenge! =)
no unary negative.
no negative tests: all input will be well formed and non-empty.
adum
Posted: Thu Aug 21, 2008 3:52 pm
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
Posted: Thu Aug 28, 2008 12:06 pm
by lechat
Do we have multi digit numbers?
Posted: Thu Aug 28, 2008 3:07 pm
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
Posted: Tue Sep 02, 2008 2:08 pm
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)
Posted: Tue Sep 02, 2008 4:34 pm
by lechat
What you wrote is exactly how it is represented.
Posted: Wed Feb 04, 2009 1:22 am
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"?
Posted: Wed Feb 04, 2009 3:26 pm
by MerickOWA
yep thats how its represented in memory. As lechat noted too, a null (zero) terminator denotes the end of the string.
Posted: Fri Apr 17, 2009 9:25 pm
by cyberwoozle
Do we have to expect nested parentheses like (3-(7+6))*5 ?
Posted: Sun Apr 19, 2009 5:48 pm
by teebee
I entered as solution
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.
Posted: Sun Apr 19, 2009 7:40 pm
by cyberwoozle
Hmmm, i could have tried this myself ...
Thanks anyway!