Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Roman numeral challenge!
Index -> Contests
Goto page 1, 2, 3, 4  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Martin




PostPosted: Sun Apr 23, 2006 8:26 pm   Post subject: Roman numeral challenge!

Part 1: Your task is to convert an integer in base 10 to its roman numeral equivalent. Write a function integer_to_roman_numeral in the language of your choice that accepts a positive integer and returns a string that is the roman numeral in capital letters. All input will be an integer in the range of 1 to 3999. You do not need to worry about bad input.

Part 2: Write the function roman_numeral_to_integer that, given a string representation of a roman numeral in mixed case letters (ie. XiiI, XIII, xiii and xIiI are all valid representations of the roman numeral for 13) return an integer that is the base 10 integer representation of the roman numeral. All input will be from 1 (I) to 3999 (MMMCMXCIX). All given roman numerals will be valid.

Part 3: Write the function is_roman_numeral that, given a string returns true or false whether the string is a roman numeral from 1 (I) to 3999 (MMMCMXCIX). Roman numerals in capital and lower case letters are valid (ie. 'XiI' is a valid roman numeral for 12)

Examples:
integer_to_roman_numeral(14) => 'XIV'
integer_to_roman_numeral(1000) => 'M'
roman_numeral_to_integer('XxxIiI') => 33
roman_numeral_to_integer('XLII') => 42
is_roman_numeral('hello!') => false
is_roman_numeral('CcXXxiV') => true
is_roman_numeral('XIIII') => false

More information on roman numerals can be found here here. A web based roman numeral to integer calculator can be found here.

You may use the language of your choice, although obviously you may not use any pre-existing roman numeral conversion functions. You may impliment a solution to any or all parts. Prize is 250 bits per correct part, to all contestants whose entries work. The best solution to each (as chosen by me) gets an additional 100 bits. This means that you can potentially win 1050 bits - 250 for each of the three parts, plus 100 bits for each of the three best solution prizes. All entries will be posted after the contest closes. PM all submissions to me, and make sure you tell me what language you are using. The contest closes on May 1st.
Sponsor
Sponsor
Sponsor
sponsor
[Gandalf]




PostPosted: Sun Apr 23, 2006 11:20 pm   Post subject: (No subject)

Alrighty, I'll try it out when I find some extra free time.

Is a "solution" the answer to one "part" of the question, or the whole question? I think the latter, but just making sure. If I am correct, do solutions in two different languages count as two solutions?
Martin




PostPosted: Sun Apr 23, 2006 11:25 pm   Post subject: (No subject)

[Gandalf] wrote:
Alrighty, I'll try it out when I find some extra free time.

Is a "solution" the answer to one "part" of the question, or the whole question? I think the latter, but just making sure. If I am correct, do solutions in two different languages count as two solutions?


A solution is the answer to one part of the question. Therefore, the most number of bits that someone can get would be 250 * 3 + 100 * 3 = 1050, if they got all three parts and all three 'best' solution prizes.
ZeroPaladn




PostPosted: Mon Apr 24, 2006 11:43 am   Post subject: (No subject)

im in! finnaly, something i can do!
Tony




PostPosted: Mon Apr 24, 2006 1:15 pm   Post subject: (No subject)

ZeroPaladn wrote:
finnaly, something i can do!

well you're always welcome to suggest new activities for us to put together.. or take the initiative yourself, we'll help out if available
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Cervantes




PostPosted: Mon Apr 24, 2006 4:22 pm   Post subject: (No subject)

We did this last year in my compsci class. Except it was a one or two day activity, so the code was really rushed... and terrible. I wouldn't mind redo-ing this problem properly. Maybe, maybe.

Good idea, Martin!
MysticVegeta




PostPosted: Mon Apr 24, 2006 5:23 pm   Post subject: (No subject)

oh wtf? This should be limited to non-mods only, otherwise it gets UNFAIR! Mod geniuses will make this unfair, *cough* zylum *cough* *cough* Cervantes *cough*
zylum




PostPosted: Mon Apr 24, 2006 6:11 pm   Post subject: (No subject)

how about since mods cant win bits we try to make the shortest solution (character wise) in any language we choose.. that should be fun Wink
Sponsor
Sponsor
Sponsor
sponsor
MysticVegeta




PostPosted: Mon Apr 24, 2006 6:23 pm   Post subject: (No subject)

but separate division of contest for them? Then it would be ok Smile
Martin




PostPosted: Mon Apr 24, 2006 7:09 pm   Post subject: (No subject)

Nah, anyone can enter. Mods won't win the best code thing (but they can have 250 bits if they want Wink).

We have three entries for part 1 so far after only a day. Great response guys, thank you very much. Smile
Drakain Zeil




PostPosted: Mon Apr 24, 2006 7:37 pm   Post subject: (No subject)

Hmm, wasn't this a past ECOO question?
zylum




PostPosted: Mon Apr 24, 2006 9:00 pm   Post subject: (No subject)

hmm, why dont people post their code? well since we are being so secretive, ill pm my solution too..

just to make things interesting, i will note that my solution to integer_to_roman_numeral is 9 lines in java and 12 in turing Wink
MysticVegeta




PostPosted: Tue Apr 25, 2006 5:41 pm   Post subject: (No subject)

I made one in 9 lines in java too
zylum




PostPosted: Tue Apr 25, 2006 8:42 pm   Post subject: (No subject)

MysticVegeta wrote:
I made one in 9 lines in java too


make that 6 in java and 10 in turing Laughing
MysticVegeta




PostPosted: Wed Apr 26, 2006 1:37 pm   Post subject: (No subject)

I hate you
Display posts from previous:   
   Index -> Contests
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 4  [ 50 Posts ]
Goto page 1, 2, 3, 4  Next
Jump to:   


Style:  
Search: