Syntactic SophistryTrue knowledge lies in knowing you can just look it up in the docs.
http://timothymeixell.com/
Thu, 26 Oct 2017 18:47:08 +0000Thu, 26 Oct 2017 18:47:08 +0000Jekyll v3.6.2Project Euler: Problem 1<h3 id="find-the-sum-of-all-the-multiples-of-3-or-5-below-1000">Find the sum of all the multiples of 3 or 5 below 1000</h3>
<p><a href="https://projecteuler.net/problem=1">problem on project euler site</a></p>
<p><a href="https://github.com/misternu/euler_solutions/tree/master/1">my solution on github</a></p>
<p>Let’s start with the intuitive solution to this problem. Loop over the range 1 to 999, and use a boolean statement to decide if you are going to add that integer to the sum.</p>
<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">def</span> <span class="nf">reduce_three_and_five</span><span class="p">(</span><span class="n">n</span><span class="p">)</span>
<span class="p">(</span><span class="mi">1</span><span class="o">...</span><span class="n">n</span><span class="p">).</span><span class="nf">reduce</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> <span class="p">{</span> <span class="o">|</span><span class="n">m</span><span class="p">,</span> <span class="n">n</span><span class="o">|</span> <span class="n">n</span> <span class="o">%</span> <span class="mi">3</span> <span class="o">==</span> <span class="mi">0</span> <span class="o">||</span> <span class="n">n</span> <span class="o">%</span> <span class="mi">5</span> <span class="o">==</span> <span class="mi">0</span> <span class="p">?</span> <span class="n">m</span> <span class="o">+</span> <span class="n">n</span> <span class="p">:</span> <span class="n">m</span> <span class="p">}</span>
<span class="k">end</span>
</code></pre></div></div>
<p>The above method takes the range from 1 to n and adds the integer to the sum if it is divisible by 3 or 5. Can you see why this might be wasteful? For just those numbers, it runs almost instantaneously, but what if we increase the range to 10,000,000?</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code> user system total real
1.160000 0.010000 1.170000 ( 1.163298)
</code></pre></div></div>
<p>Our runtime is increasing proportionally to the number of integers that we loop over. This is referred to as <strong>linear time</strong> or <strong>O(n)</strong>. If we find a way to calculate the answer without a loop, the time that it takes will not depend on the size of the loop. This is <strong>constant time</strong> or <strong>O(1)</strong>.</p>
<p>Let’s suppose that we only had to add the multiples of three up to 100. We know that</p>
<script type="math/tex; mode=display">3 + 6 + 9 + 12 + 15 ... 99</script>
<script type="math/tex; mode=display">= 3 \times (1 + 2 + 3 + 4 + 5 ... 33)</script>
<script type="math/tex; mode=display">= \sum_{n=1}^{33} 3n</script>
<script type="math/tex; mode=display">= 3 \times \sum_{n=1}^{33} n</script>
<p>The sum of a series of multiples of three is equal to 3 times the sum of an equally long integer sequence. It just so happens that we have a formula for the sum of sequential integers.</p>
<script type="math/tex; mode=display">\frac{n(n+1)}{2}</script>
<p>Where <script type="math/tex">n</script> is the number of integers to sum. We can use this to make a method that
will return this sum for us.</p>
<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">def</span> <span class="nf">integer_sum</span><span class="p">(</span><span class="n">n</span><span class="p">)</span>
<span class="n">n</span> <span class="o">*</span> <span class="p">(</span><span class="n">n</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> <span class="o">/</span> <span class="mi">2</span>
<span class="k">end</span>
</code></pre></div></div>
<p>We know from before that if we want the multiples of 3 up to 100, we would multiply 3 times the series of integers up to 33. This can be generalized to</p>
<script type="math/tex; mode=display">n \times f(m)</script>
<p>Where <script type="math/tex">n</script> is the number that the series is divisible by, and <script type="math/tex">m</script> is the maximum number in that series integer divided by <script type="math/tex">n</script>, and <script type="math/tex">f</script> is the formula from before. In ruby, this becomes</p>
<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">def</span> <span class="nf">multiples_sum</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="n">l</span><span class="p">)</span>
<span class="n">m</span> <span class="o">=</span> <span class="n">l</span><span class="o">/</span><span class="n">n</span>
<span class="n">n</span> <span class="o">*</span> <span class="n">integer_sum</span><span class="p">(</span><span class="n">m</span><span class="p">)</span>
<span class="k">end</span>
</code></pre></div></div>
<p>We now have a handy method that will give us the sum of multiples of <code class="highlighter-rouge">n</code> up to a maximum <code class="highlighter-rouge">l</code>, and in O(1) time. All that is left is to call this three times in our solution method:</p>
<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">def</span> <span class="nf">math_three_and_five</span><span class="p">(</span><span class="n">n</span><span class="p">)</span>
<span class="n">multiples_sum</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="n">n</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="o">+</span>
<span class="n">multiples_sum</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="n">n</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="o">-</span>
<span class="n">multiples_sum</span><span class="p">(</span><span class="mi">15</span><span class="p">,</span> <span class="n">n</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
<span class="k">end</span>
</code></pre></div></div>
<p>We add the multiples of three under a number to the multiples of five under a number. Since the multiples of three overlap the multiples of five, we subtract the multiples of fifteen that were duplicated. A quick test shows that this gets the same answer as our reduce method, but without iteration.</p>
Mon, 25 Sep 2017 00:00:00 +0000
http://timothymeixell.com/blog/programming/math/2017/09/25/project-euler-problem-1.html
http://timothymeixell.com/blog/programming/math/2017/09/25/project-euler-problem-1.htmlblogprogrammingmathSurvey Widget<p><a href="https://github.com/misternu/survey-widget">Click here for github repo</a></p>
<p><a href="https://survey-widget.netlify.com">Click here for the live demo</a></p>
<p>This widget can be used to make surveys with multiple choice questions. The interface is built with Material-UI components, and you can export each survey to easily copied JSON.</p>
<p>Screenshots below:</p>
<p><img src="/imgs/survey-form.png" alt="Survey interface" title="Survey Interface" />
<img src="/imgs/survey-json.png" alt="Survey JSON" title="Survey JSON" /></p>
Sun, 17 Sep 2017 06:00:00 +0000
http://timothymeixell.com/portfolio/2017/09/17/survey-widget.html
http://timothymeixell.com/portfolio/2017/09/17/survey-widget.htmlportfolioSudoku Solver<p><a href="http://github.com/misternu/sudoku">Click here for github repo</a></p>
<p>In the on-site portion of Dev Bootcamp, the first group project is to create a sudoku solving progam. Not all teams solve it. That’s okay, because the task is really about teamwork and the technical issues around sharing a codebase, not about the algorithm itself. My team managed to solve it, but I felt unsatisfied with the runtime of the program, so I made a few on my own.</p>
<p>Ruby is a language made for happy developers, not exactly for fast runtimes. But some of the more commonly used Enumerable methods have been highly optimized under the hood. This solution uses two of these helpers (each, reject), and I avoid using destructive methods wherever possible. This is because, in many cases, changing an array costs more time than making a new one.</p>
<p>The solution avoids recomputing information that was already obtained by an ancestor in the recursive tree. When a number has been eliminated from a particular square of the board, all children of that node will not take time to reconsider the possibility of it being there.</p>
<p>Fill in squares as long as you can with simple deduction. Then, the square with the least number of possibilities is recursively guessed. If a node discovers that it is invalid or unsolvable, it returns nil. If it has been filled in, it returns the complete board string (either to its parent or the original solve call). The board is always represented by strings so that we don’t spend time switching between data representations.</p>
<p>The output of the program run on 15 puzzles (including some with multiple solutions), with a benchmark time of 0.03 seconds:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>> ruby runner.rb
145892673893176425276435819519247386762583194384961752957614238438729561621358947
475936281932851764681274359517492836349768125268315497153687942794523618826149573
293541687718296453654738912972813564846952371531467298369174825125389746487625139
783426915946518327521379846658197234279643581134852769365984172417235698892761453
648732915275189463319564827486325791927618354531947682864271539752893146193456278
732689145846571329159324678413968257278135496695247831384756912521893764967412583
239517864574268319168439275792846153381975426456123987843651792925784631617392548
396245781178369524524817396287951643931486275465723918712638459659174832843592167
693875412145632798782194356357421869816957234429368175274519683968743521531286947
387419526259763418641528379716285943594631782823974165472396851135842697968157234
382619475594738621176425938863941752457263189921857364738594216245176893619382547
926513784815247639374869521648125973791438265253976148437691852569382417182754396
397648152814253769652179843479861325583924671261537984946712538728395416135486297
187234569423659871659187243795821634836495712214763985561948327348572196972316458
129578634473269158658134792936812475815746329742953816291487563387695241564321987
0.030000 0.000000 0.030000 ( 0.030455)
</code></pre></div></div>
Sun, 06 Aug 2017 06:00:00 +0000
http://timothymeixell.com/portfolio/2017/08/06/sudoku-solver.html
http://timothymeixell.com/portfolio/2017/08/06/sudoku-solver.htmlportfolioThe cube root of four is irrational<p>A proof by contradiction is one in which you assume that something is true, and show that the conclusions are contradictory, and so the assumtion must be false. Since we are trying to prove that it is <em>irrational</em>, we will assume that it is <em>rational</em>, and work from there to find something fishy.</p>
<script type="math/tex; mode=display">\sqrt[3]{4} = \frac{a}{b}</script>
<p>The square root of 4 is assumed to be equal to the ratio between a whole number <script type="math/tex">a</script> and a whole number <script type="math/tex">b</script>, having no common factors besides one (reduced to lowest terms). Using algebra, we can conclude that <script type="math/tex">b</script> cubed is equal to <script type="math/tex">a</script> cubed divided by four:</p>
<script type="math/tex; mode=display">4 = \left ( \frac{a}{b} \right )^3 \qquad
4 = \frac{a^3}{b^3} \qquad
b^3 = \frac{a^3}{4}</script>
<p>We know that <script type="math/tex">a</script> and <script type="math/tex">b</script> are whole numbers, so their cubes are also whole numbers. So the cube of <script type="math/tex">a</script> is evenly divisible by four, and therefore also by two, so it is an even number. <script type="math/tex">a</script> cannot be odd, if its cube is even, so it is even. But we assumed that <script type="math/tex">a</script> and <script type="math/tex">b</script> have no common factors, so <script type="math/tex">b</script> must be odd. Knowing this, lets break up our equation:</p>
<script type="math/tex; mode=display">b^3 = a * a * a * \frac{1}{4}</script>
<p>Let <script type="math/tex">x</script> be <script type="math/tex">a</script> divided by two. Simplify.</p>
<script type="math/tex; mode=display">x = \frac{a}{2} \qquad
b^3 = \frac{a}{2} * \frac{a}{2} * a \qquad
b^3 = x^2 * a</script>
<p>Since <script type="math/tex">b</script> is odd and so is its cube, the prime factorization of the left hand side must contain no twos. But the product on the right includes the even number <script type="math/tex">a</script>, and so the prime factorization must contain at least one two. Prime factorizations of equal numbers are identical, so the same number must and must not have a factor of two. This is absurd, therefore, our assumption is false. The cube root of four must be irrational.</p>
Fri, 27 Jan 2017 06:00:00 +0000
http://timothymeixell.com/blog/math/2017/01/27/The-cube-root-of-4-is-irrational.html
http://timothymeixell.com/blog/math/2017/01/27/The-cube-root-of-4-is-irrational.htmlblogmathIteration in JavaScript vs Ruby<p>Now that we are working in JavaScript, we still have to iterate over arrays and dictionaries. But, we don’t have any of those useful convenience methods anymore. So, as primitive as it sounds, we are just going to have to count.</p>
<p>Instead of using each, if I want to act on the contents of an array, I can do this:</p>
<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">var</span> <span class="nx">array</span> <span class="o">=</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">];</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o"><</span> <span class="nx">array</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">//do stuff with array[i]</span>
<span class="p">}</span>
</code></pre></div></div>
<p>We are getting the same functionality as <code class="highlighter-rouge">.each</code> from ruby, but we just have to be more explicit about how that is happening. Because we are forced to always be more aware of how the iterations are happening, it is necessary to be aware of what data structures are used, so that things don’t become needlessly complicated.</p>
Mon, 16 Nov 2015 06:00:00 +0000
http://timothymeixell.com/blog/programming/2015/11/16/Iteration-in-Ruby-vs-JavaScript.html
http://timothymeixell.com/blog/programming/2015/11/16/Iteration-in-Ruby-vs-JavaScript.htmlblogprogrammingRuby Classes<p>Working with variables, arrays, and hashes is great… but. Sometimes, you are going to be using a data structure so many times in your program that it saves time to create a custom one. You can think of these custom classes as blueprints for new objects, that can be used again and again.</p>
<p>The syntax is simple:</p>
<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">class</span> <span class="nc">ClassName</span>
<span class="k">def</span> <span class="nf">initialize</span><span class="p">(</span><span class="n">argument</span><span class="p">)</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre></div></div>
<p>Every class should define a method called <code class="highlighter-rouge">initialize</code>. This method is called when the object is created with <code class="highlighter-rouge">ClassName.new</code>. One of the most important things you can do in an initialize method is to set the instance variables. Lets try that now in a new class called Jar.</p>
<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">class</span> <span class="nc">Jar</span>
<span class="k">def</span> <span class="nf">initialize</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">quantity</span><span class="p">)</span>
<span class="vi">@item</span> <span class="o">=</span> <span class="n">item</span>
<span class="vi">@quantity</span> <span class="o">=</span> <span class="n">quantity</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre></div></div>
<p>The <code class="highlighter-rouge">@</code> at the beginning of a variable indicates that it is an instance variable. Instance variables are available from inside each instance of the class. By storing those two values in instance variables, we get to keep them for longer than the execution of <code class="highlighter-rouge">initialize</code>.</p>
<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">class</span> <span class="nc">Jar</span>
<span class="k">def</span> <span class="nf">initialize</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">quantity</span><span class="p">)</span>
<span class="vi">@item</span> <span class="o">=</span> <span class="n">item</span>
<span class="vi">@quantity</span> <span class="o">=</span> <span class="n">quantity</span>
<span class="k">end</span>
<span class="k">def</span> <span class="nf">add_one</span>
<span class="vi">@quantity</span> <span class="o">+=</span> <span class="mi">1</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre></div></div>
<p>I added a method <code class="highlighter-rouge">add_one</code> to the class. We can call that on an instance of the class to increase its stored number of items by one. But how do we get that item?</p>
<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">marbles</span> <span class="o">=</span> <span class="no">Jar</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="s2">"marbles"</span><span class="p">,</span> <span class="mi">8</span><span class="p">)</span>
<span class="n">marbles</span><span class="p">.</span><span class="nf">add_one</span>
<span class="nb">p</span> <span class="n">marbles</span><span class="p">.</span><span class="nf">quantity</span>
</code></pre></div></div>
<p>When we try to access the instance variable from the outside it doesn’t work. It should have said 9, but we get a <code class="highlighter-rouge">NoMethodError</code>. For that, we will need to either make a method that returns the variable manually, or learn about accessors. A subject for next time? I will leave it at that for now, thanks for reading!</p>
Mon, 09 Nov 2015 06:00:00 +0000
http://timothymeixell.com/blog/programming/2015/11/09/Ruby-Classes.html
http://timothymeixell.com/blog/programming/2015/11/09/Ruby-Classes.htmlblogprogrammingArrays & Hashes<p>When learining to write programs in Ruby, it can become cumbersome to create variables for each and every object that the program creates. In many cases, you wont even know what is going to be stored until runtime. Arrays and hashes allow for you to store objects in collections, and have methods that allow for you to easily access their stored information.</p>
<h3 id="arrays">Arrays</h3>
<p>An array stores objects in sequence. A new array can be created with either empty brackets or <code class="highlighter-rouge">Array.new</code>:</p>
<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">array1</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">array2</span> <span class="o">=</span> <span class="no">Array</span><span class="p">.</span><span class="nf">new</span>
</code></pre></div></div>
<p>You can also create an array with objects already inside:</p>
<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">array3</span> <span class="o">=</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="s2">"four"</span><span class="p">,</span> <span class="mf">5.0</span><span class="p">]</span>
</code></pre></div></div>
<p>There are lots of ways to retrieve things from arrays. The first and most important is indexes. Type the index you are retrieving in brackets after the variable that stores the array. Indexes start at 0.</p>
<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">>></span> <span class="n">array3</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span>
<span class="o">=></span> <span class="mi">3</span>
</code></pre></div></div>
<p>It can also be useful to grab the objects one at a time, and to not leave them behind. This can be achieved with the <code class="highlighter-rouge">pop</code> and <code class="highlighter-rouge">shift</code> methods.</p>
<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">>></span> <span class="n">a</span> <span class="o">=</span> <span class="n">array3</span><span class="p">.</span><span class="nf">pop</span>
<span class="o">=></span> <span class="mf">5.0</span>
<span class="o">>></span> <span class="n">b</span> <span class="o">=</span> <span class="n">array3</span><span class="p">.</span><span class="nf">shift</span>
<span class="o">=></span> <span class="mi">1</span>
<span class="o">>></span> <span class="n">array3</span>
<span class="o">=></span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="s2">"four"</span><span class="p">]</span>
</code></pre></div></div>
<p>The counterparts for these methods are <code class="highlighter-rouge">push</code> and <code class="highlighter-rouge">unshift</code>.</p>
<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">>></span> <span class="n">array3</span><span class="p">.</span><span class="nf">push</span><span class="p">(</span><span class="n">b</span><span class="p">)</span>
<span class="o">=></span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="s2">"four"</span><span class="p">,</span> <span class="mi">1</span><span class="p">]</span>
<span class="o">>></span> <span class="n">array3</span><span class="p">.</span><span class="nf">unshift</span><span class="p">(</span><span class="n">a</span><span class="p">)</span>
<span class="o">=></span> <span class="p">[</span><span class="mf">5.0</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="s2">"four"</span><span class="p">,</span> <span class="mi">1</span><span class="p">]</span>
</code></pre></div></div>
<h3 id="hashes">Hashes</h3>
<p>Some collections of information don’t have as much of an order to them, and you want to be able to access them using a name instead of a number. That is what hashes are useful for. As with before, you can make a new hash in two ways:</p>
<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">hash1</span> <span class="o">=</span> <span class="p">{}</span>
<span class="n">hash2</span> <span class="o">=</span> <span class="no">Hash</span><span class="p">.</span><span class="nf">new</span>
</code></pre></div></div>
<p>Also again, you can instantiate them with contents.</p></p>
<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">hash3</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this_number"</span> <span class="o">=></span> <span class="mi">2</span><span class="p">,</span> <span class="s2">"that_number"</span> <span class="o">=></span> <span class="mi">42</span><span class="p">}</span>
</code></pre></div></div>
<p>And access them with keys (instead of indexes)</p>
<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">>></span> <span class="n">hash3</span><span class="p">[</span><span class="s2">"that_number"</span><span class="p">]</span>
<span class="o">=></span> <span class="mi">42</span>
</code></pre></div></div>
<p>You can overwrite keys or write to new keys.</p>
<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">>></span> <span class="n">hash3</span><span class="p">[</span><span class="s2">"this_number"</span><span class="p">]</span> <span class="o">=</span> <span class="mi">4</span>
<span class="o">=></span> <span class="mi">4</span>
<span class="o">>></span> <span class="n">hash3</span><span class="p">[</span><span class="s2">"new_number"</span><span class="p">]</span> <span class="o">=</span> <span class="mi">8</span>
<span class="o">=></span> <span class="mi">8</span>
<span class="o">>></span> <span class="n">hash3</span>
<span class="o">=></span> <span class="p">{</span><span class="s2">"this_number"</span><span class="o">=></span><span class="mi">4</span><span class="p">,</span> <span class="s2">"new_number"</span><span class="o">=></span><span class="mi">8</span><span class="p">,</span> <span class="s2">"that_number"</span><span class="o">=></span><span class="mi">42</span><span class="p">}</span>
</code></pre></div></div>
<h3 id="more-info">More Info</h3>
<p>That about covers the basics of arrays and hashes. More can be found in the documentation at <a href="http://ruby-doc.org">http://ruby-doc.org</a></p>
Fri, 23 Oct 2015 06:00:00 +0000
http://timothymeixell.com/blog/programming/2015/10/23/arrays-hashes.html
http://timothymeixell.com/blog/programming/2015/10/23/arrays-hashes.htmlblogprogrammingGit & Github<p>So you’re learning to code. One day, when writing something, you decide to do an expirament. “Oh no,” you think, “what if I’m wrong? Better save a backup copy,” so you make a duplicate of the file and get on with your business. This keeps happening. Before you know it you have a pile of extra files, some with dates and some without, that you have to manually sort through to find revisions. More and more cruft, no matter how naturally organized you are.</p>
<p>There is a better way! A version control system(VCS), or revision control system (RCS), is software that handles this problem and many others. It remembers every change you made, and in what order. It keeps this information out of the way where you don’t have to look at it. But, when you need to, you can change your work back to any revision you have made.</p>
<p>One such popular VCS is called Git. Using Git, you can save batches of work that you do into chunks, called ‘commits’. Each commit also has a description that you write, and holds information about the time it was made and who made it. Git can also keep track of concurrent versions of your work, in ‘branches’. Each branch has its own history, and the branches can borrow from each other at any point, or even merge into each other.</p>
<p>All of this organization is great when you are working with other people. You can push and pull to each other’s git repositories directly, but that gets messy. This problem is solved with a service called <a href="http://github.com">GitHub</a>. <a href="http://github.com">GitHub</a> hosts a copy of your repository online, so you and other users can put your changes in a centralized place. The site allows for you to ask the group for permission to make changes (pull requests), make comments on each others code, and track known problems with the code (issues).</p>
<p>Now that you know what Git is for, it’s time to start learning it. A great place to start is <a href="http://gitimmersion.com">Git Immersion</a>. Have fun!</p>
Sat, 03 Oct 2015 06:00:00 +0000
http://timothymeixell.com/blog/vcs/2015/10/03/git-and-github.html
http://timothymeixell.com/blog/vcs/2015/10/03/git-and-github.htmlblogvcs