Author |
Message |
MerickOWA
Joined: 07 Apr 2008 Posts: 182 Location: HkRkoz al KuwaiT 2019 HaCkEr 101 |
|
Calculator Challenge |
|
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? 
|
|
Tue Aug 19, 2008 10:40 pm |
|
 |
adum

Joined: 19 Apr 2007 Posts: 392
|
|
|
|
oh, it's a friendly challenge! =)
no unary negative.
no negative tests: all input will be well formed and non-empty.
adum
|
|
Tue Aug 19, 2008 11:51 pm |
|
 |
MerickOWA
Joined: 07 Apr 2008 Posts: 182 Location: HkRkoz al KuwaiT 2019 HaCkEr 101 |
|
|
|
 |
 |
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 
|
|
Thu Aug 21, 2008 3:52 pm |
|
 |
lechat

Joined: 27 Feb 2008 Posts: 12
|
|
|
|
Do we have multi digit numbers?
|
|
Thu Aug 28, 2008 12:06 pm |
|
 |
MerickOWA
Joined: 07 Apr 2008 Posts: 182 Location: HkRkoz al KuwaiT 2019 HaCkEr 101 |
|
|
|
 |
 |
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
|
|
Thu Aug 28, 2008 3:07 pm |
|
 |
Tenebrar
Joined: 13 Jan 2008 Posts: 18
|
|
|
|
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)
|
|
Tue Sep 02, 2008 2:08 pm |
|
 |
lechat

Joined: 27 Feb 2008 Posts: 12
|
|
|
|
What you wrote is exactly how it is represented.
|
|
Tue Sep 02, 2008 4:34 pm |
|
 |
micha
Joined: 22 Dec 2008 Posts: 2
|
|
|
|
 |
 |
 |
 |
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"?
|
|
Wed Feb 04, 2009 1:22 am |
|
 |
MerickOWA
Joined: 07 Apr 2008 Posts: 182 Location: HkRkoz al KuwaiT 2019 HaCkEr 101 |
|
|
|
yep thats how its represented in memory. As lechat noted too, a null (zero) terminator denotes the end of the string.
|
|
Wed Feb 04, 2009 3:26 pm |
|
 |
cyberwoozle
Joined: 07 Nov 2008 Posts: 60 Location: Germany |
|
|
|
Do we have to expect nested parentheses like (3-(7+6))*5 ?
|
|
Fri Apr 17, 2009 9:25 pm |
|
 |
teebee

Joined: 10 Nov 2008 Posts: 89 Location: Germany |
|
|
|
I entered as solution
 |
 |
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.
|
|
Sun Apr 19, 2009 5:48 pm |
|
 |
cyberwoozle
Joined: 07 Nov 2008 Posts: 60 Location: Germany |
|
|
|
Hmmm, i could have tried this myself ... Thanks anyway!
|
|
Sun Apr 19, 2009 7:40 pm |
|
 |
|