<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://aznot.com/index.php?action=history&amp;feed=atom&amp;title=Python%2FProblems</id>
	<title>Python/Problems - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://aznot.com/index.php?action=history&amp;feed=atom&amp;title=Python%2FProblems"/>
	<link rel="alternate" type="text/html" href="https://aznot.com/index.php?title=Python/Problems&amp;action=history"/>
	<updated>2026-05-03T07:16:40Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://aznot.com/index.php?title=Python/Problems&amp;diff=8699&amp;oldid=prev</id>
		<title>Kenneth: Created page with &quot;== Roman Numeral to Integer ==  My favorite solution I found online: &lt;ref&gt;https://leetcode.com/problems/roman-to-integer/solutions/264743/clean-python-beats-99-78/&lt;/ref&gt; &lt;pre&gt; class Solution:     def romanToInt(self, s: str) -&gt; int:         translations = {             &quot;I&quot;: 1,             &quot;V&quot;: 5,             &quot;X&quot;: 10,             &quot;L&quot;: 50,             &quot;C&quot;: 100,             &quot;D&quot;: 500,             &quot;M&quot;: 1000         }         number = 0         s = s.replace(&quot;IV&quot;, &quot;IIII&quot;).repl...&quot;</title>
		<link rel="alternate" type="text/html" href="https://aznot.com/index.php?title=Python/Problems&amp;diff=8699&amp;oldid=prev"/>
		<updated>2025-05-13T21:32:55Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;== Roman Numeral to Integer ==  My favorite solution I found online: &amp;lt;ref&amp;gt;https://leetcode.com/problems/roman-to-integer/solutions/264743/clean-python-beats-99-78/&amp;lt;/ref&amp;gt; &amp;lt;pre&amp;gt; class Solution:     def romanToInt(self, s: str) -&amp;gt; int:         translations = {             &amp;quot;I&amp;quot;: 1,             &amp;quot;V&amp;quot;: 5,             &amp;quot;X&amp;quot;: 10,             &amp;quot;L&amp;quot;: 50,             &amp;quot;C&amp;quot;: 100,             &amp;quot;D&amp;quot;: 500,             &amp;quot;M&amp;quot;: 1000         }         number = 0         s = s.replace(&amp;quot;IV&amp;quot;, &amp;quot;IIII&amp;quot;).repl...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Roman Numeral to Integer ==&lt;br /&gt;
&lt;br /&gt;
My favorite solution I found online: &amp;lt;ref&amp;gt;https://leetcode.com/problems/roman-to-integer/solutions/264743/clean-python-beats-99-78/&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Solution:&lt;br /&gt;
    def romanToInt(self, s: str) -&amp;gt; int:&lt;br /&gt;
        translations = {&lt;br /&gt;
            &amp;quot;I&amp;quot;: 1,&lt;br /&gt;
            &amp;quot;V&amp;quot;: 5,&lt;br /&gt;
            &amp;quot;X&amp;quot;: 10,&lt;br /&gt;
            &amp;quot;L&amp;quot;: 50,&lt;br /&gt;
            &amp;quot;C&amp;quot;: 100,&lt;br /&gt;
            &amp;quot;D&amp;quot;: 500,&lt;br /&gt;
            &amp;quot;M&amp;quot;: 1000&lt;br /&gt;
        }&lt;br /&gt;
        number = 0&lt;br /&gt;
        s = s.replace(&amp;quot;IV&amp;quot;, &amp;quot;IIII&amp;quot;).replace(&amp;quot;IX&amp;quot;, &amp;quot;VIIII&amp;quot;)&lt;br /&gt;
        s = s.replace(&amp;quot;XL&amp;quot;, &amp;quot;XXXX&amp;quot;).replace(&amp;quot;XC&amp;quot;, &amp;quot;LXXXX&amp;quot;)&lt;br /&gt;
        s = s.replace(&amp;quot;CD&amp;quot;, &amp;quot;CCCC&amp;quot;).replace(&amp;quot;CM&amp;quot;, &amp;quot;DCCCC&amp;quot;)&lt;br /&gt;
        for char in s:&lt;br /&gt;
            number += translations[char]&lt;br /&gt;
        return number&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
My Solution: &amp;lt;ref&amp;gt;https://leetcode.com/problems/roman-to-integer/solutions/6742002/roman-to-int-13/&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Solution:&lt;br /&gt;
    def romanToInt(self, s: str) -&amp;gt; int:&lt;br /&gt;
        i = 0&lt;br /&gt;
        t = 0&lt;br /&gt;
        slen = len(s)&lt;br /&gt;
        roman = {&amp;quot;I&amp;quot;: 1, &amp;quot;V&amp;quot;: 5, &amp;quot;X&amp;quot;: 10, &amp;quot;L&amp;quot;: 50, &amp;quot;C&amp;quot;: 100, &amp;quot;D&amp;quot;: 500, &amp;quot;M&amp;quot;: 1000}&lt;br /&gt;
        rdic = {&amp;quot;IV&amp;quot;: 4, &amp;quot;IX&amp;quot;: 9, &amp;quot;XL&amp;quot;: 40, &amp;quot;XC&amp;quot;: 90, &amp;quot;CD&amp;quot;: 400, &amp;quot;CM&amp;quot;: 900}&lt;br /&gt;
        while i &amp;lt; slen:&lt;br /&gt;
            c = s[i]&lt;br /&gt;
            if i + 1 &amp;lt; slen and c in (&amp;quot;I&amp;quot;, &amp;quot;X&amp;quot;, &amp;quot;C&amp;quot;):&lt;br /&gt;
                cc = c + s[i+1]&lt;br /&gt;
                if cc in rdic:&lt;br /&gt;
                    t += rdic[cc]&lt;br /&gt;
                    i += 2&lt;br /&gt;
                    continue&lt;br /&gt;
            t += roman[c]&lt;br /&gt;
            i += 1&lt;br /&gt;
        print(t)&lt;br /&gt;
        return t&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kenneth</name></author>
	</entry>
</feed>