hacker.org Forum Index
RegisterSearchFAQMemberlistUsergroupsLog in
Calculator Challenge

 
Reply to topic    hacker.org Forum Index » Challenges View previous topic
View next topic
Calculator Challenge
Author Message
MerickOWA



Joined: 07 Apr 2008
Posts: 182
Location: HkRkoz al KuwaiT 2019 HaCkEr 101

Post Calculator Challenge Reply with quote
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? Wink
Tue Aug 19, 2008 10:40 pm View user's profile Send private message
adum



Joined: 19 Apr 2007
Posts: 391

Post Reply with quote
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 View user's profile Send private message Visit poster's website
MerickOWA



Joined: 07 Apr 2008
Posts: 182
Location: HkRkoz al KuwaiT 2019 HaCkEr 101

Post Reply with quote
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 Wink
Thu Aug 21, 2008 3:52 pm View user's profile Send private message
lechat



Joined: 27 Feb 2008
Posts: 12

Post Reply with quote
Do we have multi digit numbers?
Thu Aug 28, 2008 12:06 pm View user's profile Send private message
MerickOWA



Joined: 07 Apr 2008
Posts: 182
Location: HkRkoz al KuwaiT 2019 HaCkEr 101

Post Reply with quote
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
Thu Aug 28, 2008 3:07 pm View user's profile Send private message
Tenebrar



Joined: 13 Jan 2008
Posts: 17

Post Reply with quote
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 View user's profile Send private message
lechat



Joined: 27 Feb 2008
Posts: 12

Post Reply with quote
What you wrote is exactly how it is represented.
Tue Sep 02, 2008 4:34 pm View user's profile Send private message
micha



Joined: 22 Dec 2008
Posts: 2

Post Reply with quote
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"?
Wed Feb 04, 2009 1:22 am View user's profile Send private message Send e-mail
MerickOWA



Joined: 07 Apr 2008
Posts: 182
Location: HkRkoz al KuwaiT 2019 HaCkEr 101

Post Reply with quote
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 View user's profile Send private message
cyberwoozle



Joined: 07 Nov 2008
Posts: 60
Location: Germany

Post Reply with quote
Do we have to expect nested parentheses like (3-(7+6))*5 ?
Fri Apr 17, 2009 9:25 pm View user's profile Send private message
teebee



Joined: 10 Nov 2008
Posts: 89
Location: Germany

Post Reply with quote
I entered as solution
Code:

0<p

and got
Quote:

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 View user's profile Send private message
cyberwoozle



Joined: 07 Nov 2008
Posts: 60
Location: Germany

Post Reply with quote
Hmmm, i could have tried this myself ... Embarassed Thanks anyway!
Sun Apr 19, 2009 7:40 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    hacker.org Forum Index » Challenges All times are GMT
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.