<?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: Amy Shackles</title>
    <description>The latest articles on DEV Community by Amy Shackles (@amyshackles).</description>
    <link>https://dev.to/amyshackles</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%2F326399%2F2283f19b-333c-48d3-9b0e-12af4c6d78d1.jpg</url>
      <title>DEV Community: Amy Shackles</title>
      <link>https://dev.to/amyshackles</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/amyshackles"/>
    <language>en</language>
    <item>
      <title>SingleNumber</title>
      <dc:creator>Amy Shackles</dc:creator>
      <pubDate>Fri, 08 Jan 2021 01:24:17 +0000</pubDate>
      <link>https://dev.to/amyshackles/singlenumber-3hhm</link>
      <guid>https://dev.to/amyshackles/singlenumber-3hhm</guid>
      <description>&lt;h1&gt;
  
  
  Problem Statement
&lt;/h1&gt;

&lt;p&gt;Given a non-empty array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without extra memory?&lt;/p&gt;

&lt;h1&gt;
  
  
  Thought Process
&lt;/h1&gt;

&lt;p&gt;My initial conclusion was that no, you couldn’t. Since there’s not a range for the possible numbers in the array and the array isn’t already sorted, you can solve in linear time if you used an object to store counts, but you need that extra storage or sorting is O(n log n).&lt;/p&gt;

&lt;p&gt;But see, I forgot about XOR (^). For those of you who don’t play with bits, exclusive or takes two binary numbers and for pair where one number has the bit flipped and the other doesn’t, the resulting number has the bit flipped.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  01101
^ 10110
= 11011
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So if you have a number and XOR it by 0, you get the number. If you have a number and XOR it by itself, you get 0.&lt;/p&gt;

&lt;p&gt;Now, that’s helpful, but why would you care about XOR for this problem?&lt;/p&gt;

&lt;p&gt;Let’s run through an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;num&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;num&lt;/span&gt; &lt;span class="o"&gt;^=&lt;/span&gt; &lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;num&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cm"&gt;/*
5
4
6
4
0
5
4
6
7
5
*/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Explanation/Solution
&lt;/h1&gt;

&lt;p&gt;Because all of the values that appear twice will eventually cancel themselves out, you’re left with that one solitary element that has no partner. No extra storage necessary. Linear time.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  100 // 4
^ 001 // 1
= 101 // 5
^ 001 // 1
= 100 // 4
^ 010 // 2
= 110 // 6
^ 010 // 2
= 100 // 4
^ 100 // 4
= 000 // 0
^ 101 // 5
= 101 // 5
^ 001 // 1
= 100 // 4
^ 010 // 2
= 110 // 6
^ 001 // 1
= 111 // 7
^ 010 // 2
= 101 // 5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since we're working with an array of numbers, we can make use of an array method to accomplish the task in lieu of a for loop.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;singleNumber&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;^&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Problem taken from &lt;a href="https://leetcode.com/problems/single-number/"&gt;LeetCode&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>Why Is {} &gt; [] ?</title>
      <dc:creator>Amy Shackles</dc:creator>
      <pubDate>Tue, 24 Nov 2020 21:34:40 +0000</pubDate>
      <link>https://dev.to/amyshackles/why-is-2hkk</link>
      <guid>https://dev.to/amyshackles/why-is-2hkk</guid>
      <description>&lt;h2&gt;
  
  
  TLDR version
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Relational Comparisons
&lt;/h2&gt;

&lt;p&gt;In JavaScript, the result of a relational comparison is determined by the &lt;a href="https://tc39.es/ecma262/#sec-abstract-relational-comparison" rel="noopener noreferrer"&gt;Abstract Relational Comparison algorithm&lt;/a&gt;.  The algorithm converts both sides of a comparison to primitive values and then returns the result of the comparison between those two primitive values.&lt;/p&gt;

&lt;h2&gt;
  
  
  ToPrimitive¹
&lt;/h2&gt;

&lt;p&gt;The Abstract Relational Comparison algorithm calls &lt;code&gt;ToPrimitive&lt;/code&gt; twice, once for each operand, passing 'number' as the second argument.  This tells the &lt;code&gt;ToPrimitive&lt;/code&gt; function that if there are multiple primitive types the operand could convert to, and number is one of them, it should convert the value to a number instead of a different type. &lt;/p&gt;

&lt;h2&gt;
  
  
  OrdinaryToPrimitive²
&lt;/h2&gt;

&lt;p&gt;If the value being passed to &lt;code&gt;ToPrimitive&lt;/code&gt; is an object, it then calls &lt;code&gt;OrdinaryToPrimitive&lt;/code&gt; with the same two arguments, value and type hint.  &lt;code&gt;OrdinaryToPrimitive&lt;/code&gt; generates a list of methods to call to convert the value to a primitive.  &lt;/p&gt;

&lt;p&gt;If "string" is passed in as the type hint, the method order becomes &lt;code&gt;toString&lt;/code&gt; followed by &lt;code&gt;valueOf&lt;/code&gt;.  In this case, since "number" was passed, the method order is &lt;code&gt;valueOf&lt;/code&gt; followed by &lt;code&gt;toString&lt;/code&gt;.  It's important to note that while all values that get to this point are objects, not every value will use the &lt;code&gt;valueOf&lt;/code&gt; and &lt;code&gt;toString&lt;/code&gt; methods on the &lt;strong&gt;Object&lt;/strong&gt; prototype.&lt;/p&gt;

&lt;p&gt;If the first method results in a value of type "object", the result of calling the second method returned.   If the first method does not return a value of type "object", the result of the first method is returned.&lt;/p&gt;

&lt;h2&gt;
  
  
  OrdinaryToPrimitive( {} )
&lt;/h2&gt;

&lt;p&gt;In the case of {}, the only prototype being looked at is &lt;strong&gt;Object&lt;/strong&gt;, so it first tries calling &lt;code&gt;valueOf&lt;/code&gt; on the object using &lt;code&gt;Object.prototype.value()&lt;/code&gt;³, but that returns {}.  Since typeof {} === "object", it moves to the next method. It then calls &lt;code&gt;Object.prototype.toString()&lt;/code&gt;⁴&lt;br&gt;
;  If &lt;code&gt;Object.prototype.toString()&lt;/code&gt; is called on a value that is an object, the builtinTag is set to "Object".  The return value of &lt;code&gt;Object.prototype.toString()&lt;/code&gt; is the concatenation of "[object ", tag, "]".  The return value for passing in an empty object, then, is "[object Object]"&lt;/p&gt;
&lt;h2&gt;
  
  
  OrdinaryToPrimitive( [] )
&lt;/h2&gt;

&lt;p&gt;In the case of [], there are two prototypes to take into consideration -- &lt;strong&gt;Array&lt;/strong&gt; &lt;em&gt;and&lt;/em&gt; &lt;strong&gt;Object&lt;/strong&gt;.  If a method exists on the &lt;strong&gt;Array&lt;/strong&gt; prototype, that is the method called.  If, however, it does not exist on the &lt;strong&gt;Array prototype&lt;/strong&gt;, it looks for the method on the &lt;strong&gt;Object&lt;/strong&gt; prototype.  The &lt;strong&gt;Array&lt;/strong&gt; prototype does not contain a method for &lt;code&gt;valueOf&lt;/code&gt;, so it first tries calling &lt;code&gt;Object.prototype.valueOf()&lt;/code&gt;.  That returns [], and since typeof [] === "object", it moves on to the next method. &lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;Array&lt;/strong&gt; prototype does have a &lt;code&gt;toString()&lt;/code&gt; method, so It then calls &lt;code&gt;Array.prototype.toString()&lt;/code&gt;⁵.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Array.prototype.toString()&lt;/code&gt; returns the value of the &lt;code&gt;join&lt;/code&gt; method on the array.  As there are no elements in the array, the return value of &lt;code&gt;Array.prototype.toString()&lt;/code&gt; on an empty array is an empty string.&lt;/p&gt;
&lt;h2&gt;
  
  
  Comparison
&lt;/h2&gt;

&lt;p&gt;Now that both sides are converted to their primitive values, it's time to compare them in relation to each other.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;[object Object]&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A string of any length is going to be greater in value than the value of an empty string. &lt;/p&gt;

&lt;h2&gt;
  
  
  Follow-up
&lt;/h2&gt;

&lt;p&gt;The way that JavaScript evaluates abstract equality when one operand is of type String/Number/Symbol/BigInt and the other operand is an object is to call the same &lt;code&gt;ToPrimitive&lt;/code&gt; on the object and then check equality⁶. &lt;/p&gt;

&lt;p&gt;Therefore, we can also sanity check that {} is actually converted to &lt;code&gt;"[object Object]"&lt;/code&gt; and [] is converted to an empty string by performing abstract equality checks.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;({}&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;[object Object]&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// true&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;([]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Why does {} &amp;gt; [] error in browser?
&lt;/h2&gt;

&lt;p&gt;Shout out to &lt;a href="https://hashnode.com/@MartijnImhoff" rel="noopener noreferrer"&gt;Martijn Imhoff&lt;/a&gt; for asking this question.&lt;/p&gt;

&lt;p&gt;The way that the specification for JavaScript is written, block statements are evaluated before expressions, so when the interpreter sees curly braces when not in an expression context, it interprets them as a block rather than an object literal.  That's why you get an error when you attempt to run those expressions in the browser.  The way to force the interpreter to see {} as an object literal instead of as a block is to wrap it in parentheses.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2FAmyShackles%2FAmyShackles%2Fblob%2Fmaster%2Fparens-with-%257B%257D%253E%255B%255D.png%3Fraw%3Dtrue" 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%2Fgithub.com%2FAmyShackles%2FAmyShackles%2Fblob%2Fmaster%2Fparens-with-%257B%257D%253E%255B%255D.png%3Fraw%3Dtrue" alt="({}) &amp;gt; [] // true; ({}) &amp;lt; [] // false; ({}) == "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you were to open a Node console rather than a browser console, you would see:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2FAmyShackles%2FAmyShackles%2Fblob%2Fmaster%2F%257B%257D%2520%253E%2520%255B%255D.png%3Fraw%3Dtrue" 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%2Fgithub.com%2FAmyShackles%2FAmyShackles%2Fblob%2Fmaster%2F%257B%257D%2520%253E%2520%255B%255D.png%3Fraw%3Dtrue" alt="{} &amp;gt; [] // true; &amp;gt; {} &amp;lt; [] // false; {} == "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is because Node made a change to evaluate input as expressions before evaluating them as statements.  That change can be seen &lt;a href="https://github.com/nodejs/node/blob/651088c3e6b6399a3e656e397c3845b970ad7903/lib/repl.js#L355-L358" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  TLDR Version
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;{}&lt;/code&gt; is converted to &lt;code&gt;"[object Object]"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;[]&lt;/code&gt; is converted to &lt;code&gt;""&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;"[object Object]" &amp;gt; ""&lt;/code&gt;&lt;/p&gt;




&lt;p&gt;References:&lt;/p&gt;

&lt;p&gt;¹ &lt;a href="https://tc39.es/ecma262/#sec-toprimitive" rel="noopener noreferrer"&gt;ToPrimitive specification&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;² &lt;a href="https://tc39.es/ecma262/#sec-ordinarytoprimitive" rel="noopener noreferrer"&gt;OrdinaryToPrimitive specification&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;³ &lt;a href="https://tc39.es/ecma262/#sec-object.prototype.valueof" rel="noopener noreferrer"&gt;Object.prototype.valueOf() specification&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;⁴ &lt;a href="https://tc39.es/ecma262/#sec-object.prototype.tostring" rel="noopener noreferrer"&gt;Object.prototype.toString() specification&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;⁵ &lt;a href="https://tc39.es/ecma262/#sec-array.prototype.tostring" rel="noopener noreferrer"&gt;Array.prototype.toString() specification&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;⁶ &lt;a href="https://tc39.es/ecma262/#sec-abstract-equality-comparison" rel="noopener noreferrer"&gt;Abstract Equality Comparison algorithm&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>Learning to Love Regex</title>
      <dc:creator>Amy Shackles</dc:creator>
      <pubDate>Thu, 12 Nov 2020 03:45:21 +0000</pubDate>
      <link>https://dev.to/amyshackles/learning-to-love-regex-12ip</link>
      <guid>https://dev.to/amyshackles/learning-to-love-regex-12ip</guid>
      <description>&lt;p&gt;You create a table of information somewhere and decide to transfer it somewhere else in markdown format.&lt;br&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fh0o7o6483g61m8a78g2i.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fh0o7o6483g61m8a78g2i.png" alt="A table in Whimsical with values highlighted for copy"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fw56in960qf3qddfolc3z.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fw56in960qf3qddfolc3z.png" alt="The values from the table posted into a Repl -- the formatting is all wrong!"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Only, when you go to copy the values into your code editor, you realize that the formatting is all wrong!  Verdammt!  You spent all day compiling this information and you &lt;em&gt;really&lt;/em&gt; don't want to spend the rest of the day fiddling around with the formatting to turn it into a markdown table.  &lt;/p&gt;

&lt;p&gt;Never fear, friend.  Regex to the rescue.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 1: Know how to write a markdown table
&lt;/h2&gt;

&lt;p&gt;The basic format is this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The heading for the table needs a pipe (|) on either side of each column.&lt;/li&gt;
&lt;li&gt;Between the heading of the table and the table body, there needs to be a line where each column has a pipe on either side and the content of the column has three or more hyphens&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;| Heading1 | Heading2 |
| --- | --- |
| The most | Basic table ever |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ends up looking like:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Heading1&lt;/th&gt;
&lt;th&gt;Heading2&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;The most&lt;/td&gt;
&lt;td&gt;Basic table ever&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Step 2: Remove newlines
&lt;/h2&gt;

&lt;p&gt;To make subsequent regular expressions easier, remove all the newlines in the pasted text and replace them with a single space.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F7qbgz30x20boitc6nsrw.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F7qbgz30x20boitc6nsrw.png" alt="Repl of pasted text with a find/replace set to find \n with regular expression option selected and replace with a space"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fy0jzc5l2cijkh7o55rzb.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fy0jzc5l2cijkh7o55rzb.png" alt="Repl result of running the find/replace operation - now all of the text is on one line"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 3: Create your table header
&lt;/h2&gt;

&lt;p&gt;This step requires figuring out a regular expression that will match your headers and capture each header individually so that you can manipulate what surrounds it (namely, to add the pipes).  This can be accomplished by making use of capture groups.  For capture groups, each capture is given a number internally which can then be used in the replace operation.  In this example, our table header should include &lt;code&gt;Alias&lt;/code&gt;, &lt;code&gt;Canonical property name&lt;/code&gt;, and &lt;code&gt;Matches letters and written signs belonging to ____ script&lt;/code&gt; as headers, so we need to come up with a way to match those.  Note that with regular expressions, there are a ton of ways to approach a regular expression to match text, so this is by no means the only way to go about it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Find:
(\w+) ([\w\s]+(?= Matches)) ([\w\s]+)

Replace:
| $1 | $2 | $3 |\n| --- | --- | --- |\n

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

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F89atpyu1ogt8ubindztr.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F89atpyu1ogt8ubindztr.png" alt="Only the text that we want to be the header of our table is highlighted when we try out our regular expression find"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The find regex:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creates a capture group of one or more alphanumeric characters (including underscore)&lt;/li&gt;
&lt;li&gt;Matches a space&lt;/li&gt;
&lt;li&gt;Creates a second capture group of one or more of either alphanumeric characters (including underscore) or whitespace characters only if it is followed by a space and the word 'Matches' (Since the third heading begins with 'Matches', this is a way to ensure that the second capture group ends at the right spot)&lt;/li&gt;
&lt;li&gt;Matches a space&lt;/li&gt;
&lt;li&gt;Creates a third capture group of one or more either alphanumeric characters (including underscore) or whitespace characters&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;Alias&lt;/code&gt; becomes capture group 1&lt;br&gt;
&lt;code&gt;Canonical property name&lt;/code&gt; becomes capture group 2&lt;br&gt;
&lt;code&gt;Matches letters and written signs belonging to ____ script&lt;/code&gt; becomes capture group 3&lt;/p&gt;

&lt;p&gt;The replacement regex:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Adds a pipe (|) and a space before capture group 1&lt;/li&gt;
&lt;li&gt;Adds a space and a pipe and a space before capture group 2&lt;/li&gt;
&lt;li&gt;Adds a space and a pipe and a space before capture group 3&lt;/li&gt;
&lt;li&gt;Adds a space and a pipe after the third capture group&lt;/li&gt;
&lt;li&gt;Adds a new line&lt;/li&gt;
&lt;li&gt;Adds a pipe&lt;/li&gt;
&lt;li&gt;Adds a space&lt;/li&gt;
&lt;li&gt;Adds three hyphens&lt;/li&gt;
&lt;li&gt;Adds a space&lt;/li&gt;
&lt;li&gt;Adds a pipe&lt;/li&gt;
&lt;li&gt;Adds a space&lt;/li&gt;
&lt;li&gt;Adds three hyphens&lt;/li&gt;
&lt;li&gt;Adds a space&lt;/li&gt;
&lt;li&gt;Adds a pipe&lt;/li&gt;
&lt;li&gt;Adds a space&lt;/li&gt;
&lt;li&gt;Adds three hyphens&lt;/li&gt;
&lt;li&gt;Adds a space&lt;/li&gt;
&lt;li&gt;Adds a pipe&lt;/li&gt;
&lt;li&gt;Adds a new line&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F81428j907kgqvc8k8vfw.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F81428j907kgqvc8k8vfw.png" alt="After applying the find/replace regex, a header is created for the table"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Create the table body
&lt;/h2&gt;

&lt;p&gt;This is much like the routine we went through to create the header for the table -- we need to come up with a regular expression that will match what we want to match and ensure that our replacement regular expression converts it into the format we're looking for.&lt;/p&gt;

&lt;p&gt;I know from having input all of this data that the pattern for the table is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The first column starts with &lt;code&gt;\p{Script=&lt;/code&gt;, is followed by variable number of letters, followed by &lt;code&gt;}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The second column starts with &lt;code&gt;\p{Script=&lt;/code&gt;, is followed by a variable number of letters (and/or underscores), followed by &lt;code&gt;}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The third column is a variable number of letters and can include multiple words (so can include whitespace)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Find:
(\\p{Script=\w+}) (\\p{Script=\w+}) ([\w\s]+)

Replace:
| $1 | $2 | $3 |\n

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

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fs2irr1niyyckrw6uoj2s.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fs2irr1niyyckrw6uoj2s.png" alt="The text other than the newly created header is highlighted to indicate that the regex is matching.  There are 142 matches to this find, which is what we expect"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The find regex:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creates a capture group of the value &lt;code&gt;\p{Script=&lt;/code&gt; followed by one ore more alphanumeric characters followed by a &lt;code&gt;}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Matches a space&lt;/li&gt;
&lt;li&gt;Creates a capture group of the value &lt;code&gt;\p{Script=&lt;/code&gt; followed by one or more alphanumeric values followed by a &lt;code&gt;}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Matches a space&lt;/li&gt;
&lt;li&gt;Creates a capture group of one or more alphanumeric values or whitespaces&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For the first row of the table:&lt;br&gt;
&lt;code&gt;\p{Script=Adlm}&lt;/code&gt; becomes capture group 1&lt;br&gt;
&lt;code&gt;\p{Script=Adlam}&lt;/code&gt; becomes capture group 2&lt;br&gt;
&lt;code&gt;Adlam&lt;/code&gt; becomes capture group 3&lt;/p&gt;

&lt;p&gt;The replacement regex:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Adds a pipe and a space before capture group 1&lt;/li&gt;
&lt;li&gt;Adds a pipe and a space before capture group 2&lt;/li&gt;
&lt;li&gt;Adds a pipe and a space before capture group 3&lt;/li&gt;
&lt;li&gt;Adds a space and a pipe after capture group 3&lt;/li&gt;
&lt;li&gt;Adds a new line&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F44uo2k7vvurjnjw79rfx.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F44uo2k7vvurjnjw79rfx.png" alt="The text now looks like it's in markdown format!"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Copying that newly formatted text here results in (moment of truth....)&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Alias&lt;/th&gt;
&lt;th&gt;Canonical property name&lt;/th&gt;
&lt;th&gt;Matches letters and written signs belonging to _____ script&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Adlm}&lt;/td&gt;
&lt;td&gt;\p{Script=Adlam}&lt;/td&gt;
&lt;td&gt;Adlam&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Ahom}&lt;/td&gt;
&lt;td&gt;\p{Script=Ahom}&lt;/td&gt;
&lt;td&gt;Ahom&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Hluw}&lt;/td&gt;
&lt;td&gt;\p{Script=Anatolian_Hieroglyphs}&lt;/td&gt;
&lt;td&gt;Anatolian Hieroglyphs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Arab}&lt;/td&gt;
&lt;td&gt;\p{Script=Arabic}&lt;/td&gt;
&lt;td&gt;Arabic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Armn}&lt;/td&gt;
&lt;td&gt;\p{Script=Armenian}&lt;/td&gt;
&lt;td&gt;Armenian&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Avst}&lt;/td&gt;
&lt;td&gt;\p{Script=Avestan}&lt;/td&gt;
&lt;td&gt;Avestan&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Bali}&lt;/td&gt;
&lt;td&gt;\p{Script=Balinese}&lt;/td&gt;
&lt;td&gt;Balinese&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Bamu}&lt;/td&gt;
&lt;td&gt;\p{Script=Bamum}&lt;/td&gt;
&lt;td&gt;Bamum&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Bass}&lt;/td&gt;
&lt;td&gt;\p{Script=Bassa_Vah}&lt;/td&gt;
&lt;td&gt;Bassa Vah&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Batk}&lt;/td&gt;
&lt;td&gt;\p{Script=Batak}&lt;/td&gt;
&lt;td&gt;Batak&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Beng}&lt;/td&gt;
&lt;td&gt;\p{Script=Bengali}&lt;/td&gt;
&lt;td&gt;Bengali&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Bhks}&lt;/td&gt;
&lt;td&gt;\p{Script=Bhaiksuki}&lt;/td&gt;
&lt;td&gt;Bhaiksuki&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Bopo}&lt;/td&gt;
&lt;td&gt;\p{Script=Bopomofo}&lt;/td&gt;
&lt;td&gt;Bopomofo&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Brah}&lt;/td&gt;
&lt;td&gt;\p{Script=Brahmi}&lt;/td&gt;
&lt;td&gt;Brahmi&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Brai}&lt;/td&gt;
&lt;td&gt;\p{Script=Braille}&lt;/td&gt;
&lt;td&gt;Braille&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Bugi}&lt;/td&gt;
&lt;td&gt;\p{Script=Buginese}&lt;/td&gt;
&lt;td&gt;Buginese&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Buhd}&lt;/td&gt;
&lt;td&gt;\p{Script=Buhid}&lt;/td&gt;
&lt;td&gt;Buhid&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Cans}&lt;/td&gt;
&lt;td&gt;\p{Script=Canadian_Aboriginal}&lt;/td&gt;
&lt;td&gt;Canadian Aboriginal&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Cari}&lt;/td&gt;
&lt;td&gt;\p{Script=Carian}&lt;/td&gt;
&lt;td&gt;Carian&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Aghb}&lt;/td&gt;
&lt;td&gt;\p{Script=Caucasian_Albanian}&lt;/td&gt;
&lt;td&gt;Caucasian Albanian&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Cakm}&lt;/td&gt;
&lt;td&gt;\p{Script=Chakma}&lt;/td&gt;
&lt;td&gt;Chakma&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Cher}&lt;/td&gt;
&lt;td&gt;\p{Script=Cherokee}&lt;/td&gt;
&lt;td&gt;Cherokee&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Zyyy}&lt;/td&gt;
&lt;td&gt;\p{Script=Common}&lt;/td&gt;
&lt;td&gt;Common&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Copt}&lt;/td&gt;
&lt;td&gt;\p{Script=Coptic}&lt;/td&gt;
&lt;td&gt;Coptic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Qaac}&lt;/td&gt;
&lt;td&gt;\p{Script=Coptic}&lt;/td&gt;
&lt;td&gt;Coptic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Xsux}&lt;/td&gt;
&lt;td&gt;\p{Script=Cuneiform}&lt;/td&gt;
&lt;td&gt;Cuneiform&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Cprt}&lt;/td&gt;
&lt;td&gt;\p{Script=Cypriot}&lt;/td&gt;
&lt;td&gt;Cypriot&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Cyrl}&lt;/td&gt;
&lt;td&gt;\p{Script=Cyrillic}&lt;/td&gt;
&lt;td&gt;Cyrillic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Dsrt}&lt;/td&gt;
&lt;td&gt;\p{Script=Deseret}&lt;/td&gt;
&lt;td&gt;Deseret&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Deva}&lt;/td&gt;
&lt;td&gt;\p{Script=Devanagari}&lt;/td&gt;
&lt;td&gt;Devanagari&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Dupl}&lt;/td&gt;
&lt;td&gt;\p{Script=Duployan}&lt;/td&gt;
&lt;td&gt;Duployan&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Egyp}&lt;/td&gt;
&lt;td&gt;\p{Script=Egyptian_Hieroglyphs}&lt;/td&gt;
&lt;td&gt;Egyptian Hieroglyphs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Elba}&lt;/td&gt;
&lt;td&gt;\p{Script=Elbasan}&lt;/td&gt;
&lt;td&gt;Elbasan&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Ethi}&lt;/td&gt;
&lt;td&gt;\p{Script=Ethiopic}&lt;/td&gt;
&lt;td&gt;Ethiopic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Geor}&lt;/td&gt;
&lt;td&gt;\p{Script=Georgian}&lt;/td&gt;
&lt;td&gt;Georgian&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Glag}&lt;/td&gt;
&lt;td&gt;\p{Script=Glagolitic}&lt;/td&gt;
&lt;td&gt;Glagolitic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Goth}&lt;/td&gt;
&lt;td&gt;\p{Script=Gothic}&lt;/td&gt;
&lt;td&gt;Gothic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Gran}&lt;/td&gt;
&lt;td&gt;\p{Script=Grantha}&lt;/td&gt;
&lt;td&gt;Grantha&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Grek}&lt;/td&gt;
&lt;td&gt;\p{Script=Greek}&lt;/td&gt;
&lt;td&gt;Greek&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Gujr}&lt;/td&gt;
&lt;td&gt;\p{Script=Gujarati}&lt;/td&gt;
&lt;td&gt;Gujarati&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Guru}&lt;/td&gt;
&lt;td&gt;\p{Script=Gurmukhi}&lt;/td&gt;
&lt;td&gt;Gurmukhi&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Hani}&lt;/td&gt;
&lt;td&gt;\p{Script=Han}&lt;/td&gt;
&lt;td&gt;Han&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Hang}&lt;/td&gt;
&lt;td&gt;\p{Script=Hangul}&lt;/td&gt;
&lt;td&gt;Hangul&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Hano}&lt;/td&gt;
&lt;td&gt;\p{Script=Hanunoo}&lt;/td&gt;
&lt;td&gt;Hanunoo&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Hatr}&lt;/td&gt;
&lt;td&gt;\p{Script=Hatran}&lt;/td&gt;
&lt;td&gt;Hatran&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Hebr}&lt;/td&gt;
&lt;td&gt;\p{Script=Hebrew}&lt;/td&gt;
&lt;td&gt;Hebrew&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Hira}&lt;/td&gt;
&lt;td&gt;\p{Script=Hiragana}&lt;/td&gt;
&lt;td&gt;Hiragana&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Armi}&lt;/td&gt;
&lt;td&gt;\p{Script=Imperial_Aramaic}&lt;/td&gt;
&lt;td&gt;Imperial Aramaic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Zinh}&lt;/td&gt;
&lt;td&gt;\p{Script=Inherited}&lt;/td&gt;
&lt;td&gt;Inherited&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Qaai}&lt;/td&gt;
&lt;td&gt;\p{Script=Inherited}&lt;/td&gt;
&lt;td&gt;Inherited&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Phli}&lt;/td&gt;
&lt;td&gt;\p{Script=Inscriptional_Pahlavi}&lt;/td&gt;
&lt;td&gt;Inscriptional Pahlavi&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Prti}&lt;/td&gt;
&lt;td&gt;\p{Script=Inscriptional_Parthian}&lt;/td&gt;
&lt;td&gt;Inscriptional Parthian&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Java}&lt;/td&gt;
&lt;td&gt;\p{Script=Javanese}&lt;/td&gt;
&lt;td&gt;Javanese&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Kthi}&lt;/td&gt;
&lt;td&gt;\p{Script=Kaithi}&lt;/td&gt;
&lt;td&gt;Kaithi&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Knda}&lt;/td&gt;
&lt;td&gt;\p{Script=Kannada}&lt;/td&gt;
&lt;td&gt;Kannada&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Kana}&lt;/td&gt;
&lt;td&gt;\p{Script=Katakana}&lt;/td&gt;
&lt;td&gt;Katakana&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Kali}&lt;/td&gt;
&lt;td&gt;\p{Script=Kayah_Li}&lt;/td&gt;
&lt;td&gt;Kayah Li&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Khar}&lt;/td&gt;
&lt;td&gt;\p{Script=Kharoshthi}&lt;/td&gt;
&lt;td&gt;Kharoshthi&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Khmr}&lt;/td&gt;
&lt;td&gt;\p{Script=Khmer}&lt;/td&gt;
&lt;td&gt;Khmer&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Khoj}&lt;/td&gt;
&lt;td&gt;\p{Script=Khojki}&lt;/td&gt;
&lt;td&gt;Khojki&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Sind}&lt;/td&gt;
&lt;td&gt;\p{Script=Khudawadi}&lt;/td&gt;
&lt;td&gt;Khudawadi&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Laoo}&lt;/td&gt;
&lt;td&gt;\p{Script=Lao}&lt;/td&gt;
&lt;td&gt;Lao&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Latn}&lt;/td&gt;
&lt;td&gt;\p{Script=Latin}&lt;/td&gt;
&lt;td&gt;Latin&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Lepc}&lt;/td&gt;
&lt;td&gt;\p{Script=Lepcha}&lt;/td&gt;
&lt;td&gt;Lepcha&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Limb}&lt;/td&gt;
&lt;td&gt;\p{Script=Limbu}&lt;/td&gt;
&lt;td&gt;Limbu&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Lina}&lt;/td&gt;
&lt;td&gt;\p{Script=Linear_A}&lt;/td&gt;
&lt;td&gt;Linear A&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Linb}&lt;/td&gt;
&lt;td&gt;\p{Script=Linear_B}&lt;/td&gt;
&lt;td&gt;Linear B&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Lisu}&lt;/td&gt;
&lt;td&gt;\p{Script=Lisu}&lt;/td&gt;
&lt;td&gt;Lisu&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Lyci}&lt;/td&gt;
&lt;td&gt;\p{Script=Lycian}&lt;/td&gt;
&lt;td&gt;Lycian&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Lydi}&lt;/td&gt;
&lt;td&gt;\p{Script=Lydian}&lt;/td&gt;
&lt;td&gt;Lydian&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Mahj}&lt;/td&gt;
&lt;td&gt;\p{Script=Mahajani}&lt;/td&gt;
&lt;td&gt;Mahajani&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Mlym}&lt;/td&gt;
&lt;td&gt;\p{Script=Malayalam}&lt;/td&gt;
&lt;td&gt;Malayalam&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Mand}&lt;/td&gt;
&lt;td&gt;\p{Script=Mandaic}&lt;/td&gt;
&lt;td&gt;Mandaic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Mani}&lt;/td&gt;
&lt;td&gt;\p{Script=Manichaean}&lt;/td&gt;
&lt;td&gt;Manichaean&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Marc}&lt;/td&gt;
&lt;td&gt;\p{Script=Marchen}&lt;/td&gt;
&lt;td&gt;Marchen&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Gonm}&lt;/td&gt;
&lt;td&gt;\p{Script=Masaram_Gondi}&lt;/td&gt;
&lt;td&gt;Masaram Gondi&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Mtei}&lt;/td&gt;
&lt;td&gt;\p{Script=Meetei_Mayek}&lt;/td&gt;
&lt;td&gt;Meetei Mayek&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Mend}&lt;/td&gt;
&lt;td&gt;\p{Script=Mende_Kikakui}&lt;/td&gt;
&lt;td&gt;Mende Kikakui&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Merc}&lt;/td&gt;
&lt;td&gt;\p{Script=Meroitic_Cursive}&lt;/td&gt;
&lt;td&gt;Meroitic Cursive&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Mero}&lt;/td&gt;
&lt;td&gt;\p{Script=Meroitic_Hieroglyphs}&lt;/td&gt;
&lt;td&gt;Meroitic Hieroglyphs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Plrd}&lt;/td&gt;
&lt;td&gt;\p{Script=Miao}&lt;/td&gt;
&lt;td&gt;Miao&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Modi}&lt;/td&gt;
&lt;td&gt;\p{Script=Modi}&lt;/td&gt;
&lt;td&gt;Modi&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Mong}&lt;/td&gt;
&lt;td&gt;\p{Script=Mongolian}&lt;/td&gt;
&lt;td&gt;Mongolian&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Mroo}&lt;/td&gt;
&lt;td&gt;\p{Script=Mro}&lt;/td&gt;
&lt;td&gt;Mro&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Mult}&lt;/td&gt;
&lt;td&gt;\p{Script=Multani}&lt;/td&gt;
&lt;td&gt;Multani&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Mymr}&lt;/td&gt;
&lt;td&gt;\p{Script=Myanmar}&lt;/td&gt;
&lt;td&gt;Myanmar&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Nbat}&lt;/td&gt;
&lt;td&gt;\p{Script=Nabataean}&lt;/td&gt;
&lt;td&gt;Nabataean&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Talu}&lt;/td&gt;
&lt;td&gt;\p{Script=New_Tai_Lue}&lt;/td&gt;
&lt;td&gt;New Tai Lue&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Newa}&lt;/td&gt;
&lt;td&gt;\p{Script=Newa}&lt;/td&gt;
&lt;td&gt;Newa&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Nkoo}&lt;/td&gt;
&lt;td&gt;\p{Script=Nko}&lt;/td&gt;
&lt;td&gt;Nko&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Nshu}&lt;/td&gt;
&lt;td&gt;\p{Script=Nushu}&lt;/td&gt;
&lt;td&gt;Nushu&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Ogam}&lt;/td&gt;
&lt;td&gt;\p{Script=Ogham}&lt;/td&gt;
&lt;td&gt;Ogham&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Olck}&lt;/td&gt;
&lt;td&gt;\p{Script=Ol_Chiki}&lt;/td&gt;
&lt;td&gt;Ol Chiki&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Hung}&lt;/td&gt;
&lt;td&gt;\p{Script=Old_Hungarian}&lt;/td&gt;
&lt;td&gt;Old Hungarian&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Ital}&lt;/td&gt;
&lt;td&gt;\p{Script=Old_Italic}&lt;/td&gt;
&lt;td&gt;Old Italic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Norb}&lt;/td&gt;
&lt;td&gt;\p{Script=Old_North_Arabian}&lt;/td&gt;
&lt;td&gt;Old North Arabian&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Perm}&lt;/td&gt;
&lt;td&gt;\p{Script=Old_Permic}&lt;/td&gt;
&lt;td&gt;Old Permic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Xpeo}&lt;/td&gt;
&lt;td&gt;\p{Script=Old_Persian}&lt;/td&gt;
&lt;td&gt;Old Persian&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Sarb}&lt;/td&gt;
&lt;td&gt;\p{Script=Old_South_Arabian}&lt;/td&gt;
&lt;td&gt;Old South Arabian&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Orkh}&lt;/td&gt;
&lt;td&gt;\p{Script=Old_Turkic}&lt;/td&gt;
&lt;td&gt;Old Turkic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Orya}&lt;/td&gt;
&lt;td&gt;\p{Script=Oriya}&lt;/td&gt;
&lt;td&gt;Oriya&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Osge}&lt;/td&gt;
&lt;td&gt;\p{Script=Osage}&lt;/td&gt;
&lt;td&gt;Osage&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Osma}&lt;/td&gt;
&lt;td&gt;\p{Script=Osmanya}&lt;/td&gt;
&lt;td&gt;Osmanya&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Hmng}&lt;/td&gt;
&lt;td&gt;\p{Script=Pahawh_Hmong}&lt;/td&gt;
&lt;td&gt;Pahawh Hmong&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Palm}&lt;/td&gt;
&lt;td&gt;\p{Script=Palmyrene}&lt;/td&gt;
&lt;td&gt;Palmyrene&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Pauc}&lt;/td&gt;
&lt;td&gt;\p{Script=Pau_Cin_Hau}&lt;/td&gt;
&lt;td&gt;Pau Cin Hau&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Phag}&lt;/td&gt;
&lt;td&gt;\p{Script=Phags_Pa}&lt;/td&gt;
&lt;td&gt;Phags Pa&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Phnx}&lt;/td&gt;
&lt;td&gt;\p{Script=Phoenician}&lt;/td&gt;
&lt;td&gt;Phoenician&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Phlp}&lt;/td&gt;
&lt;td&gt;\p{Script=Psalter_Pahlavi}&lt;/td&gt;
&lt;td&gt;Psalter Pahlavi&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Rjng}&lt;/td&gt;
&lt;td&gt;\p{Script=Rejang}&lt;/td&gt;
&lt;td&gt;Rejang&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Runr}&lt;/td&gt;
&lt;td&gt;\p{Script=Runic}&lt;/td&gt;
&lt;td&gt;Runic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Samr}&lt;/td&gt;
&lt;td&gt;\p{Script=Samaritan}&lt;/td&gt;
&lt;td&gt;Samaritan&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Saur}&lt;/td&gt;
&lt;td&gt;\p{Script=Saurashtra}&lt;/td&gt;
&lt;td&gt;Saurashtra&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Shrd}&lt;/td&gt;
&lt;td&gt;\p{Script=Sharada}&lt;/td&gt;
&lt;td&gt;Sharada&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Shaw}&lt;/td&gt;
&lt;td&gt;\p{Script=Shavian}&lt;/td&gt;
&lt;td&gt;Shavian&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Sidd}&lt;/td&gt;
&lt;td&gt;\p{Script=Siddham}&lt;/td&gt;
&lt;td&gt;Siddham&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Sgnw}&lt;/td&gt;
&lt;td&gt;\p{Script=SignWriting}&lt;/td&gt;
&lt;td&gt;SignWriting&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Sinh}&lt;/td&gt;
&lt;td&gt;\p{Script=Sinhala}&lt;/td&gt;
&lt;td&gt;Sinhala&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Sora}&lt;/td&gt;
&lt;td&gt;\p{Script=Sora_Sompeng}&lt;/td&gt;
&lt;td&gt;Sora Sompeng&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Soyo}&lt;/td&gt;
&lt;td&gt;\p{Script=Soyombo}&lt;/td&gt;
&lt;td&gt;Soyombo&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Sund}&lt;/td&gt;
&lt;td&gt;\p{Script=Sundanese}&lt;/td&gt;
&lt;td&gt;Sundanese&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Sylo}&lt;/td&gt;
&lt;td&gt;\p{Script=Syloti_Nagri}&lt;/td&gt;
&lt;td&gt;Syloti Nagri&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Syrc}&lt;/td&gt;
&lt;td&gt;\p{Script=Syriac}&lt;/td&gt;
&lt;td&gt;Syriac&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Tglg}&lt;/td&gt;
&lt;td&gt;\p{Script=Tagalog}&lt;/td&gt;
&lt;td&gt;Tagalog&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Tagb}&lt;/td&gt;
&lt;td&gt;\p{Script=Tagbanwa}&lt;/td&gt;
&lt;td&gt;Tagbanwa&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Tale}&lt;/td&gt;
&lt;td&gt;\p{Script=Tai_Le}&lt;/td&gt;
&lt;td&gt;Tai Le&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Lana}&lt;/td&gt;
&lt;td&gt;\p{Script=Tai_Tham}&lt;/td&gt;
&lt;td&gt;Thai Tham&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Tavt}&lt;/td&gt;
&lt;td&gt;\p{Script=Tai_Viet}&lt;/td&gt;
&lt;td&gt;Tia Viet&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Takr}&lt;/td&gt;
&lt;td&gt;\p{Script=Takri}&lt;/td&gt;
&lt;td&gt;Takri&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Taml}&lt;/td&gt;
&lt;td&gt;\p{Script=Tamil}&lt;/td&gt;
&lt;td&gt;Tamil&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Tang}&lt;/td&gt;
&lt;td&gt;\p{Script=Tangut}&lt;/td&gt;
&lt;td&gt;Tangut&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Telu}&lt;/td&gt;
&lt;td&gt;\p{Script=Telugu}&lt;/td&gt;
&lt;td&gt;Telugu&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Thaa}&lt;/td&gt;
&lt;td&gt;\p{Script=Thaana}&lt;/td&gt;
&lt;td&gt;Thaana&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Thai}&lt;/td&gt;
&lt;td&gt;\p{Script=Thai}&lt;/td&gt;
&lt;td&gt;Thai&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Tibt}&lt;/td&gt;
&lt;td&gt;\p{Script=Tibetan}&lt;/td&gt;
&lt;td&gt;Tibetan&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Tfng}&lt;/td&gt;
&lt;td&gt;\p{Script=Tifinagh}&lt;/td&gt;
&lt;td&gt;Tifinagh&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Tirh}&lt;/td&gt;
&lt;td&gt;\p{Script=Tirhuta}&lt;/td&gt;
&lt;td&gt;Tirhuta&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Ugar}&lt;/td&gt;
&lt;td&gt;\p{Script=Ugaritic}&lt;/td&gt;
&lt;td&gt;Ugaritic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Vaii}&lt;/td&gt;
&lt;td&gt;\p{Script=Vai}&lt;/td&gt;
&lt;td&gt;Vai&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Wara}&lt;/td&gt;
&lt;td&gt;\p{Script=Warang_Citi}&lt;/td&gt;
&lt;td&gt;Warang Citi&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Yiii}&lt;/td&gt;
&lt;td&gt;\p{Script=Yi}&lt;/td&gt;
&lt;td&gt;Yi&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;\p{Script=Zanb}&lt;/td&gt;
&lt;td&gt;\p{Script=Zanzabar_Square}&lt;/td&gt;
&lt;td&gt;Zanzabar Square&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;So if you find yourself in a situation where you need to format data and you &lt;em&gt;really&lt;/em&gt; don't want to manually go through the repetitive work involved.... look for patterns, embrace the regex, and save yourself some time.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>regex</category>
    </item>
    <item>
      <title>SingleNumber Solution in O(n) Time Without Extra Storage</title>
      <dc:creator>Amy Shackles</dc:creator>
      <pubDate>Thu, 24 Sep 2020 19:21:09 +0000</pubDate>
      <link>https://dev.to/amyshackles/singlenumber-solution-in-o-n-time-without-extra-storage-4b9e</link>
      <guid>https://dev.to/amyshackles/singlenumber-solution-in-o-n-time-without-extra-storage-4b9e</guid>
      <description>&lt;h2&gt;
  
  
  Problem Statement
&lt;/h2&gt;

&lt;p&gt;Given a non-empty array of integers, every element appears twice except for one.  Find that single one.  Note: Your algorithm should have a linear runtime complexity.  Could you implement it without extra memory?&lt;/p&gt;

&lt;h2&gt;
  
  
  Thought Process
&lt;/h2&gt;

&lt;p&gt;My initial conclusion was that no, you couldn't.  Since there's not a range for the possible numbers in the array and the array isn't already sorted, you can solve in linear time if you used an object to store counts, but you need that extra storage or sorting is O(n log n).&lt;/p&gt;

&lt;p&gt;But see, I forgot about XOR (^).  For those of you who don't play with bits, exclusive or takes two binary numbers and for pair where one number has the bit flipped and the other doesn't, the resulting number has the bit flipped.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  01101
^ 10110
= 11011
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So if you have a number and XOR it by 0, you get the number.  If you have a number and XOR it by itself, you get 0.  &lt;/p&gt;

&lt;p&gt;Now, that's helpful, but why would you care about XOR for this problem?&lt;/p&gt;

&lt;p&gt;Let's run through an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;input:  [4,1,1,2,2,4,5,1,2,1,2]
4^1=5
5^1=4
4^2=6
6^2=4
4^4=0
0^5=5
5^1=4
4^2=6
6^1=7
7^2=5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Explanation/Solution
&lt;/h2&gt;

&lt;p&gt;Because all of the values that appear twice will eventually cancel themselves out, you're left with that one solitary element that has no partner.  No extra storage necessary.  Linear time.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;singleNumber&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;^&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>xor</category>
      <category>leetcode</category>
    </item>
    <item>
      <title>Array Manipulation JavaScript Solution</title>
      <dc:creator>Amy Shackles</dc:creator>
      <pubDate>Mon, 21 Sep 2020 01:06:28 +0000</pubDate>
      <link>https://dev.to/amyshackles/array-manipulation-javascript-solution-58bj</link>
      <guid>https://dev.to/amyshackles/array-manipulation-javascript-solution-58bj</guid>
      <description>&lt;h2&gt;
  
  
  Problem Statement
&lt;/h2&gt;

&lt;p&gt;Starting with a 1-indexed array of zeros and a list of operations, for each operation add a value to each of the array elements between two given indices, inclusive.  Once all operations have been performed, return the maximum value in the array.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;p&gt;The function you are writing takes two arguments.  The first argument, &lt;em&gt;n&lt;/em&gt;, represents the number of elements in the array you are performing operations on.  The second argument, &lt;em&gt;queries&lt;/em&gt; is an array of operations to perform on the array.  Each element in &lt;em&gt;queries&lt;/em&gt; is an array consisting of a starting index, ending index, and the value to be added to the elements in your array between those starting and ending indices.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;queries&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
&lt;span class="c1"&gt;// Start, end, value to add&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="cm"&gt;/*
 1   2   3   4   5   6   7   8   9   10  11  12 // Indices
*/&lt;/span&gt;
&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;// Starting array&lt;/span&gt;
&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;// After queries[0]&lt;/span&gt;
&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;// After queries[1]&lt;/span&gt;
&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;14&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;14&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;// After queries[2]&lt;/span&gt;

&lt;span class="nx"&gt;largest&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Naive Approach (Brute Force)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Create an array with length of n + 1&lt;/li&gt;
&lt;li&gt;Initialize each element in the array with 0&lt;/li&gt;
&lt;li&gt;Create a variable to store the maximum value encountered, initialized to 0&lt;/li&gt;
&lt;li&gt;Iterate through queries array, separating out a, b, k&lt;/li&gt;
&lt;li&gt;Loop through the array from index a through b, incrementing each element at that index by k&lt;/li&gt;
&lt;li&gt;If the updated value of the array at the current index is greater than the max, update max
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;arrayManipulation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;queries&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;fill&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;max&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;queries&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(([&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;k&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;k&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;max&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nx"&gt;max&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;max&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, this works for some input.  But think about what happens when n is a large number.  Think about what happens if queries is a large array.  In each operation in queries, you're updating 1-n elements in the array.  That's a &lt;em&gt;lot&lt;/em&gt; of operations to be performing.  So some of the tests on HackerRank for this particular problem time out if you have a function like this as a solution.  Their input is just too large to get away with using this algorithm.  Womp womp.  Sad trombone.&lt;/p&gt;

&lt;p&gt;But you know what?  There's no shame in not knowing how to solve this problem.  It's marked as hard and it &lt;em&gt;is&lt;/em&gt; hard.  I had to look up solutions in the Discussion section to grok how one would even approach solving this problem at scale.  And then I needed to take out a piece of paper and a pen to work through a few problems to understand how the provided solution worked.  This is one of those solutions that once you understand it, it seems obvious.  And it's beautiful.  Naturally, the solutions I found were all in either C++ or Java and that's not my language of choice for code challenges, so I adapted it into JavaScript to both ensure that I understood it and to make it easier for anyone looking to solve it in JavaScript.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;
  SPOILERS!
  &lt;br&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;arrayManipulation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;queries&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;fill&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;queries&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(([&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;k&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;k&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="nx"&gt;k&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;max&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;val&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nx"&gt;max&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;max&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;max&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Let's go through how this works using the earlier example.  Note that the reason we're changing the value at arr[a - 1] is because the problem statement indicated that the arrays are 1-indexed, so the array indices given are going to be off by 1 since arrays in JavaScript are 0-indexed.  The reason we change arr[b] and not arr[b-1] is that the operations are meant to be from a to b inclusive and so we want to add the end point as being after the last index operated on.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;queries&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
&lt;span class="c1"&gt;// Start, end, value to add&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="cm"&gt;/*
 1   2   3   4   5   6   7   8  9  10 11  12  13 // Indices
*/&lt;/span&gt;
 &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;// Starting array&lt;/span&gt;
 &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;// After [2,7,4]&lt;/span&gt;
 &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;// After [5,9,2]&lt;/span&gt;
 &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;// After [6,12,8]&lt;/span&gt;

&lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;max&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// sum stays 0, max stays 0&lt;/span&gt;
&lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// sum is now 4, sum &amp;gt; max, so max becomes 4&lt;/span&gt;
&lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// sum stays same, max stays same&lt;/span&gt;
&lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// sum stays same, max stays same&lt;/span&gt;
&lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// sum is now 6; sum &amp;gt; max, so max becomes 6;&lt;/span&gt;
&lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// sum is now 14; sum &amp;gt; max, so max becomes 14;&lt;/span&gt;
&lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// sum stays same, max stays same&lt;/span&gt;
&lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// sum is 10; max &amp;gt; sum, so max stays 14;&lt;/span&gt;
&lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// sum stays same, max stays same&lt;/span&gt;
&lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// sum is 8; max &amp;gt; sum, so max stays 14;&lt;/span&gt;
&lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// sum stays same, max stays same&lt;/span&gt;
&lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// sum stays same, max stays same&lt;/span&gt;
&lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// sum is 0; max &amp;gt; sum, so stays 14;&lt;/span&gt;

&lt;span class="nx"&gt;max&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;14&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How does this work?  Well, because we're subtracting the value of &lt;em&gt;k&lt;/em&gt; at the index following the end index, we're only adding the value of a given &lt;em&gt;k&lt;/em&gt; for the indices we should have added that &lt;em&gt;k&lt;/em&gt; to.  And because we're only changing the values in the array to mark the beginning and end of operations, we're only performing 2 updates for each query.  We've changed a variable operation with a worst case complexity of &lt;em&gt;n&lt;/em&gt; to be constant!  Not too shabby.&lt;br&gt;
&lt;/p&gt;

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




&lt;p&gt;Problem taken from &lt;a href="https://www.hackerrank.com/challenges/crush/problem"&gt;HackerRank&lt;/a&gt; &lt;/p&gt;

</description>
      <category>hackerrank</category>
      <category>arrays</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Homebrew Basics</title>
      <dc:creator>Amy Shackles</dc:creator>
      <pubDate>Mon, 14 Sep 2020 19:22:01 +0000</pubDate>
      <link>https://dev.to/amyshackles/homebrew-basics-2eoi</link>
      <guid>https://dev.to/amyshackles/homebrew-basics-2eoi</guid>
      <description>&lt;h2&gt;
  
  
  Homebrew Terminology
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Formula&lt;/strong&gt;: A package definition written in Ruby&lt;br&gt;
&lt;strong&gt;Keg&lt;/strong&gt;: Installation prefix of a formula (e.g., /usr/local/Cellar/pipenv)&lt;br&gt;
&lt;strong&gt;Keg-only dependency&lt;/strong&gt;: Dependency that isn't symlinked to places like /usr/local&lt;br&gt;
&lt;strong&gt;Cask&lt;/strong&gt;: An extension of Homebrew to install MacOS native apps (e.g., Atom and Google Chrome)&lt;br&gt;
&lt;strong&gt;Cellar&lt;/strong&gt;: Where kegs are installed (/usr/local/Cellar)&lt;br&gt;
&lt;strong&gt;Bottle&lt;/strong&gt;: A pre-built keg (rather than one built from source)&lt;br&gt;
&lt;strong&gt;Tap&lt;/strong&gt;: A git repository.  To tap a repository is to make a shallow clone of it.&lt;br&gt;
&lt;strong&gt;Brew bundle&lt;/strong&gt;: An extension of Homebrew to describe dependencies&lt;/p&gt;
&lt;h2&gt;
  
  
  Essential commands
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install&lt;/span&gt; &amp;lt;formula name&amp;gt; &lt;span class="c"&gt;# Installs a package&lt;/span&gt;

brew uninstall &amp;lt;formula name&amp;gt; &lt;span class="c"&gt;# Uninstalls a package&lt;/span&gt;

brew list &lt;span class="c"&gt;# Lists all installed packages&lt;/span&gt;

brew search &lt;span class="c"&gt;# Lists all locally available packages&lt;/span&gt;

brew search &amp;lt;text&amp;gt; &lt;span class="c"&gt;# Searches online in homebrew/core and&lt;/span&gt;
&lt;span class="c"&gt;# homebrew/cask&lt;/span&gt;

brew search /&amp;lt;text&amp;gt;/ &lt;span class="c"&gt;# Search term is interpreted as a &lt;/span&gt;
&lt;span class="c"&gt;# regular expression if bookended by slashes.  Searches &lt;/span&gt;
&lt;span class="c"&gt;# online in homebrew/core and homebrew/cask&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Useful commands
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew commands &lt;span class="c"&gt;# Lists all built-in and external commands known&lt;/span&gt;
&lt;span class="c"&gt;# to homebrew.  Returns with subheadings for:&lt;/span&gt;
&lt;span class="c"&gt;# "Built-in commands", "Built-in developer commands",&lt;/span&gt;
&lt;span class="c"&gt;# "External commands", "Cask commands", and&lt;/span&gt;
&lt;span class="c"&gt;# "external cask commands".&lt;/span&gt;

brew cleanup &lt;span class="c"&gt;# Removes old lock files and outdated downloads&lt;/span&gt;
&lt;span class="c"&gt;# for formulae and casks, removing old versions&lt;/span&gt;

brew doctor &lt;span class="c"&gt;# Checks system for potential problems&lt;/span&gt;

brew log &lt;span class="c"&gt;# Shows git log for the Homebrew repository&lt;/span&gt;

brew log &amp;lt;formula name&amp;gt; &lt;span class="c"&gt;# Shows git log for formula&lt;/span&gt;

brew update &lt;span class="c"&gt;# Fetches newest version of Homebrew and all&lt;/span&gt;
&lt;span class="c"&gt;# formula from Github and performs necessary migrations&lt;/span&gt;

brew upgrade &lt;span class="c"&gt;# Upgrade outdated casks and formula using the&lt;/span&gt;
&lt;span class="c"&gt;# same options they were installed with&lt;/span&gt;

brew upgrade &amp;lt;formula name|cask name&amp;gt; &lt;span class="c"&gt;# Upgrade formula|cask&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Managing Background Services
&lt;/h2&gt;

&lt;p&gt;Brew services manage background services using the macOS &lt;em&gt;launchctl&lt;/em&gt; daemon manager&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew services run &amp;lt;formula name&amp;gt; &lt;span class="c"&gt;# Run the service without&lt;/span&gt;
&lt;span class="c"&gt;# registering to launch it at login (or boot)&lt;/span&gt;

brew services run &lt;span class="nt"&gt;--all&lt;/span&gt; &lt;span class="c"&gt;# Run all services without registering&lt;/span&gt;
&lt;span class="c"&gt;# to launch them at login/boot&lt;/span&gt;

brew services start &amp;lt;formula name&amp;gt; &lt;span class="c"&gt;# Immediately start the&lt;/span&gt;
&lt;span class="c"&gt;# service and register it to launch at login (or boot)&lt;/span&gt;

brew services start &lt;span class="nt"&gt;--all&lt;/span&gt; &lt;span class="c"&gt;# Immediately start all services&lt;/span&gt;
&lt;span class="c"&gt;# and register them to launch at login/boot&lt;/span&gt;

brew services stop &amp;lt;formula name&amp;gt; &lt;span class="c"&gt;# Immediately stop the&lt;/span&gt;
&lt;span class="c"&gt;# service and unregister it from launching at login (or boot)&lt;/span&gt;

brew services stop &lt;span class="nt"&gt;--all&lt;/span&gt; &lt;span class="c"&gt;# Immediately stop all services&lt;/span&gt;
&lt;span class="c"&gt;# and register unregister them from launching at login/boot&lt;/span&gt;

brew services restart &amp;lt;formula name&amp;gt; &lt;span class="c"&gt;# Stop (if necessary) and&lt;/span&gt;
&lt;span class="c"&gt;# start the service immediately, registering to launch at&lt;/span&gt;
&lt;span class="c"&gt;# login (or boot)&lt;/span&gt;

brew services restart &lt;span class="nt"&gt;--all&lt;/span&gt; &lt;span class="c"&gt;# Stop (if necessary) all services&lt;/span&gt;
&lt;span class="c"&gt;# and start them immediately, registering to launch them at &lt;/span&gt;
&lt;span class="c"&gt;# login/boot&lt;/span&gt;

brew services cleanup &lt;span class="c"&gt;# Remove all unused services&lt;/span&gt;

brew services &lt;span class="c"&gt;# Lists all managed services and whether they &lt;/span&gt;
&lt;span class="c"&gt;# are stopped or started&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;References:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.brew.sh/Manpage"&gt;Homebrew Manpage&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.brew.sh/Formula-Cookbook#homebrew-terminology"&gt;Homebrew Terminology&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>macos</category>
      <category>homebrew</category>
      <category>brew</category>
    </item>
    <item>
      <title>Trust, But Verify (Downloads)</title>
      <dc:creator>Amy Shackles</dc:creator>
      <pubDate>Mon, 13 Jul 2020 20:43:53 +0000</pubDate>
      <link>https://dev.to/amyshackles/verify-the-checksum-of-a-downloaded-file-on-mac-4c7d</link>
      <guid>https://dev.to/amyshackles/verify-the-checksum-of-a-downloaded-file-on-mac-4c7d</guid>
      <description>&lt;p&gt;Have you ever downloaded something from the internet and noticed that the site you're downloading from has a message about verifying the integrity of the downloaded package?  Have you ever been curious how to go about doing that, so clicked the link, only to see a jumble of text displayed?  Believe me, I know the feeling.&lt;/p&gt;

&lt;p&gt;While the task of acquiring the SHA256 value of a downloaded file is easy to figure out (there are plenty of resources online on how to do that), most of the examples out there seem to only go that far, relying on your ability to spot the difference visually between the two outputs.&lt;/p&gt;

&lt;p&gt;My friends, there is a better way.&lt;/p&gt;

&lt;h4&gt;
  
  
  Option 1: Echo!
&lt;/h4&gt;

&lt;p&gt;1) After downloading the package you want to verify, make a note of where that file is.  If it makes it easier, &lt;code&gt;cd&lt;/code&gt; into the containing folder so that you don't need to specify the path to it.&lt;br&gt;
2) Copy the SHA256 value from the download site that corresponds with the package you downloaded (that's going to be all the letters/numbers before the spaces and the file name)&lt;br&gt;
3) In your terminal shell, type the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;Copied&lt;/span&gt;&lt;span class="p"&gt; 256 Value&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;  /path/to/downloaded/file"&lt;/span&gt; | shasum &lt;span class="nt"&gt;-a&lt;/span&gt; 256 &lt;span class="nt"&gt;-c&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's break that down.&lt;br&gt;&lt;br&gt;
The echo command will write the copied value to standard out.  The quotation marks ensures that the whitespace is maintained... the two spaces between the SHA256 and the filepath is important.  From the man page for &lt;code&gt;shasum&lt;/code&gt;, the second space character is for specifying that the type should be text.  It should be noted that in lieu of a space character, you could also set the mode to binary and provide the mode character '*'&lt;br&gt;
The | (pipe character) passes the output (stdout) of the previous command to the input (stdin) of the next, so now the &lt;code&gt;shasum&lt;/code&gt; command has the values we just passed to stdout&lt;br&gt;
The -a flag is shorthand for -algorithm and tells &lt;code&gt;shasum&lt;/code&gt; which type of SHA to calculate.  In this example, we're working with SHA256, so we pass 256 to the -a flag.&lt;br&gt;
The -c flag is shorthand for --check&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"ef0ca4924922514b6ad71469998821f2cf7c596b4b8b59736c3699759e0f1df8  Downloads/VirtualBox-6.1.10-138449-OSX.dmg"&lt;/span&gt; | shasum &lt;span class="nt"&gt;-a&lt;/span&gt; 256 &lt;span class="nt"&gt;-c&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Option 2: Why Echo When You Can Redirect?
&lt;/h4&gt;

&lt;p&gt;1) After downloading the package you want to verify, make a note of where that file is.  If it makes it easier, &lt;code&gt;cd&lt;/code&gt; into the containing folder so that you don't need to specify the path to it.&lt;br&gt;
2) Copy the SHA256 value from the download site that corresponds with the package you downloaded (that's going to be all the letters/numbers before the spaces and the file name)&lt;br&gt;
3) In your terminal shell, type the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;shasum &lt;span class="nt"&gt;-a&lt;/span&gt; 256 &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;Copied&lt;/span&gt;&lt;span class="p"&gt; SHA256 value&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;  /path/toDownload"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;shasum &lt;span class="nt"&gt;-a&lt;/span&gt; 256 &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s2"&gt;"ef0ca4924922514b6ad71469998821f2cf7c596b4b8b59736c3699759e0f1df8 *Downloads/VirtualBox-6.1.10-138449-OSX.dmg"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Result
&lt;/h4&gt;

&lt;p&gt;Whichever option you choose, if your SHA256 values match, you should get a response like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Downloads/VirtualBox-6.1.10-138449-OSX.dmg: OK
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>checksum</category>
      <category>security</category>
      <category>mac</category>
      <category>sha256</category>
    </item>
    <item>
      <title>Breaking Down Project Euler #1: Multiples of 3 and 5</title>
      <dc:creator>Amy Shackles</dc:creator>
      <pubDate>Fri, 08 May 2020 00:11:02 +0000</pubDate>
      <link>https://dev.to/amyshackles/breaking-down-project-euler-1-multiples-of-3-and-5-14hg</link>
      <guid>https://dev.to/amyshackles/breaking-down-project-euler-1-multiples-of-3-and-5-14hg</guid>
      <description>&lt;p&gt;Greetings, friends.&lt;/p&gt;

&lt;p&gt;If you want to get to the meat of this post, click here&lt;/p&gt;

&lt;p&gt;As you may (or may not) know, I'm a currently unemployed software developer.  A currently unemployed workaholic of a software developer.  A currently unemployed workaholic of a software developer who did not spec into the mathematics skill tree.  &lt;/p&gt;

&lt;p&gt;For a long time, I lived with this mistaken belief that people were either &lt;em&gt;good&lt;/em&gt; at math or they were &lt;em&gt;not good&lt;/em&gt; at math, and I was &lt;em&gt;clearly&lt;/em&gt; a member of the latter group.  Until I was talking to one of my best friends, the smartest man I've ever met&lt;sup&gt;1&lt;/sup&gt;, about my terrible-at-math affliction.  &lt;/p&gt;

&lt;p&gt;Paraphrased version of the conversation:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"No one's good at math to start with." &lt;br&gt;
"But you're good at math!"&lt;br&gt;
".... because I went to a library every day and read everything I could about it.  And practiced.  A lot.  And asked a lot of questions.  I was &lt;em&gt;rubbish&lt;/em&gt; at math."&lt;br&gt;
"But you're an electrical engineer!"&lt;br&gt;
"Exactly.  If I can learn it, so can you.  You just have to want to."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;Damn it&lt;/em&gt;, I thought to myself.  &lt;em&gt;So this was exactly like that whole "no one's an amazing artist without practice" things.  I have no one to blame but myself&lt;/em&gt;.&lt;sup&gt;2&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;Why am I telling you this story?  Well, dear, patient reader, I'm a workaholic out of work.  I know that if I want to stop being a workaholic out of work, I should spec more into the whiteboarding skill tree.  While everyone's approach for leveling up on this skill tree is different, my general approach tends to be to try to solve a lot of problems on HackerRank/LeetCode/whatever other platform I happen to have open at the time.  Emphasis on try.  It would be lying to say that I struggle with every algorithmic question, because I have familiarity with quite a few now.  I've slain those dragons, they hold no power over me, I am &lt;em&gt;victorious&lt;/em&gt;.  But for others, I just ... can't.  For some problems, I can't even come up with a terrible solution to a problem.&lt;sup&gt;3&lt;/sup&gt;  For still others, I can come up with the naive approach for solving it, but inevitably some of the tests on whatever the platform is are smart enough to test for poorly performing code and will error out.  &lt;/p&gt;

&lt;p&gt;So what do I, a workaholic with a stubborn streak and a deep hatred of not understanding a problem, do?&lt;/p&gt;

&lt;p&gt;I look at solutions.  Sometimes, the solutions are straightforward and I feel like an idiot for not having thought of approaching it that way, before reminding myself that everything always seems easier with hindsight.  Other times, the solutions work, but I am confused either a) how or b) why.  And then I spend an embarrassing amount of time trying to figure out the how and why.&lt;/p&gt;

&lt;p&gt;Which brings us to this post!&lt;/p&gt;

&lt;h3&gt;
  
  
  Multiples of 3 and 5 &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.&lt;/p&gt;

&lt;p&gt;Find the sum of all the multiples of 3 or 5 below 1000.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The naive approach to this problem is fairly straightforward if you are familiar with the modulo operator, which gives you the remainder when one number is divided by another.  One approach might be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;initialize a variable &lt;em&gt;sum&lt;/em&gt; with the value of 0&lt;/li&gt;
&lt;li&gt;iterate from 3 to 999 (3 because you know 1 and 2 don't divide cleanly)&lt;/li&gt;
&lt;li&gt;if the number is divisible by 3 or 5, add that number to the sum&lt;/li&gt;
&lt;li&gt;return the sum&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

function sumOf3or5(num) {
    let sum = 0;
    for (let i = 3; i &amp;lt; num; i++) {
        if (i % 3 === 0 || i % 5 === 0) {
            sum += i;
        }
    }
    return sum;
}


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

&lt;/div&gt;

&lt;p&gt;But the tests were tricky.  They used values greater than Number.MAX_SAFE_INTEGER, which meant that when it came to mathematical operations on those numbers ... well, it didn't do well.  But more than that, because the numbers were so high, it also meant that this naive solution was not going to work&lt;sup&gt;4&lt;/sup&gt;.&lt;/p&gt;

&lt;p&gt;This was one of the times where I had to look at other people's solutions to come to an answer.  The solution I ended up with was:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

function sumOf3or5(num) {
/* 
    The test cases use numbers greater than Math.MAX_INTEGER, so we 
    need to use a data type that can handle larger numbers.  You could 
    pull in a library like bignumbers.js for this, but there's a new data 
    type in JavaScript for big numbers -- BigInt.   
*/
    num = BigInt(num);
/*
    We not only have to add the sum of multiples of 3 and 5 together, but 
    because 3 * 5 = 15, we need to make sure to subtract all the sums of 
    multiples of 15 in order to remove duplicates
*/
    return (
        BigInt(sumOfSequence(num - 1n, 3) 
        + sumOfSequence(num - 1n, 5)
        - sumOfSequence(num - 1n, 15)).toString()
        )
}

function sumOfSequence(num, multiple) {
    // find the number of times multiple can go into num
    let terms = num / BigInt(multiple);
    // Use Gauss's summation trick
    let sum = terms * (terms + 1n) / 2n;
    return BigInt(multiple) * sum;
}


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

&lt;/div&gt;

&lt;p&gt;First off, if you're not familiar with BigInt in JavaScript, that 'n' at the end of numbers is just to indicate that it's a BigInt type.  &lt;/p&gt;

&lt;p&gt;Second, I'm sure you're looking at that &lt;code&gt;n * (n + 1) / 2&lt;/code&gt; bit and going "...?"&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fysr6gvkaf3638c2320h8.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fysr6gvkaf3638c2320h8.png" alt="Gauss's Summation Trick"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;"I get that that's the way to sum numbers, but why are we using the number of times a multiple can go into the number for the formula?  And why are we multiplying by the multiple afterward?"&lt;/p&gt;

&lt;p&gt;Good question.&lt;/p&gt;

&lt;p&gt;Say that we're looking for the sum of multiples of 3s and 5s for numbers less than 10.&lt;/p&gt;

&lt;p&gt;To calculate the multiples of 3, we would be passing 9 and 3 to our sumOfSequence function.  That would mean that the 'n' we would be using for the summation would be 3 (9 / 3 = 3).  So what we're using Gauss's trick for is the summation of 1 to 3 (1 + 2 + 3) and then multiplying it by the multiple so that we get the &lt;em&gt;actual&lt;/em&gt; sum of the multiple.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

(1 + 2 + 3) * 3 = 18
3 + 6 + 9 = 18


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

&lt;/div&gt;

&lt;p&gt;If you made it all the way down here, thanks for reading.  I hope it helps you in some small way.  Let me know if you'd be interested in reading more content like this.  Honestly, feel free to reach out in general.  Be safe, be kind, take care!&lt;/p&gt;

&lt;p&gt;Every time I found myself leaning on my natural writing tendency of including an aside, I cut and pasted it down here into the footnotes.  &lt;/p&gt;




&lt;h5&gt;
  
  
  Footnotes &lt;a&gt;&lt;/a&gt;
&lt;/h5&gt;

&lt;p&gt;[1] Literally a genius, and not in the pretentious "I'm a member of MENSA and all should bow before me" way, more in the "you asked a good question, but you would have to understand three different levels above what you currently know to understand my answer to your question, so let me patiently explain to you how all of that stuff works so you know what I'm talking about" way.&lt;br&gt;
[2] Well, maybe my high school guidance counselor who convinced me to stop taking math because I would "never need it as a health and human sciences major".  &amp;gt;insert an eyebrow narrow right here&amp;lt; &lt;br&gt;
[3] Sometimes I &lt;em&gt;can&lt;/em&gt; come up with a terrible solution, but it is &lt;em&gt;so&lt;/em&gt; terrible that I wouldn't even admit to having come up with it.  I'm serious, it's bad.&lt;br&gt;
[4] It has to iterate through all of the numbers from 3 to the number passed in, so if the number is large, this is going to take a lot of time to execute.&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
