Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Comments on Single digit Roman numeral

Post

Single digit Roman numeral

+2
−0

Given a single character, which is a valid Roman numeral, output its value.

Values

There are 7 valid single character Roman numerals, with the following values:

Character Value
I 1
V 5
X 10
L 50
C 100
D 500
M 1000

Input

  • A single character, which will always be one of IVXLCDM.

Output

  • The corresponding value.
  • The output value must not be a Roman numeral.

Test cases

As there are only 7 valid inputs, the list of test cases is exhaustive.

Test cases are in the format "input" : output.

"I" : 1
"V" : 5
"X" : 10
"L" : 50
"C" : 100
"D" : 500
"M" : 1000

Scoring

This is a code golf challenge. Your score is the number of bytes in your code.

Explanations are optional, but I'm more likely to upvote answers that have one.

History
Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

2 comment threads

Allowed output formats? (4 comments)
Similar challenge (1 comment)
Allowed output formats?
H_H‭ wrote 6 months ago

Do you have any restrictions on the output format?

trichoplax‭ wrote 6 months ago · edited 6 months ago

I'm happy to stick with the defaults for I/O unless there's some loophole I need to close.

One of the answers there mentions using a character code instead of a number, which would allow outputting 1000 as "Ϩ" (unicode codepoint U+03E8) but I'm not sure that's going to help anyone...

Did you have a particular output format in mind? I can add an explicit decision to the challenge if it's not covered by the defaults.

H_H‭ wrote 6 months ago · edited 6 months ago

Is ,. as a solution allowed, then? (i would consider this a loophole for this particular challenge).

Even when you explicit forbid this form of output, it could still be made possible by using a special form of character encoding for the input. A encoding where I has the number 1, V the number 5, ...

trichoplax‭ wrote 6 months ago

Good point. I will edit to make explicit that output in Roman numerals is not acceptable.

As for choosing a text encoding where the output always equals the input, I would likely vote to agree that should be a forbidden loophole if you added it to Code Golf - Default Rules: Loopholes