-
Notifications
You must be signed in to change notification settings - Fork 12.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create Roman number to decimal #2018
base: master
Are you sure you want to change the base?
Conversation
|
@@ -0,0 +1,40 @@ | |||
|
|||
def value(r): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use switch statement, they are far better instead of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea
while (i < len(str)): | ||
s1 = value(str[i]) | ||
if (i + 1 < len(str)): | ||
s2 = value(str[i + 1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leetcode problem idea...I see.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code is so fucking awful... Lemme pullup with a better one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made this but more efficient here. https://github.com/dexterharrison29/code-review/blob/main/roman-numerals.py
The value function is used to map Roman numerals to their decimal values, and the romanToDecimal function converts a Roman numeral to an integer using the given mapping.