<?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: Annette Michaels</title>
    <description>The latest articles on DEV Community by Annette Michaels (@rygelxvi).</description>
    <link>https://dev.to/rygelxvi</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%2F179168%2Faaaf2768-c0c4-42df-a252-08bc0fe11b3d.png</url>
      <title>DEV Community: Annette Michaels</title>
      <link>https://dev.to/rygelxvi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rygelxvi"/>
    <language>en</language>
    <item>
      <title>Lockdown Breathes Life into Old Projects</title>
      <dc:creator>Annette Michaels</dc:creator>
      <pubDate>Sun, 29 Mar 2020 18:52:21 +0000</pubDate>
      <link>https://dev.to/rygelxvi/lockdown-breathes-life-into-old-projects-16g0</link>
      <guid>https://dev.to/rygelxvi/lockdown-breathes-life-into-old-projects-16g0</guid>
      <description>&lt;p&gt;I started my first job (yeay!) a few months ago and in the process one of my personal projects fell to the wayside. I work remotely so the stay at home order has not actually changed my life or daily pattern much. However, it has changed for many of the educators out there.&lt;/p&gt;

&lt;p&gt;The main project I was working on had to do with increasing exposure for kids who are deaf and hard-of-hearing to English literacy. I have been working with a teacher of the deaf (and possibly more in the future) to release a website that has her reading and signing books so her students can follow along. With the lockdown in place many of her students do not have the same access to language so the past two weekends I have been working to get the site ready for deployment.&lt;/p&gt;

&lt;p&gt;You could say why not just keep the videos on Youtube and let them search through her channel? &lt;/p&gt;

&lt;p&gt;We thought this would make it easier for the kids to navigate and it allows for filtering. We can also control the content they are exposed to and there are no ads.&lt;/p&gt;

&lt;p&gt;It was built with the intention of increasing accessibility so it has large easy to find buttons to help those with multiple disabilities and also it also has goes straight to fullscreen and autoplays (on most devices) when a video is clicked. This prevents accidentally playing all the videos at once. It also has a responsive design since many students do not have access to computers at home.&lt;/p&gt;

&lt;p&gt;I have a lot to learn still and there are a lot of features we want to  add including multiple sign languages to increase accessibility. It is a work in progress but I am proud of it, and am excited to get better at my craft.&lt;/p&gt;

&lt;p&gt;This is my first app that is fully loaded on heroku. There were a few problems involving Youtube API call limitations that I believe I have found a solution to (so this is a test to see if I really fixed it =D).&lt;/p&gt;

&lt;p&gt;It is currently available at &lt;a href="//seesignstories.herokuapp.com"&gt;seesignstories.herokuapp.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>productivity</category>
      <category>codenewbie</category>
      <category>programming</category>
    </item>
    <item>
      <title>3Sum Algorithm</title>
      <dc:creator>Annette Michaels</dc:creator>
      <pubDate>Wed, 25 Sep 2019 04:02:30 +0000</pubDate>
      <link>https://dev.to/rygelxvi/3sum-algorithm-499j</link>
      <guid>https://dev.to/rygelxvi/3sum-algorithm-499j</guid>
      <description>&lt;h2&gt;
  
  
  3Sum Problem - No Duplicates
&lt;/h2&gt;

&lt;p&gt;Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.&lt;/p&gt;

&lt;p&gt;No duplicates.&lt;/p&gt;

&lt;p&gt;The trickiest part of this problem is duplicates (language depending). At first glance it makes sense to iterate in three loops for the brute force method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (i = 0; i &amp;lt; nums.length - 2; i++) {
   for (j = i + 1; j &amp;lt; nums.length - 1; j++) {
      for (k = j + 1; k &amp;lt; nums.length; k++) {
       ///additional code here
      }
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This results in O(n^3) time complexity and removing the duplicates is difficult because the goal is to return an array of arrays.&lt;/p&gt;

&lt;p&gt;The way I recommend doing this problem is by using two pointers reducing the complexity to O(n^2).&lt;/p&gt;

&lt;p&gt;In layman's terms we are going to have one number that we are going to go put through all the pertinent combinations by moving two pointers around to see if they match the target.&lt;/p&gt;

&lt;p&gt;To do this the first thing we need to do is sort the array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nums = nums.sort()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This should work right?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let nums = [0,5,2,-5,-2]
nums.sort()
Array(5) [ -2, -5, 0, 2, 5 ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nope the default sort in javascript does it alphabetically.&lt;/p&gt;

&lt;p&gt;So instead we have to change the sort method. If you want to read up I recommend the documentation &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let nums = [0,5,2,-5,-2]
nums.sort(function(a,b) {return a-b})
Array(5) [ -5, -2, 0, 2, 5 ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Success!&lt;/p&gt;

&lt;p&gt;Now we can get down to finding our unique triplets &lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimage.shutterstock.com%2Fimage-photo%2Ftriplets-cavalier-king-charles-260nw-757983475.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimage.shutterstock.com%2Fimage-photo%2Ftriplets-cavalier-king-charles-260nw-757983475.jpg" alt="triplets"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So after sorting we need to create a for loop. This loop is going to represent a number that we are comparing everything to. &lt;/p&gt;

&lt;p&gt;i = number we aren't changing&lt;br&gt;
j = low pointer start spot&lt;br&gt;
k = high pointer start spot&lt;/p&gt;

&lt;p&gt;[ &lt;strong&gt;&lt;em&gt;i:-5&lt;/em&gt;&lt;/strong&gt;, &lt;strong&gt;j:-2&lt;/strong&gt;, 0, 2, &lt;strong&gt;k:5&lt;/strong&gt; ]&lt;/p&gt;

&lt;p&gt;and the next iteration of the loop (i = 1)&lt;/p&gt;

&lt;p&gt;[ -5, &lt;strong&gt;&lt;em&gt;i:-2&lt;/em&gt;&lt;/strong&gt;, &lt;strong&gt;j:0&lt;/strong&gt;, 2, &lt;strong&gt;k:5&lt;/strong&gt; ]&lt;/p&gt;

&lt;p&gt;and then&lt;/p&gt;

&lt;p&gt;[ -5, -2, &lt;strong&gt;&lt;em&gt;i:0&lt;/em&gt;&lt;/strong&gt;, &lt;strong&gt;j:2&lt;/strong&gt;, &lt;strong&gt;k:5&lt;/strong&gt; ]&lt;/p&gt;

&lt;p&gt;so the low pointer j will always start at i + 1 and the high pointer k will always start at nums.length - 1.&lt;/p&gt;

&lt;p&gt;So far we have&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var threeSum = function(nums) {

    let result = []

    nums = nums.sort(function(a,b) {return a-b})

    for (let i = 0; i &amp;lt; nums.length - 2; i++) {

        let j = i + 1
        let k = nums.length - 1


    }      

    return result
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since j should always be lower than k we can put most of the rest of the code into a while loop that specifies this.&lt;/p&gt;

&lt;p&gt;and then just go through the rest of the logic.&lt;/p&gt;

&lt;p&gt;If the sum of the three numbers is equal to the target (0 in the leetcode problem) then push it onto the array, otherwise increment or decrement the appropriate pointer to bring us closer to the target number.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var threeSum = function(nums) {

    let result = []

    nums = nums.sort(function(a,b) {return a-b})

    for (let i = 0; i &amp;lt; nums.length - 2; i++) {

        let j = i + 1
        let k = nums.length - 1
        while (j &amp;lt; k) { 
            let sum = nums[i] + nums[j] + nums[k]

            if(sum === 0) {
                result.push([nums[i], nums[j], nums[k]])
                j++
                k--
            } else if (sum &amp;lt; 0) {
                j++
            } else {
                k--
            }

        }


    }      

    return result
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This mostly works except it allows for some duplicates and of course we are currently ignoring our base cases.&lt;/p&gt;

&lt;p&gt;To ensure no duplicates once we find triplet we need to move the pointers to the next unique number else we could end up with the same triplet. &lt;/p&gt;

&lt;p&gt;for example [0,0,0,1,1,1,2,2,2] will result in lots of duplicated triplets.&lt;/p&gt;

&lt;p&gt;So we add the following after we add to the result array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;while (nums[k] === nums[k - 1]) k--
while (nums[j] === nums[j + 1]) j++
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This concept also applies to 'i' so but we use continue to let it go to the next loop are properly handle the variables.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (i &amp;gt; 0 &amp;amp;&amp;amp; nums[i] === nums[i - 1]) continue
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the base cases. There are lots of ways to write these. I thought reduce would be fun to practice.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    if (nums.length &amp;lt; 3) {return [] }
    if (nums.length === 3) {
      let sum = nums.reduce(function(acc, cv) {
            return acc + cv
        }, 0)
      return sum === 0 ? [nums] : []
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is the full code in JS&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var threeSum = function(nums) {

    let result = []

    if (nums.length &amp;lt; 3) {return [] }
    if (nums.length === 3) {
      let sum = nums.reduce(function(acc, cv) {
            return acc + cv
        }, 0)
      return sum === 0 ? [nums] : []
    }

    nums = nums.sort(function(a,b) {return a-b})

    for (let i = 0; i &amp;lt; nums.length - 2; i++) {

        let j = i + 1
        let k = nums.length - 1
        if (i &amp;gt; 0 &amp;amp;&amp;amp; nums[i] === nums[i - 1]) continue

        while (i &amp;lt; j) { 
            let sum = nums[i] + nums[j] + nums[k]

            if(sum === 0) {
                result.push([nums[i], nums[j], nums[k]])
                while (nums[k] === nums[k - 1]) k--
                while (nums[j] === nums[j + 1]) j++
                k--
                j++
            } else if (sum &amp;lt; 0) {
                j++
            } else {
                k--
            }


        }

    }      

    return result
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and here it is in Ruby. In Ruby the duplicates are much easier to handle because .uniq will remove them so we don't &lt;em&gt;have&lt;/em&gt; to have the while loops.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def three_sum(nums)
  result = []

  return result if (nums.length &amp;lt; 3)

  return [nums] if (nums.length === 3 &amp;amp;&amp;amp; nums.sum === 0)
  nums.sort!
  for i in 0..nums.length - 3
    j = i + 1
    k = nums.length - 1

    while j &amp;lt; k
      sum = nums[i] + nums[j] + nums[k]
      if sum &amp;lt; 0
        j += 1
      elsif sum &amp;gt; 0
        k -=1
      else
        result.push([nums[i],nums[j],nums[k]])
        j += 1
        k -= 1
      end

    end
  end

  return result.uniq
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>algorithms</category>
      <category>ruby</category>
    </item>
    <item>
      <title>Learning Node/Express on the fly</title>
      <dc:creator>Annette Michaels</dc:creator>
      <pubDate>Sun, 08 Sep 2019 02:47:49 +0000</pubDate>
      <link>https://dev.to/rygelxvi/learning-node-express-on-the-fly-1jm1</link>
      <guid>https://dev.to/rygelxvi/learning-node-express-on-the-fly-1jm1</guid>
      <description>&lt;p&gt;I have managed to max out my Youtube API query limit (10,000 units) on my own developing my website. There are a few workarounds to this conundrum and I decided that instead of setting up multiple API keys and swapping them out that I should bite the bullet and build the back-end. Luckily, it will not be used regularly until next week so I have a little bit of time (and a back-up solution).&lt;/p&gt;

&lt;p&gt;Initially, I wanted to build the back-end in a new language instead of what I already know (Rails), probably Java/Spring Boot or Python/Django. However, since I need it up and running quickly I thought it would make sense to take a language I already know, Javascript, and learn some new skills, NodeJS and Express. I know I'm using PostgreSQL and wanted something close to what I already know for a smooth transition. I went with Sequelize due to it's similarities to Active Record.&lt;/p&gt;

&lt;p&gt;robinwieruch.de has been my best resource by far.&lt;/p&gt;

&lt;p&gt;There are free tutorials in the blog section including setting up NodeJS with Babel, Express, Sequelize, and making the REST API with it.&lt;/p&gt;

&lt;p&gt;It has an abundance of information, I recommend checking it out! &lt;/p&gt;

</description>
      <category>codenewbie</category>
      <category>todayilearned</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Oops don't forget to test</title>
      <dc:creator>Annette Michaels</dc:creator>
      <pubDate>Wed, 04 Sep 2019 15:52:39 +0000</pubDate>
      <link>https://dev.to/rygelxvi/oops-don-t-forget-to-test-57p5</link>
      <guid>https://dev.to/rygelxvi/oops-don-t-forget-to-test-57p5</guid>
      <description>&lt;p&gt;So managed to make a newbie mistake. I forgot to recheck my layout after editing css in &lt;em&gt;all&lt;/em&gt; the screen sizes. Ended up with a desktop layout that I pushed to my deployed branch that looked like&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4kCIFW_T--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/6b85954iqqb7oda8nuq9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4kCIFW_T--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/6b85954iqqb7oda8nuq9.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;instead of &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--k6wo4Ohd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/8i0glmawwl7y2nhycd16.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--k6wo4Ohd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/8i0glmawwl7y2nhycd16.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;oops. Easy fix at least and a friendly reminder to check everything before deploying =)&lt;/p&gt;

</description>
      <category>codenewbie</category>
      <category>css</category>
      <category>beginners</category>
      <category>testing</category>
    </item>
    <item>
      <title>Practice what you don't like</title>
      <dc:creator>Annette Michaels</dc:creator>
      <pubDate>Sat, 31 Aug 2019 01:43:55 +0000</pubDate>
      <link>https://dev.to/rygelxvi/practice-what-you-don-t-like-3385</link>
      <guid>https://dev.to/rygelxvi/practice-what-you-don-t-like-3385</guid>
      <description>&lt;p&gt;Have you ever really not wanted to do a thing? Like really not wanted to to the point where it gave you the heebie-jeebies?&lt;/p&gt;

&lt;p&gt;For programming it was CSS.&lt;/p&gt;

&lt;p&gt;I am a scientist so having to use something that feels so imprecise feels innately wrong. One small change shouldn't make your website into a Picasso painting right?&lt;/p&gt;

&lt;p&gt;Well I have been working on my website SeeSignStories and I know that this has to be an easy to navigate site that is responsive to a wide range of operating systems and screen sizes. The children using it will be in early elementary school and grabbing their parents phones or tablets, definitely not using a desktop computer. So I have been working an awful lot with CSS and learning about different viewports and doing tons of media queries.&lt;/p&gt;

&lt;p&gt;I can solidly say that CSS and I have become better friends. Since I am looking for my first job front-end positions seem less daunting since I know I can do it.&lt;/p&gt;

&lt;p&gt;In summary, if you don't like something or it is hard, you probably just need to practice it more.&lt;/p&gt;

&lt;p&gt;On a side note if anyone has any tips about naming classes for CSS or organizing the giant CSS file with media queries let me know! Or eTags since my next mission is to not use up my Youtube API quota so quickly...&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>career</category>
      <category>css</category>
      <category>todayilearned</category>
    </item>
    <item>
      <title>Project: See Sign Stories</title>
      <dc:creator>Annette Michaels</dc:creator>
      <pubDate>Mon, 26 Aug 2019 02:38:48 +0000</pubDate>
      <link>https://dev.to/rygelxvi/project-see-sign-stories-4n92</link>
      <guid>https://dev.to/rygelxvi/project-see-sign-stories-4n92</guid>
      <description>&lt;p&gt;I recently started a project working with a Teacher of the Deaf to develop English literacy skills in children who are deaf and hard of hearing. I have been using the YouTube API to fetch the videos and publish them on a page that is kid-friendly and highly accessible to those with developmental disabilities.&lt;/p&gt;

&lt;p&gt;The adventure has just started and I have already learned so much from learning how to communicate with non-technical clients to how YouTube thumbnail resolution is more dynamic? than expected.&lt;/p&gt;

&lt;p&gt;I will definitely be posting more about this project in the future as it matures. Check it out at&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/Rygel-XVI/SeeSignStories"&gt;https://github.com/Rygel-XVI/SeeSignStories&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>codenewbie</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Container with the Most Water - Code Challenge</title>
      <dc:creator>Annette Michaels</dc:creator>
      <pubDate>Sat, 06 Jul 2019 21:33:30 +0000</pubDate>
      <link>https://dev.to/rygelxvi/container-with-the-most-water-code-challenge-34ff</link>
      <guid>https://dev.to/rygelxvi/container-with-the-most-water-code-challenge-34ff</guid>
      <description>&lt;p&gt;&lt;a href="https://leetcode.com/problems/container-with-most-water/"&gt;Leetcode Problem 11&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This problem is pretty straight forward.&lt;/p&gt;

&lt;p&gt;Given an array of heights, find the two indices that could contain the most water between them.&lt;/p&gt;

&lt;p&gt;Generally there are two ways of solving this, the brute force method, and the two pointer method.&lt;/p&gt;

&lt;h3&gt;
  
  
  Brute Force
&lt;/h3&gt;

&lt;p&gt;This method will calculate every possible combination possible to determine the answer. This requires a nested loop resulting in a complexity of O(n^2).&lt;/p&gt;

&lt;p&gt;Javascript&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var maxArea = function(height) {
    let mostWater = 0

    for (let l = 0; l &amp;lt; height.length - 1; l++) {
        for (let r = height.length - 1; r &amp;gt; l; r--) {
            mostWater = Math.max(mostWater, (Math.min(height[l], height[r])*(r-l)))
        }        
    }
    return mostWater
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A better way of doing this is to utilize two pointers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Two Pointer Method
&lt;/h3&gt;

&lt;p&gt;For this method we utilize two pointers that are placed on opposite ends of the array to iterate through once resulting in a time complexity of O(n). The area between the current left (l) and right (r) indexes and if the area is larger than the current max, it is set as max.&lt;/p&gt;

&lt;p&gt;The indices are moved based on which one is smaller or if equal the left one in this situation. It is arbitrary which is checked in the if statement.&lt;/p&gt;

&lt;p&gt;Javascript&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var maxArea = function(height) {
    let max = 0

    let l = 0
    let r = height.length - 1

    while (l &amp;lt; r) {
        if (height[l] &amp;gt; height[r]) {
            max = Math.max(height[r] * (r-l), max)
            r--
        } else {
            max = Math.max(height[l] * (r-l), max)
            l++ 
        }       
    }

    return max
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In Ruby...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def max_area(height)
    max_area = 0

    l_idx = 0
    r_idx = height.length - 1

    while (r_idx &amp;gt; l_idx)  
        if height[r_idx] &amp;gt;= height[l_idx]
            max_area = [(height[l_idx] * (r_idx - l_idx)), max_area].max
            l_idx += 1
        else 
            max_area = [(height[r_idx] * (r_idx - l_idx)), max_area].max
            r_idx -= 1
        end        
    end

    return max_area
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For more readability you can always separate out the max_area (ruby) or max (javascript) into multiple lines.  &lt;/p&gt;

&lt;p&gt;Javascript&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (height[l] &amp;gt; height[r]) {
    maybeMax = height[r] * (r-l)
    r--
} else {
    maybeMax = height[l] * (r-l)
    l++ 
}        

max = Math.max(maybeMax, max)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ruby&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if height[r_idx] &amp;gt;= height[l_idx]
    maybe_max = height[l_idx] * (r_idx - l_idx)
    l_idx += 1
else 
    maybe_max = height[r_idx] * (r_idx - l_idx)
    r_idx -= 1
end

max_area = maybe_max if maybe_max &amp;gt; max_area
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Decided to mix up the syntax on the last line for variety since the Ruby and JS solutions look so similar.&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>challenge</category>
    </item>
    <item>
      <title>Reverse an Integer - Code Challenge</title>
      <dc:creator>Annette Michaels</dc:creator>
      <pubDate>Sun, 30 Jun 2019 23:07:48 +0000</pubDate>
      <link>https://dev.to/rygelxvi/reverse-an-integer-code-challenge-5g66</link>
      <guid>https://dev.to/rygelxvi/reverse-an-integer-code-challenge-5g66</guid>
      <description>&lt;p&gt;Leetcode Problem 7&lt;/p&gt;

&lt;h3&gt;
  
  
  Given a 32-bit signed integer, reverse digits of an integer.
&lt;/h3&gt;

&lt;p&gt;Examples:&lt;br&gt;
Input: -123&lt;br&gt;
Output: -321&lt;/p&gt;

&lt;p&gt;Input: 120&lt;br&gt;
Output: 21&lt;/p&gt;

&lt;p&gt;Input: 123&lt;br&gt;
Output: 321&lt;/p&gt;

&lt;p&gt;At first glance this problem is easy. In Ruby just convert to string, reverse, and convert back to integer and Ruby has all those nice built in functions to do just that and make it easy.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def reverse(x)

    x.to_s.reverse.to_i

end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, this will not accomodate a negative number as the reverse function does not accomodate then negative. So this is what happens.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;irb(main):016:0&amp;gt; x = -123
=&amp;gt; -123
irb(main):017:0&amp;gt; x.to_s.reverse.to_i
=&amp;gt; 321

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What we really want is -321 and one way to accomodate this is to create a variable that indicates whether or not it should be negative and add it if necessary on the return statement.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def reverse(x)

    neg = x &amp;lt; 0 
    x.to_s.reverse.to_i
    return neg ? -x : x

end

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Almost there. We have not considered a key part of the problem. It is a 32-bit integer.&lt;/p&gt;

&lt;p&gt;Integers can be huge, however, when programming there are limitations. Technically you could have a number that is infinite places long and have it be an integer but that would also break whatever you are working on (hello stackoverflow). So when the question says 32-bit integer what it is saying is the largest binary number with 32 places so...&lt;/p&gt;

&lt;p&gt;11111111111111111111111111111111   in base 2 math is equal to&lt;/p&gt;

&lt;p&gt;4294967295 in base 10 math.&lt;/p&gt;

&lt;p&gt;However, the problem also specifies signed so the first bit is a + or - resulting in 31 1's not 32 so we end up with the magic number as &lt;/p&gt;

&lt;p&gt;2147483648&lt;/p&gt;

&lt;p&gt;So the range is -2147483648 to 2147483648 right? But what about 0? Well the positive integer gets it so the range results in&lt;/p&gt;

&lt;p&gt;-2147483648 to 2147483647 non-inclusive of those numbers.&lt;/p&gt;

&lt;p&gt;To accommodate this we have to check if the integer input is greater or less than those ranges before returning a result.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def reverse(x)

    neg = x &amp;lt; 0
    x = x.to_s.reverse.to_i

    return  0 if (x &amp;gt; 2147483646 || x &amp;lt; -2147483647)

    return neg ? -x : x
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you wanted to not use as many built in functions building out the reverse is always good practice.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def reverse(x)
    i = 0

    neg = x &amp;lt; 0
    x = x.to_s

    x.length % 2 == 0? (half = x.length/2) : (half = x.length/2 + 1)
    len = x.length - 1

    while i &amp;lt; half
      temp = x[i]        
      x[i] = x[len - i]
      x[len - i] = temp
      i += 1
    end

    x = x.to_i

    return  0 if (x &amp;gt; 2147483646 || x &amp;lt; -2147483647)

    return neg ? -x : x
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In Javascript we end up with&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var reverse = function(x) {
    const neg = x &amp;lt; 0

    x = Math.abs(x).toString().split("").reverse().join("")
    x = parseInt(x)

    if (neg) {
        x = - + x
    }

    if (x &amp;lt; -2147483647 || x &amp;gt; 2147483646){
        return 0
    } else {
        return x
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Of course the parseInt can be combined with the line above it but it's a little easier to read on a different line.&lt;/p&gt;

&lt;p&gt;Until my next code challenge.&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>javascript</category>
      <category>challenge</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Singly Linked List in JS</title>
      <dc:creator>Annette Michaels</dc:creator>
      <pubDate>Fri, 28 Jun 2019 16:16:54 +0000</pubDate>
      <link>https://dev.to/rygelxvi/singly-linked-list-in-js-1b62</link>
      <guid>https://dev.to/rygelxvi/singly-linked-list-in-js-1b62</guid>
      <description>&lt;h1&gt;
  
  
  Data Structures - Singly Linked Lists
&lt;/h1&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;A singly linked list consists of many nodes each node contains data and points at the next node. The last node in the list points to null which is how you know you reached the end. The front of the list is the head node.&lt;/p&gt;

&lt;p&gt;The following is some Javascript code showing initialization of the LinkedList and Node classes.  &lt;/p&gt;

&lt;p&gt; &lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
class LinkedList {

  constructor() {
    this.head = null
    this.size = 0
  }


///Other methods here



end



class Node {

  constructor(data, next) {
    this.data = data
    this.next = next
  }

}

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt; &lt;/p&gt;

&lt;h6&gt;
  
  
  Head Node ---&amp;gt; Node ---&amp;gt;  Node ---&amp;gt; Node ---&amp;gt;...more nodes... --&amp;gt; null   
&lt;/h6&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;It is a very simple structure. It does not require that nodes are next to each other in memory and because of this is very easy to add and remove from the head of the list. It can be done in constant or O(1) time which is the best possible time complexity.  &lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Javascript - add to head and remove from head&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  addToHead(data) {
    let node
    if (!!data) {
      node = new Node(data, this.head)
      this.head = node
      this.size += 1
    } else {
      return null
    }
}

  removeFromHead() {
    if (this.size != 0) {
      this.head = this.head.next
      this.size -= 1
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt; &lt;/p&gt;

&lt;p&gt;A downside to this structure is that it is more expensive to search for something in the list or add/remove to the end (instead of th head). Every node has to be iterated through until we accidently run into the node that contains the data we are looking for or until we reach the end or until the next pointer points to null.   &lt;/p&gt;

&lt;p&gt; &lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// finds the Node that contains the data. If it doesn't exist returns null
  find(data) {
    let current = this.head
      while (current != null) {
        if (current.data === data) {
          return current
        } else {
          current = current.next
        }
      }
    return null
}



  addToTail(data) {
    let node
    let size = this.size
    let current = this.head

    if (!!data) {

// when list is empty just add to head
      if (current === null) {
        this.addToHead(data)
      } else {

// otherwise find the end of the list and add a Node
        while (size &amp;gt; 0) {

// if size === 1 than it is the last node. Add new Node to end.
          if (size === 1) {
            node = new Node(data, null)
            current.next = node
            this.size += 1
          }
// size is &amp;gt; 1 than decrement size and check the next Node
          current = current.next
          size -= 1
        }
      }
    } else {
      return null
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Since we have to traverse the list each time this results in O(n) complexity which is not optimal.  &lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Inserting and deleting from the middle of the list is equally as difficult since we have to create our new node and point it to the 'next' node &lt;em&gt;before&lt;/em&gt; we mode the current node's next to the new node. Else we have no pointer and the list is lost.  &lt;/p&gt;

&lt;p&gt; &lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  insertAtIndex(data, index) {
    let node
    let current
    let size = this.size

// check if !!data and if index is within bounds
    if (!!data &amp;amp;&amp;amp; index &amp;gt;= size - 1 &amp;amp;&amp;amp; index &amp;gt;= 0) {
      current = this.head

// base case if list is empty or if adding to head
      if (current == null &amp;amp;&amp;amp; index === 0 || index === size-1) {
        this.addToHead(data)
        return true
      }
// base case when adding to tail
      if (index === 1) {
        this.addToTail(data)
        return true
      }

// find spot before index and insert to next Node
      while (size &amp;gt; index) {
        if (size - 1 === index) {
          node = new Node(data, current.next)
          current.next = node
          this.size += 1
          return true
        }
        current = current.next
        size -= 1
      }

    }
    return false
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt; &lt;/p&gt;

&lt;p&gt;This is why the structures are often used for Stacks and Queues. It allows flexibility for the operating system because it doesn't need a block of memory like an array does which makes them optimal for Stacks and Queues in my opinion. With a Stack we are always manipulating the last thing added because it is a last in first out (LIFO) structure and a Queue is a first in first out (FIFO) data structure. We can talk about those a different day. &lt;/p&gt;

&lt;p&gt;Here's a link to my &lt;a href="https://github.com/Rygel-XVI/my-linked-list-js"&gt;JS linked-list code&lt;/a&gt;&lt;/p&gt;

</description>
      <category>coding</category>
      <category>computerscience</category>
      <category>beginners</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Longest Palindromic Substring</title>
      <dc:creator>Annette Michaels</dc:creator>
      <pubDate>Tue, 18 Jun 2019 01:39:10 +0000</pubDate>
      <link>https://dev.to/rygelxvi/longest-palindromic-substring-1dae</link>
      <guid>https://dev.to/rygelxvi/longest-palindromic-substring-1dae</guid>
      <description>&lt;h1&gt;
  
  
  Longest Palindromic Substring
&lt;/h1&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;How to find the longest palindromic substring in a string?&lt;/strong&gt;
&lt;/h3&gt;

&lt;h3&gt;
  
  
  First we have to answer the question 'What is a palindrome?"
&lt;/h3&gt;

&lt;p&gt;A palindrome is the same backwards and forwards.&lt;/p&gt;

&lt;p&gt;For example, these are all palindromes&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;      "mom"&lt;/li&gt;
&lt;li&gt;      "racecar"&lt;/li&gt;
&lt;li&gt;      "taco cat"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;      So when given a string (s) how do we determine if it is a palindrome? First off we need to determine if we will be considering just single words or if we will be considering cases that include spaces. For this situation we will be using single words to make it simpler.&lt;/p&gt;

&lt;p&gt;      Some of the more common solutions include the 'brute force' method or check every substring to see if it is a palindrome. We could also do the expand from the center method which is more efficient than brute force. The best method is to use Manacher's Algorithm which is linear time and I recommend looking it up.&lt;/p&gt;

&lt;p&gt;For this blog I am going to explain solving the problem using a matrix.&lt;/p&gt;

&lt;p&gt;There are 3 variables to keep track of.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Index at where the palindrome starts (start)&lt;/li&gt;
&lt;li&gt;Length of the palindrome (max)&lt;/li&gt;
&lt;li&gt;Index offset (k)
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def longest_palindrome(s)
   start = 0
   max = 0
   k = 2


end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;      We will iterate through the string and when we run into matching letters (matrix[i][j]) where matrix[i+1][j-1] == true we can add another true to the table. To do this we need to initialize the matrix and set all matrix[i][i] = true because each character is a palindrome of size 1.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    for n in 0..s.length - 1
      matrix[n][n] = true
    end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;a&lt;/th&gt;
&lt;th&gt;b&lt;/th&gt;
&lt;th&gt;b&lt;/th&gt;
&lt;th&gt;b&lt;/th&gt;
&lt;th&gt;a&lt;/th&gt;
&lt;th&gt;b&lt;/th&gt;
&lt;th&gt;c&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;a&lt;/td&gt;
&lt;td&gt;T&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;b&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;T&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;b&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;T&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;b&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;T&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;a&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;T&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;b&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;T&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;c&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;T&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;      We also need to go through and set matrix[i][i+1] to true if the characters match else the odd indicies can never be 'true' as you will see when we get to that part of the code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    for m in 0..s.length - 1
      if (s[m] == s[m+1])
          matrix[m][m+1] = true
          start = m
          max = 1
      end
    end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;a&lt;/th&gt;
&lt;th&gt;b&lt;/th&gt;
&lt;th&gt;b&lt;/th&gt;
&lt;th&gt;b&lt;/th&gt;
&lt;th&gt;a&lt;/th&gt;
&lt;th&gt;b&lt;/th&gt;
&lt;th&gt;c&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;a&lt;/td&gt;
&lt;td&gt;T&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;b&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;T&lt;/td&gt;
&lt;td&gt;T&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;b&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;T&lt;/td&gt;
&lt;td&gt;T&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;b&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;T&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;a&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;T&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;b&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;T&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;c&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;T&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;      Now if we go through the rest of the comparisons checking if the chars are the same and the matrix value is true to the bottom left ([i+1][j-1]) we will end up filling the matrix as such.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;a&lt;/th&gt;
&lt;th&gt;b&lt;/th&gt;
&lt;th&gt;b&lt;/th&gt;
&lt;th&gt;b&lt;/th&gt;
&lt;th&gt;a&lt;/th&gt;
&lt;th&gt;b&lt;/th&gt;
&lt;th&gt;c&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;a&lt;/td&gt;
&lt;td&gt;T&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;T&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;b&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;T&lt;/td&gt;
&lt;td&gt;T&lt;/td&gt;
&lt;td&gt;T&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;b&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;T&lt;/td&gt;
&lt;td&gt;T&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;b&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;T&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;T&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;a&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;T&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;b&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;T&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;c&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;T&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    while (k &amp;lt; s.length)
        while (i &amp;lt; s.length - k)
            j = i + k
            if (s[j] == s[i] &amp;amp;&amp;amp; !!matrix[i+1][j-1])
                matrix[i][j] = true

                if (k &amp;gt; max)
                    max = k
                    start = i
                end

            end
            i += 1
        end
        k += 1
        i = 0
    end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;      We start with k = 2 since we already filled in the first two diagonals and then each time we increment k we set i = 0 and in the inner loop j = i + k (offset). At the end we can return the substring using the variables we saved. If we put it all together we have...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def longest_palindrome(s)
    start = 0
    max = 0

    if (s.length &amp;lt; 3)
        return "" if (s.length &amp;lt; 1)
        return s[0] if (s.length == 1)
        return s[0] == s[1] ? s : s[0]
    end

    matrix = Array.new(s.length) {Array.new(s.length)}

    for n in 0..s.length - 1
      matrix[n][n] = true
    end

    for m in 0..s.length - 1
      if (s[m] == s[m+1])
          matrix[m][m+1] = true
          start = m
          max = 1
      end
    end

    i = 0
    k = 2
    while (k &amp;lt; s.length)
        while (i &amp;lt; s.length - k)
            j = i + k
            if (s[j] == s[i] &amp;amp;&amp;amp; !!matrix[i+1][j-1])
                matrix[i][j] = true

                if (k &amp;gt; max)
                    max = k
                    start = i
                end

            end
            i += 1
        end
        k += 1
        i = 0
    end

    return s[(start)..(start + max)]
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;And as always don't forget to add your base cases!&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    if (s.length &amp;lt; 3)

        # empty string as input
        return "" if (s.length &amp;lt; 1)

        # string of length 1 should return the char
        return s[0] if (s.length == 1)

        # If there are two letters that are the same return the string else just the first char
        return s[0] == s[1] ? s : s[0]
    end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Please don't hesitate to give me feedback on my code! It's the only way we get better and I'm sure I have a long way to go =)&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>algorithms</category>
      <category>challenge</category>
      <category>ruby</category>
    </item>
    <item>
      <title>Career changes are hard</title>
      <dc:creator>Annette Michaels</dc:creator>
      <pubDate>Tue, 11 Jun 2019 18:11:52 +0000</pubDate>
      <link>https://dev.to/rygelxvi/career-changes-are-hard-1e4i</link>
      <guid>https://dev.to/rygelxvi/career-changes-are-hard-1e4i</guid>
      <description>&lt;h3&gt;
  
  
  Changing careers is hard,
&lt;/h3&gt;

&lt;p&gt;especially when working full-time in an unrelated field.&lt;/p&gt;

&lt;p&gt;I thought completing my coursework was a challenge in time-management. I was wrong. Job searching for that first job is the &lt;em&gt;real&lt;/em&gt; challenge in time-management.&lt;/p&gt;

&lt;p&gt;Not only do I need to keep my coding skills up by working on personal projects and doing code problems, I also have to filter through the egregious amount of job postings, write cover letters, and network.&lt;/p&gt;

&lt;p&gt;To add to this I have decided to learn Java. My classes were in Ruby and Javascript so learning a strongly-typed language and having built in classes for Trees and whatnot would be nice. More importantly many roles require either an iteration of C, Java, or Python so a basis in one (however small) would be great.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Here is the list&lt;/strong&gt;
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;job search&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;network&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;practice code challenges&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;on the computer&lt;/li&gt;
&lt;li&gt;on the whiteboard (aka the sliding glass door in my house)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;continue working on personal projects&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;learn Java&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I need to dedicate aliquots of time so many days a week to make sure that when I am productive that I am focused on what I need to focus on instead of trying to figure out what I should do each day.&lt;/p&gt;

&lt;h4&gt;
  
  
  Here is the plan:
&lt;/h4&gt;

&lt;p&gt;When it is slow at work - work on blog posts on coding problems and CS topics&lt;/p&gt;

&lt;p&gt;2 days a week (Probably Tuesday/Friday) - Job stuff&lt;br&gt;
2 days a week - do a coding challenges in each language&lt;br&gt;
1 day a week - practice whiteboarding&lt;br&gt;
1 day a week - do nothing/sleep/excessive netflix  &lt;em&gt;yeay&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Wen I need a break, I do what I really want to do, learn Java and work on my personal projects.&lt;/p&gt;

&lt;p&gt;Lets see how this goes.&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>career</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
