<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: ETHAN LEONG _</title>
    <description>The latest articles on DEV Community by ETHAN LEONG _ (@ethanhaseaten).</description>
    <link>https://dev.to/ethanhaseaten</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2977146%2F51af86e7-6a71-4e52-9114-3b4b1e6fb3fd.png</url>
      <title>DEV Community: ETHAN LEONG _</title>
      <link>https://dev.to/ethanhaseaten</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ethanhaseaten"/>
    <language>en</language>
    <item>
      <title>Recursion</title>
      <dc:creator>ETHAN LEONG _</dc:creator>
      <pubDate>Fri, 28 Mar 2025 07:50:39 +0000</pubDate>
      <link>https://dev.to/ethanhaseaten/recursion-2f0o</link>
      <guid>https://dev.to/ethanhaseaten/recursion-2f0o</guid>
      <description>&lt;h1&gt;
  
  
  check palindrome:
&lt;/h1&gt;

&lt;p&gt;def is_palindrome(s):&lt;br&gt;
    if len(s) &amp;lt;= 1:&lt;br&gt;
        return True&lt;br&gt;
    if s[0] != s[-1]:&lt;br&gt;
        return False&lt;br&gt;
    return is_palindrome(s[1:-1])&lt;/p&gt;

&lt;h1&gt;
  
  
  permutations of string
&lt;/h1&gt;

&lt;p&gt;def permute(s, answer=''):&lt;br&gt;
    if len(s) == 0:&lt;br&gt;
        print(answer)&lt;br&gt;
        return&lt;br&gt;
    for i in range(len(s)):&lt;br&gt;
        ch = s[i]&lt;br&gt;
        left = s[:i]&lt;br&gt;
        right = s[i+1:]&lt;br&gt;
        permute(left + right, answer + ch)&lt;/p&gt;

&lt;h1&gt;
  
  
  subsets
&lt;/h1&gt;

&lt;p&gt;def subsets(s, current=""):&lt;br&gt;
    if len(s) == 0:&lt;br&gt;
        print(current)&lt;br&gt;
        return&lt;br&gt;
    subsets(s[1:], current)        # Exclude&lt;br&gt;
    subsets(s[1:], current + s[0]) # Include&lt;/p&gt;

&lt;h1&gt;
  
  
  tower of hanoi
&lt;/h1&gt;

&lt;p&gt;def hanoi(n, source, target, auxiliary):&lt;br&gt;
    if n == 0:&lt;br&gt;
        return&lt;br&gt;
    hanoi(n - 1, source, auxiliary, target)&lt;br&gt;
    print(f"Move disk {n} from {source} to {target}")&lt;br&gt;
    hanoi(n - 1, auxiliary, target, source)&lt;/p&gt;

&lt;h1&gt;
  
  
  nth stair
&lt;/h1&gt;

&lt;p&gt;def count_ways(n):&lt;br&gt;
    if n &amp;lt;= 1:&lt;br&gt;
        return 1&lt;br&gt;
    return count_ways(n - 1) + count_ways(n - 2)&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Prime Function</title>
      <dc:creator>ETHAN LEONG _</dc:creator>
      <pubDate>Fri, 28 Mar 2025 07:34:25 +0000</pubDate>
      <link>https://dev.to/ethanhaseaten/prime-function-5fih</link>
      <guid>https://dev.to/ethanhaseaten/prime-function-5fih</guid>
      <description>&lt;p&gt;def get_primes(n):&lt;br&gt;
        primes = []&lt;br&gt;
        candidate = 2&lt;br&gt;
        while len(primes) &amp;lt; n:&lt;br&gt;
            for p in primes:&lt;br&gt;
                if candidate % p == 0:&lt;br&gt;
                    break&lt;br&gt;
            else:&lt;br&gt;
                primes.append(candidate)&lt;br&gt;
            candidate += 1&lt;br&gt;
        return primes&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>algorithms</category>
    </item>
    <item>
      <title>Recursion Power Sum</title>
      <dc:creator>ETHAN LEONG _</dc:creator>
      <pubDate>Thu, 27 Mar 2025 15:59:40 +0000</pubDate>
      <link>https://dev.to/ethanhaseaten/recursion-power-sum-56h9</link>
      <guid>https://dev.to/ethanhaseaten/recursion-power-sum-56h9</guid>
      <description>&lt;p&gt;def powerSum(X, N, num=1):&lt;br&gt;
    power = num ** N&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if power &amp;gt; X:
    return 0  # too big, can't continue
elif power == X:
    return 1  # exact match found
else:
    # either include this number or skip it
    return powerSum(X - power, N, num + 1) + powerSum(X, N, num + 1)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>programming</category>
      <category>python</category>
      <category>recursion</category>
      <category>algorithms</category>
    </item>
    <item>
      <title>Sort Dictionary</title>
      <dc:creator>ETHAN LEONG _</dc:creator>
      <pubDate>Thu, 27 Mar 2025 13:34:42 +0000</pubDate>
      <link>https://dev.to/ethanhaseaten/sort-dictionary-211f</link>
      <guid>https://dev.to/ethanhaseaten/sort-dictionary-211f</guid>
      <description>&lt;p&gt;student_scores = {&lt;br&gt;
    'Alex': 88,&lt;br&gt;
    'Ben': 75,&lt;br&gt;
    'Cyrus': 93,&lt;br&gt;
    'Denver': 85&lt;br&gt;
}&lt;br&gt;
sorted_by_values = dict(sorted(student_scores.items(), key=lambda item: item[1]))&lt;br&gt;
print(sorted_by_values)&lt;/p&gt;

&lt;p&gt;{'Ben': 75, 'Denver': 85, 'Alex': 88, 'Cyrus': 93}&lt;/p&gt;

</description>
      <category>python</category>
      <category>sorting</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
