<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[johnsthoughts - Medium]]></title>
        <description><![CDATA[Here is a place for my thoughts and findings related to coding. - Medium]]></description>
        <link>https://medium.com/johnsthoughts?source=rss----d5aca00d2216---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>johnsthoughts - Medium</title>
            <link>https://medium.com/johnsthoughts?source=rss----d5aca00d2216---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 01:20:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/johnsthoughts" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Problem with Problems]]></title>
            <link>https://medium.com/johnsthoughts/the-problem-with-problems-ea443c67a517?source=rss----d5aca00d2216---4</link>
            <guid isPermaLink="false">https://medium.com/p/ea443c67a517</guid>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[p-vs-np]]></category>
            <dc:creator><![CDATA[John Daise]]></dc:creator>
            <pubDate>Thu, 02 Aug 2018 18:24:53 GMT</pubDate>
            <atom:updated>2018-08-02T18:24:52.744Z</atom:updated>
            <content:encoded><![CDATA[<p>In 1971, a computer-scientist by the name of Stephen Cook proposed a profound theoretical problem. This problem was so profound that it was selected as one of the 7 <a href="http://www.claymath.org/millennium-problems">Millennium Prize Problems</a> :</p><p><strong>The P versus NP Problem</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*DDAOdFkMEDwAeUQys32sEg.jpeg" /><figcaption>Stephen Cook : Klaus Tschira Stiftung / Peter Badge (<a href="http://www.heidelberg-laureate-forum.org/blog/laureate/stephen-a-cook/">http://www.heidelberg-laureate-forum.org/blog/laureate/stephen-a-cook/</a>)</figcaption></figure><p><strong>What is the P vs NP problem?</strong></p><p>Essentially this is a problem about solving problems. In his proposal, Cook described classes of problems which centered around the <a href="https://en.wikipedia.org/wiki/Turing_machine">Turing Machine</a> as the standard for computation:</p><p>P( for <em>polynomial time</em>) and NP (for <strong><em>n</em></strong><em>ondeterministic </em><strong><em>p</em></strong><em>olynomial time</em>).</p><p>Cook describes the P class as “…the class of decision problems solvable by some algorithm within a number of steps bounded by some fixed polynomial in the length of the input.” (Stephen Cook)</p><p>In other words these are problems that a deterministic Turing machine can solve within a “reasonable” amount of time. “Reasonable” meaning that the execution time of the algorithm that was used to solve a problem would be measured within polynomial time (See: <a href="https://www.google.com/search?q=time+complexity&amp;oq=time+comple&amp;aqs=chrome.0.0j69i60j69i57j0l3.2181j0j7&amp;sourceid=chrome&amp;ie=UTF-8">Time Complexity</a>). Examples within this realm would include performing simple mathematical operations to slightly more complex problems like the <a href="https://www.geeksforgeeks.org/sum-fibonacci-numbers/">Sum of Fibonacci Numbers Function</a> or finding all the odd factors of a smaller number.</p><p>When discussing the NP class Cook explains that “[the] notation NP stands for “nondeterministic polynomial time”, since originally NP was defined in terms of <a href="https://en.wikipedia.org/wiki/Non-deterministic_Turing_machine">nondeterministic Turing machines</a> (that is, machines that have more than one possible move from a given configuration)….”(He goes on to explain in further and complex detail :<a href="http://www.claymath.org/sites/default/files/pvsnp.pdf"><em>here</em></a>). Problems that are part of the NP class are computational decision problems that are easily checked but would require more complex steps in order to be solved. (Note: This is a simplification of the NP class. I would highly recommend researching further on the topic of <a href="https://en.wikipedia.org/wiki/Non-deterministic_Turing_machine">nondeterministic Turing machines</a> to get a better sense for how this computing process works.)</p><p><a href="https://en.wikipedia.org/wiki/NP-completeness">NP-complete</a> and <a href="https://en.wikipedia.org/wiki/NP-hardness">NP-Hard</a></p><p>NP-complete problems are easily checked but there is not a known way to quickly solve them.</p><p>NP-Hard class is described as “at least as hard as the hardest problems in <a href="https://en.wikipedia.org/wiki/NP_(complexity)">NP</a>”.</p><p>Examples:</p><p>NP-complete Examples</p><ul><li><a href="https://en.wikipedia.org/wiki/Sudoku">Sudoku</a></li><li><a href="https://en.wikipedia.org/wiki/Minesweeper_(video_game)#Computational_complexity">Minesweeper Consistency Problem</a></li><li><a href="https://en.wikipedia.org/wiki/Battleship_(puzzle)">Battleship</a></li></ul><p>NP-hard</p><ul><li><a href="https://en.wikipedia.org/wiki/Travelling_salesman_problem">Traveling salesman</a>*</li><li><a href="https://en.wikipedia.org/wiki/Nurse_scheduling_problem">Nurse Scheduling Problem</a></li><li><a href="https://en.wikipedia.org/wiki/Closest_string">Closest String</a></li></ul><p>(*Note: Some problems, when set under certain parameters can be considered either NP-hard or NP-complete)</p><p>Let’s go back to the original problem: <strong>P = NP?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*8nni9HdodzdSBLJ5jIG8vg.png" /><figcaption><a href="https://en.wikipedia.org/wiki/NP_(complexity)#/media/File:P_np_np-complete_np-hard.svg">https://en.wikipedia.org/wiki/NP_(complexity)#/media/File:P_np_np-complete_np-hard.svg</a></figcaption></figure><p>The picture above diagrams two differing view points. As of now, we generally operate under the general assumption that there is this gradience in the complexity of problems, that <strong>P</strong> ≠ <strong>NP </strong>even though this has not been formally proven . What would it mean if P=NP? In simple terms, this would mean that the problems we perceive as being complex in nature and scope would actually be readily solvable and they could even be as solvable as a P class problem. Some consider this within the realm of possibility because our standards of computing are becoming more advanced. (See: <a href="https://www.google.com/search?q=quantum+computing&amp;oq=quantum+&amp;aqs=chrome.1.69i57j35i39j0l4.2318j0j7&amp;sourceid=chrome&amp;ie=UTF-8">Quantum Computing</a>)</p><p><strong>What are the implications here?</strong></p><p>One immediate example is in the realm of cryptography. Cryptography relies heavily on the notion that certain codes are “unsolvable” however if P =NP were proven to be true, this would shake the foundations of cryptography because this would mean all the methods that we rely on for making things “secure” would actually be insecure and readily solvable.</p><p>There are other implications which go beyond the realm of computing which I encourage you to look into.</p><p><strong>Side Thought:</strong></p><p>As we are learning to become developers, we face many problems that we attempt to solve. Understanding the nature and scope of any given problem is important to figuring out the best approach for how to reach a desired solution. If we have a particular goal in mind and we reach a problem where the nature is too complex and/or the scope is too wide, we may come to the conclusion that a particular problem may not be worth solving.</p><p>After wrestling with trying to understand P vs. NP, I and others can be assured that most of the problems that we will encounter as developers will most likely be able to be solved within a practical amount of time. However if we do encounter and recognize such a complex problem, it might be best to walk away. Although in the process of trying to solve a such a problem may lead you to discover something new.</p><p>Suggested Reading:</p><ul><li><a href="https://en.wikipedia.org/wiki/P_versus_NP_problem">P versus NP problem - Wikipedia</a></li><li><a href="http://www.claymath.org/millennium-problems/p-vs-np-problem">P vs NP Problem</a></li><li><a href="https://www.theglobeandmail.com/news/toronto/the-problem-of-p-versus-np/article1377814/">The problem of P versus NP</a></li><li><a href="https://www.nytimes.com/2009/10/08/science/Wpolynom.html">Solving the P-NP Puzzler</a></li><li><a href="http://techtales.co/2017/08/08/explained-p-vs-np-probme/">What is the P vs. NP problem and why is it so important?</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea443c67a517" width="1" height="1" alt=""><hr><p><a href="https://medium.com/johnsthoughts/the-problem-with-problems-ea443c67a517">The Problem with Problems</a> was originally published in <a href="https://medium.com/johnsthoughts">johnsthoughts</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learning about Memoization]]></title>
            <link>https://medium.com/johnsthoughts/memoization-ff94ae944611?source=rss----d5aca00d2216---4</link>
            <guid isPermaLink="false">https://medium.com/p/ff94ae944611</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[memoization]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[John Daise]]></dc:creator>
            <pubDate>Wed, 18 Jul 2018 18:04:52 GMT</pubDate>
            <atom:updated>2018-07-19T13:08:47.544Z</atom:updated>
            <content:encoded><![CDATA[<p>While going through the pre-work for bootcamp, I came upon an exercise where had to build a method that required a particular function to run only once. Within that method there had to be a check to see whether said function had already been performed. If that function had already been performed, the method would skip running the step of running that particular function again. With my limited knowledge I decided to consult Google for answers. In my search I came across a symbol “||=” (“or-equals”). I immediately used this operator and magically my code worked! But what really is happening here…</p><p><strong>What is “||=”??</strong></p><p>“||=” or “or-equals” is a special operator that allows a programmer to perform a technique called memoization.</p><p><strong>What is Memoization? Why is it useful?</strong></p><p>Memoization is a technique that allows a computer to process more efficiently. There are certain processes that are considered to be “expensive” (processes that would be a lot of work for the computer to perform). Anytime you are dealing with “expensive” code, this may be a situation where memoization could be useful. More specifically one can take any previously computed results to be stored and used again later rather than repeating a particular computation over and over again.</p><p><strong>How does “||=” (“or-equals”) work?</strong></p><p>Example:</p><p>x ||= y</p><p>Let’s look at a basic example above. So imagine that you have a method and you get to a line that looks like what is written above. Going from left to right, the computer is going to evaluate “x”. If “x” already has a value or is defined, then the computer will go about using x for whatever it is to be used for. If you come to a situation where “x” is undefined, nil or false, then “x” will become equal to “y” (or will be assigned to the value “y”). From my understanding the “y” portion of this line does not have to be a single value but it could also be a larger, more “expensive” block of code that a programmer may not necessarily want the computer to run again.</p><p>At this current point in my coding journey, I am simply learning the basics of how to program. From what I know, when anyone is looking to build more efficient code or refactor code, memoization is a technique that one can use. In scenarios where you begin to notice that you are computing a series of smaller functions repeatedly or where the number of computations may grow exponentially, even after recursive methods are employed, memoization may be the solution.</p><p><strong>Side thought</strong>:</p><p>From my understanding there are some mysteries around how “||=” (“or-equals”) can be utilized. Supposedly there are some flaws in using the operator to perform memoization compared to other approaches. I have yet to learn about any of that but if you learn or know anything please let me know.</p><p>Suggested Reading:</p><p><a href="https://en.wikipedia.org/wiki/Memoization">https://en.wikipedia.org/wiki/Memoization</a></p><p><a href="http://www.rubyinside.com/what-rubys-double-pipe-or-equals-really-does-5488.html">http://www.rubyinside.com/what-rubys-double-pipe-or-equals-really-does-5488.html</a></p><p><a href="https://allenan.com/ruby-or-equals-operator-default-booleans/">https://allenan.com/ruby-or-equals-operator-default-booleans/</a></p><p><a href="http://gavinmiller.io/2013/basics-of-ruby-memoization/">http://gavinmiller.io/2013/basics-of-ruby-memoization/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff94ae944611" width="1" height="1" alt=""><hr><p><a href="https://medium.com/johnsthoughts/memoization-ff94ae944611">Learning about Memoization</a> was originally published in <a href="https://medium.com/johnsthoughts">johnsthoughts</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>