Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-220
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2022-220
2022-220
Commits
612d403d
Commit
612d403d
authored
Nov 13, 2022
by
Pathirana K.P.G.I
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
9a00f540
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
+14
-0
rome_to_number.py
rome_to_number.py
+14
-0
No files found.
rome_to_number.py
0 → 100644
View file @
612d403d
def
roman_to_int
(
s
):
rom_val
=
{
'I'
:
1
,
'V'
:
5
,
'X'
:
10
,
'L'
:
50
,
'C'
:
100
,
'D'
:
500
,
'M'
:
1000
}
int_val
=
0
for
i
in
range
(
len
(
s
)):
if
i
>
0
and
rom_val
[
s
[
i
]]
>
rom_val
[
s
[
i
-
1
]]:
int_val
+=
rom_val
[
s
[
i
]]
-
2
*
rom_val
[
s
[
i
-
1
]]
else
:
int_val
+=
rom_val
[
s
[
i
]]
return
int_val
print
(
roman_to_int
(
'XV'
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment