<?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: Muhammad Faran Aiki</title>
    <description>The latest articles on DEV Community by Muhammad Faran Aiki (@faranaiki).</description>
    <link>https://dev.to/faranaiki</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%2F648230%2F725405e9-79ac-4d2a-9ff4-272d1e977e50.jpg</url>
      <title>DEV Community: Muhammad Faran Aiki</title>
      <link>https://dev.to/faranaiki</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/faranaiki"/>
    <language>en</language>
    <item>
      <title>How to use "any" and "all" in Python</title>
      <dc:creator>Muhammad Faran Aiki</dc:creator>
      <pubDate>Wed, 16 Jun 2021 15:22:59 +0000</pubDate>
      <link>https://dev.to/faranaiki/how-to-use-any-and-all-in-python-2dim</link>
      <guid>https://dev.to/faranaiki/how-to-use-any-and-all-in-python-2dim</guid>
      <description>&lt;p&gt;Credential: I do not know, but I, at least, am 4 years experienced; I am still learning C and Assembly.&lt;/p&gt;

&lt;p&gt;What is &lt;code&gt;any&lt;/code&gt; and &lt;code&gt;all&lt;/code&gt; in Python?&lt;/p&gt;

&lt;p&gt;By Python definition, &lt;code&gt;any&lt;/code&gt; will return if there is an item whereby true in a list, whereas &lt;code&gt;all&lt;/code&gt; will return if all items are true in a list.&lt;/p&gt;

&lt;p&gt;It looks like the operator &lt;code&gt;or&lt;/code&gt; and &lt;code&gt;and&lt;/code&gt; for &lt;code&gt;any&lt;/code&gt; and &lt;code&gt;all&lt;/code&gt;. It is actually easy to implement in C, Assembly, or any other language.&lt;/p&gt;

&lt;p&gt;Here are examples of the function &lt;code&gt;any&lt;/code&gt;,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;any([true, false, false])   # Result in True
any([false, false, false])  # Result in False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here are examples of the function &lt;code&gt;all&lt;/code&gt;,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;all([true, true, true])     # Result in True
all([true, true, false])    # Result in False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Implementation in C for &lt;code&gt;any&lt;/code&gt;,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// My algorithm for "any"
int any(int* arr, int size) {
    int i = 0, t = 0;
    for (; i &amp;lt; size - 1 ; i += 2) {
        t += arr[i] + arr[i + 1];
    }
    return (t + arr[size % i]) &amp;amp;&amp;amp; 1;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With a &lt;code&gt;O(log n)&lt;/code&gt; time complexity and &lt;code&gt;O(1)&lt;/code&gt; space complexity.&lt;/p&gt;

&lt;p&gt;Implementation in C for &lt;code&gt;all&lt;/code&gt;,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// My algorithm for "all"
int all(int* arr, int size) {
    int i = 0, t = 0;
    for (; i &amp;lt; size - 1 ; i += 2) {
        t += arr[i] + arr[i + 1];
    }
    return (t + (i % size &amp;amp;&amp;amp; arr[size % i]) &amp;gt; (i &amp;gt;&amp;gt; 1));
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With a &lt;code&gt;O(log n)&lt;/code&gt; time complexity and &lt;code&gt;O(1)&lt;/code&gt; space complexity.&lt;/p&gt;

&lt;p&gt;I will explain how the algorithm works in another post.&lt;/p&gt;

&lt;p&gt;How to use &lt;code&gt;any&lt;/code&gt;,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Real world application
if any(person.alive for person in people):
    myself.shout("Who is dead?")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How to use &lt;code&gt;all&lt;/code&gt;,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Real world application
if all(person.alive for person in people):
    myself.shout("We are safe!")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>python</category>
      <category>c</category>
      <category>algorithms</category>
      <category>list</category>
    </item>
    <item>
      <title>Why I prefer this style</title>
      <dc:creator>Muhammad Faran Aiki</dc:creator>
      <pubDate>Sat, 12 Jun 2021 15:18:54 +0000</pubDate>
      <link>https://dev.to/faranaiki/why-i-prefer-this-style-3a0h</link>
      <guid>https://dev.to/faranaiki/why-i-prefer-this-style-3a0h</guid>
      <description>&lt;p&gt;I prefer,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;

int main() {
  printf("I prefer this");
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;More than this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;

int main()
{
  printf("I do not prefer this");
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because the &lt;strong&gt;line&lt;/strong&gt; is less than the previous. Note, that &lt;strong&gt;I did not mention the size is lesser&lt;/strong&gt; than the previous, they both are the same size.&lt;br&gt;
But of course, it is up to the developer, coder, or the programmer to decide which style they use. I was just sharing my opinion.&lt;/p&gt;

</description>
      <category>c</category>
      <category>cpp</category>
      <category>bracket</category>
    </item>
    <item>
      <title>Hard to find Assembly topic</title>
      <dc:creator>Muhammad Faran Aiki</dc:creator>
      <pubDate>Sat, 12 Jun 2021 12:23:52 +0000</pubDate>
      <link>https://dev.to/faranaiki/hard-to-find-assembly-topic-1c7g</link>
      <guid>https://dev.to/faranaiki/hard-to-find-assembly-topic-1c7g</guid>
      <description>&lt;p&gt;Man, it is really hard to find documentation on how to make an Operating System.&lt;br&gt;
No, what I meant by that is understanding, not just copy-paste (well, except GDT and its similar).&lt;br&gt;
Maybe I am too stupid to understand an easy thing, or too lazy to read the full topic.&lt;/p&gt;

</description>
      <category>assembly</category>
      <category>os</category>
    </item>
    <item>
      <title>Is Python (and similar) really a programming language?</title>
      <dc:creator>Muhammad Faran Aiki</dc:creator>
      <pubDate>Sat, 12 Jun 2021 12:20:42 +0000</pubDate>
      <link>https://dev.to/faranaiki/is-python-and-similar-really-a-programming-language-4gi9</link>
      <guid>https://dev.to/faranaiki/is-python-and-similar-really-a-programming-language-4gi9</guid>
      <description>&lt;p&gt;For some reason, maybe because of my ego, I sometimes do not think that Python (and its similar) is a programming language.&lt;br&gt;
Maybe because Python (and its similar) is a high-level programming language and near pseudo-code? I do not know.&lt;br&gt;
It is not really that bad, but I do not consider it as an "achievement" if I master it or know anything about it.&lt;br&gt;
Not only that, Python is far away from the Zen of Python (the latest version).&lt;/p&gt;

</description>
      <category>python</category>
      <category>c</category>
      <category>assembly</category>
    </item>
  </channel>
</rss>
