<?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: ruthmoog</title>
    <description>The latest articles on DEV Community by ruthmoog (@ruthmoog).</description>
    <link>https://dev.to/ruthmoog</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%2F63272%2F7767fcf3-9ae3-49ea-b336-d1aef1df9edf.png</url>
      <title>DEV Community: ruthmoog</title>
      <link>https://dev.to/ruthmoog</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ruthmoog"/>
    <language>en</language>
    <item>
      <title>Book Club: Eloquent JavaScript. 4 Data Structures: Objects and Arrays</title>
      <dc:creator>ruthmoog</dc:creator>
      <pubDate>Tue, 28 May 2024 16:46:09 +0000</pubDate>
      <link>https://dev.to/ruthmoog/book-club-eloquent-javascript-4-data-structures-objects-and-arrays-57e3</link>
      <guid>https://dev.to/ruthmoog/book-club-eloquent-javascript-4-data-structures-objects-and-arrays-57e3</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Eloquent JavaScript&lt;/strong&gt; A Modern Introduction to Programming, by Marijn Haverbeke
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Part i: Language
&lt;/h3&gt;




&lt;h2&gt;
  
  
  Chapter 4:  Data Structures: Objects and Arrays
&lt;/h2&gt;

&lt;p&gt;If you read any of this chapter, please go ahead and discuss what you thought in the comments! &lt;/p&gt;

&lt;p&gt;📝 I'll add my notes here when I've read the chapter.&lt;/p&gt;

&lt;p&gt;📆 9th May 2024.&lt;/p&gt;

&lt;p&gt;📚 On &lt;a href="https://app.thestorygraph.com"&gt;Storygraph&lt;/a&gt;? Join the &lt;a href="https://app.thestorygraph.com/readalongs/9a6ec9d4-4572-4a54-a0e2-a4200c63ad67"&gt;Readalong&lt;/a&gt;!&lt;/p&gt;




</description>
      <category>books</category>
      <category>javascript</category>
      <category>bookclub</category>
    </item>
    <item>
      <title>Hidden Figures: disguising images from machines</title>
      <dc:creator>ruthmoog</dc:creator>
      <pubDate>Fri, 26 Apr 2024 10:51:08 +0000</pubDate>
      <link>https://dev.to/ruthmoog/hidden-figures-disguising-images-from-machines-4bpo</link>
      <guid>https://dev.to/ruthmoog/hidden-figures-disguising-images-from-machines-4bpo</guid>
      <description>&lt;p&gt;Artists who share their work online are frustrated by the theft of their style and content by machine learning (ML) tools. It's possible for artworks to be used for training of generative artificial intelligence (AI) without permission, and without guidance or accountability, tech giants have &lt;a href="https://the-decoder.com/apple-wants-to-buy-content-from-publishers-for-generative-ai-training/"&gt;investigated buying publishing houses&lt;/a&gt; to access non-public content.&lt;/p&gt;

&lt;p&gt;There is potential in these fashionable technologies as a force for good, but we don't have established ethical policies in place to make them fair - so artists and developers are finding ways to disrupt malpractice and artwork theft.&lt;/p&gt;

&lt;h2&gt;
  
  
  Poison attacks
&lt;/h2&gt;

&lt;p&gt;Enter &lt;a href="https://glaze.cs.uchicago.edu/"&gt;Glaze&lt;/a&gt; and &lt;a href="https://nightshade.cs.uchicago.edu/whatis.html"&gt;Nightshade&lt;/a&gt;, tools which can manipulate content so it will disrupt or &lt;em&gt;poison&lt;/em&gt; ML training data.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Nightshade can help deter model trainers who disregard copyrights, opt-out lists, and do-not-scrape/robots.txt directives&lt;br&gt;
&lt;em&gt;- &lt;a href="https://nightshade.cs.uchicago.edu/whatis.html"&gt;&lt;strong&gt;What is Nightshade?&lt;/strong&gt; The Glaze Project Team&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Glaze&lt;/strong&gt; works by making changes in the digital image file, which are not obvious to the human eye, but are significant enough to distort the input to an AI training model. That can result in a picture in one style being interpreted as a differently style. e.g. you see a painting in the style of Van Gogh, but the AI 'sees' a picture in the style of Man Ray.&lt;br&gt;
This works (for now!) on artificial neural networks which use a &lt;a href="https://en.wikipedia.org/wiki/Variational_autoencoder"&gt;variational autoencoder (VAE)&lt;/a&gt; architecture, but it doesn't work on networks that don't rely on VAE.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Nightshade&lt;/strong&gt; works in a similar way to Glaze - they're from the same team - but it essentially gaslights the AI model into learning misinformation, and this is a deterrent for training on private content.&lt;br&gt;
But, it does affect the lightness of the original image to the human eye. e.g. you see a 'shaded' photograph of a sunflower, but the AI could 'see' a photograph of a sunflower alarm clock, and with enough data could learn that sunflowers have clock hands and bells.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Nightshade's goal is not to break models, but to increase the cost of training on unlicensed data, such that licensing images from their creators becomes a viable alternative.&lt;br&gt;
&lt;em&gt;- &lt;a href="https://nightshade.cs.uchicago.edu/whatis.html"&gt;&lt;strong&gt;What is Nightshade?&lt;/strong&gt; The Glaze Project Team&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Is it worth it?
&lt;/h2&gt;

&lt;p&gt;Keep in mind you're fighting fire with fire in terms of compute:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Glaze uses around 5 Gb of memory and a substantial amount of CPU computing. We are working on reducing these numbers.&lt;br&gt;
&lt;em&gt;- &lt;a href="https://glaze.cs.uchicago.edu/user-guide.html"&gt;&lt;strong&gt;User guide&lt;/strong&gt; The Glaze Project Team&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Ultimately it depends how ignoble and determined the party is that is trying to crawl the artwork. Nightshade will be most effective against large volumes, and Glaze is a temporary measure which could become ineffective long-term. But there's nothing to stop users applying both measures, and yet little else to do without keeping content off the web (and good luck with that). If the content is there, it cannot also &lt;strong&gt;not&lt;/strong&gt; be &lt;em&gt;there&lt;/em&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Resources
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.reddit.com/r/aiwars/comments/19asm74/we_need_to_talk_a_little_bit_about_glaze_and/"&gt;Reddit &lt;em&gt;&lt;strong&gt;AI Wars&lt;/strong&gt; - We need to talk a little bit about Glaze and Nightshade&lt;/em&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://glaze.cs.uchicago.edu/aboutus.html"&gt;Sand Lab, University of Chicago &lt;em&gt;&lt;strong&gt;The Glaze Project&lt;/strong&gt;&lt;/em&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>ethics</category>
      <category>copyright</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>Book Club: Eloquent JavaScript. 5 Functions</title>
      <dc:creator>ruthmoog</dc:creator>
      <pubDate>Sun, 10 Mar 2024 16:55:15 +0000</pubDate>
      <link>https://dev.to/ruthmoog/book-club-eloquent-javascript-5-functions-4057</link>
      <guid>https://dev.to/ruthmoog/book-club-eloquent-javascript-5-functions-4057</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Eloquent JavaScript&lt;/strong&gt; A Modern Introduction to Programming, by Marijn Haverbeke
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Part i: Language
&lt;/h3&gt;




&lt;p&gt;Have you noticed &lt;a href="https://eloquentjavascript.net/"&gt;https://eloquentjavascript.net/&lt;/a&gt; has made a 4th edition (2024) available?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fta6r9kfeu5zjvotk59h5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fta6r9kfeu5zjvotk59h5.png" alt="Cover illustration from 4th edition, an inked bird of prey, on a mustard yellow background" width="482" height="247"&gt;&lt;/a&gt;&lt;/p&gt;
4th Edition cover illustration by &lt;a href="http://www.pechane.com/"&gt;Péchane Sumi-e&lt;/a&gt;



&lt;h2&gt;
  
  
  Chapter 3: Functions
&lt;/h2&gt;

&lt;p&gt;If you read any of this chapter, please go ahead and discuss what you thought in the comments! &lt;/p&gt;

&lt;p&gt;📝 I'll add my notes here when I've read the chapter.&lt;/p&gt;

&lt;p&gt;📆 End of March 2024.&lt;/p&gt;

&lt;p&gt;📚 On &lt;a href="https://app.thestorygraph.com"&gt;Storygraph&lt;/a&gt;? Join the &lt;a href="https://app.thestorygraph.com/readalongs/9a6ec9d4-4572-4a54-a0e2-a4200c63ad67"&gt;Readalong&lt;/a&gt;!&lt;/p&gt;

&lt;h3&gt;
  
  
  My Notes
&lt;/h3&gt;

&lt;p&gt;Wow I took a lot of time to get through this chapter - have just been busy.&lt;/p&gt;

&lt;p&gt;This chapter has some nice and simple exercises to play with functions, and it explains about scope, ways to define your functions and, understanding the call stack.&lt;/p&gt;

&lt;p&gt;The optional and default arguments were an interesting reminder for me that was useful for the exercises, plus there is an example purely for playing with recursion.&lt;/p&gt;




</description>
      <category>books</category>
      <category>javascript</category>
      <category>bookclub</category>
    </item>
    <item>
      <title>We_Coded 2024</title>
      <dc:creator>ruthmoog</dc:creator>
      <pubDate>Fri, 08 Mar 2024 18:13:00 +0000</pubDate>
      <link>https://dev.to/ruthmoog/wecoded-2024-3pcl</link>
      <guid>https://dev.to/ruthmoog/wecoded-2024-3pcl</guid>
      <description>&lt;p&gt;Another year in tech and I (she/her) have so far stuck it out beyond the 3 year drop-off for women. It ain't no thing!&lt;/p&gt;

&lt;h2&gt;
  
  
  How can we actively embrace equality in the tech industry?
&lt;/h2&gt;

&lt;p&gt;I was fortunate to be invited to a talk by intersex activist &lt;a href="https://www.intersexequalityrights.com/about"&gt;Valentino Vecchietti&lt;/a&gt; (she/they), focusing on intersex inclusion in science and scientific publishing for this years international Women's Day.&lt;/p&gt;

&lt;p&gt;This day can be full of cringe to be honest, as people awkwardly try to be inclusive of women and overtly recognise women's gender it's just a bit strange.&lt;br&gt;
Making sure to include trans women and non-binary and intersex people into the fold goes a long way for inclusivity. Be it a pride flag emoji reaction, using your pronouns, or making sure that we talk about women and gender minorities instead of &lt;em&gt;just&lt;/em&gt; women or only females... this goes a long way to showing simply that you care about others.&lt;/p&gt;

&lt;p&gt;If you'd like to use the global inclusive pride flag it's freely available with usage support at &lt;a href="//globalinclusiveprideflag.com"&gt;https://www.globalinclusiveprideflag.com/&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Happy International Women's Day
&lt;/h2&gt;

&lt;p&gt;If you're not sure you're feeling the Women's Day vibes, try wishing your virtual interactive assistant a happy international Women's Day. I'm sure your robot will be ready to tell you about a historical figure worth raising a toast for.&lt;/p&gt;

</description>
      <category>wecoded</category>
    </item>
    <item>
      <title>Book Club: Eloquent JavaScript. 4 Programme Structure</title>
      <dc:creator>ruthmoog</dc:creator>
      <pubDate>Wed, 31 Jan 2024 16:10:29 +0000</pubDate>
      <link>https://dev.to/ruthmoog/book-club-eloquent-javascript-4-programme-structure-5ea8</link>
      <guid>https://dev.to/ruthmoog/book-club-eloquent-javascript-4-programme-structure-5ea8</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Eloquent JavaScript&lt;/strong&gt; A Modern Introduction to Programming, by Marijn Haverbeke
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Part i: Language
&lt;/h3&gt;




&lt;p&gt;Sorry that this next chapter is later than expected, I had a lot going on at the end of last year including a new job as a Frontend Dev. But I will try to stay on track, please feel welcome to join in!&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%2Flearning.oreilly.com%2Fapi%2Fv2%2Fepubs%2Furn%3Aorm%3Abook%3A9781492071198%2Ffiles%2Fimages%2Ff0040-01.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Flearning.oreilly.com%2Fapi%2Fv2%2Fepubs%2Furn%3Aorm%3Abook%3A9781492071198%2Ffiles%2Fimages%2Ff0040-01.jpg" alt="A pencil illustration from the book, of ferns and flying bumblebees"&gt;&lt;/a&gt;&lt;/p&gt;
Illustration by &lt;a href="https://www.madalinatantareanu.com" rel="noopener noreferrer"&gt;Madalina Tantareanu&lt;/a&gt;



&lt;h2&gt;
  
  
  Chapter 2: Programme Structure
&lt;/h2&gt;

&lt;p&gt;If you read any of this chapter, please go ahead and discuss what you thought in the comments! &lt;/p&gt;

&lt;p&gt;📝 I've removed chapter 3 from this post (because I forgot there are exercises too!) and I've added my notes below.&lt;/p&gt;

&lt;p&gt;📆 End of Feb 2024.&lt;/p&gt;

&lt;p&gt;📚 On &lt;a href="https://app.thestorygraph.com" rel="noopener noreferrer"&gt;Storygraph&lt;/a&gt;? Join the &lt;a href="https://app.thestorygraph.com/readalongs/9a6ec9d4-4572-4a54-a0e2-a4200c63ad67" rel="noopener noreferrer"&gt;Readalong&lt;/a&gt;!&lt;/p&gt;




&lt;h3&gt;
  
  
  Who should read this chapter?
&lt;/h3&gt;

&lt;p&gt;This chapter is a general and basic overview of the terminology and syntax used in JS. So it will be useful to read carefully if you're new to programming, otherwise skim it. I find it difficult to use the terms in the book (e.g. 'binding' because I would usually say &lt;em&gt;var&lt;/em&gt; or &lt;em&gt;constant&lt;/em&gt;) but it's good to be aware of the vocab.&lt;/p&gt;

&lt;h3&gt;
  
  
  What do we learn?
&lt;/h3&gt;

&lt;p&gt;In a nutshell, here we learn that programs are made of statements, which can contain statements including expressions, which can be made of expressions! Loops and conditions can interrupt the top-to-bottom control flow, with bindings for tracking state and filing data under a name. Functions are like blocks of program, where a function call is an expression which can produce a value.&lt;/p&gt;

&lt;h3&gt;
  
  
  Exercises
&lt;/h3&gt;

&lt;p&gt;There are three fairly simple programming logic exercises at the end of the chapter, which are worth doing to practise loops - especially the classic FizzBuzz.&lt;br&gt;
The hints provide a couple of solutions, so if you didn't need to use the hint, &lt;em&gt;do&lt;/em&gt; read it after writing your solution.&lt;/p&gt;

</description>
      <category>books</category>
      <category>javascript</category>
      <category>bookclub</category>
    </item>
    <item>
      <title>Book Club: Eloquent JavaScript. 3 Intro + Values, Types, and Operators</title>
      <dc:creator>ruthmoog</dc:creator>
      <pubDate>Thu, 12 Oct 2023 10:43:42 +0000</pubDate>
      <link>https://dev.to/ruthmoog/book-club-eloquent-javascript-3-intro-values-types-and-operators-506o</link>
      <guid>https://dev.to/ruthmoog/book-club-eloquent-javascript-3-intro-values-types-and-operators-506o</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Eloquent JavaScript&lt;/strong&gt; A Modern Introduction to Programming, by Marijn Haverbeke
&lt;/h2&gt;




&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Chapter 1: Values, Types, and Operators
&lt;/h2&gt;

&lt;p&gt;If you read any of this chapter, please go ahead and discuss what you thought in the comments! &lt;/p&gt;

&lt;p&gt;📝 my notes from these chapters are below.&lt;/p&gt;

&lt;p&gt;📆 End of October 2023.&lt;/p&gt;

&lt;p&gt;📚 On &lt;a href="https://app.thestorygraph.com"&gt;Storygraph&lt;/a&gt;? Join the &lt;a href="https://app.thestorygraph.com/readalongs/9a6ec9d4-4572-4a54-a0e2-a4200c63ad67"&gt;Readalong&lt;/a&gt;!&lt;/p&gt;




&lt;p&gt;Chapter 1 is very high level overview of the syntax used in JS, I think for readers with some experience of JS already this content won't be new info and could be skipped - but the introduction might be worth reading or skimming as it's got some context behind the language that many JS developers might not know.&lt;/p&gt;

</description>
      <category>books</category>
      <category>algorithms</category>
      <category>bookclub</category>
    </item>
    <item>
      <title>Book Club: Eloquent JavaScript. 2 Discussion Qs</title>
      <dc:creator>ruthmoog</dc:creator>
      <pubDate>Thu, 12 Oct 2023 10:13:30 +0000</pubDate>
      <link>https://dev.to/ruthmoog/book-club-eloquent-javascript-2-discussion-qs-ggi</link>
      <guid>https://dev.to/ruthmoog/book-club-eloquent-javascript-2-discussion-qs-ggi</guid>
      <description>&lt;p&gt;I'll answer these questions when I've finished the book, but feel free to answer these here or to use them for your own book club.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Eloquent JavaScript&lt;/strong&gt; A Modern Introduction to Programming, by Marijn Haverbeke
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Discussion Questions
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Do you have a favourite project from the book? If so, why? What did you like about it?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The book uses examples in a sandbox in the browser. Did you use the sandbox? If so, how did it help your understanding? If not, did you follow the examples another way?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Did you have an opinion about JavaScript before reading this book? Did the book make you think differently about the language?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Were any of the chapters or topics frustrating for you? Is there anything you still don't understand?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;One of the book's aims is to explain how to organize and clarify your code. How has your coding style improved from reading this book? Did you learn anything new about how to write code?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Had you written a programming language before? If not, did this exercise help you see how other programming languages might work?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Is there anything you'll learn more about after reading this book?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Would you recommend this book? Who would enjoy reading it?&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>discuss</category>
      <category>books</category>
      <category>algorithms</category>
      <category>bookclub</category>
    </item>
    <item>
      <title>Book Club: Eloquent JavaScript. 1 Welcome</title>
      <dc:creator>ruthmoog</dc:creator>
      <pubDate>Thu, 12 Oct 2023 09:55:50 +0000</pubDate>
      <link>https://dev.to/ruthmoog/book-club-eloquent-javascript-1-welcome-22e</link>
      <guid>https://dev.to/ruthmoog/book-club-eloquent-javascript-1-welcome-22e</guid>
      <description>&lt;p&gt;Welcome to this tech book club! I'd love for you to join me reading this title. I've chosen this book after it was suggested by &lt;a href="https://dev.to/quii"&gt;Chris&lt;/a&gt;, who thought it would be a good topic for me as I move into more front-end development.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Eloquent JavaScript&lt;/strong&gt; A Modern Introduction to Programming, by Marijn Haverbeke
&lt;/h2&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%2Fuploads%2Farticles%2Flt0oyvvs19zvhhk7ahi7.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%2Fuploads%2Farticles%2Flt0oyvvs19zvhhk7ahi7.png" alt="Tentacles and chess pieces"&gt;&lt;/a&gt;&lt;/p&gt;
Illustration by &lt;a href="https://www.madalinatantareanu.com" rel="noopener noreferrer"&gt;Madalina Tantareanu&lt;/a&gt;



&lt;h3&gt;
  
  
   About the book
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Eloquent JavaScript&lt;/em&gt; dives deep into the JavaScript language to show you how to write beautiful, effective code. &lt;br&gt;
...&lt;/p&gt;

&lt;p&gt;You start by learning the basic structure of the JavaScript language as well as control structures, functions, and data structures to help you write basic programs. Then you’ll learn about error handling and bug fixing, modularity, and asynchronous programming before moving on to web browsers and how JavaScript is used to program them.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Published by &lt;a href="https://nostarch.com/ejs3" rel="noopener noreferrer"&gt;no starch press&lt;/a&gt; where you can buy the book in paperback.&lt;/li&gt;
&lt;li&gt;Or read for &lt;strong&gt;free&lt;/strong&gt; online at &lt;a href="https://eloquentjavascript.net/" rel="noopener noreferrer"&gt;eloquentjavascript.net&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  About the Author
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Marijn Haverbeke&lt;/strong&gt; is a programming language enthusiast and polyglot. He's worked on a wide range of software systems, from databases to compilers to editors. He runs a small business around his open source projects.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Reading Information
&lt;/h2&gt;

&lt;p&gt;The book has 21 chapters and approx 481 pages.&lt;br&gt;
My copy is the online 3rd edition.&lt;br&gt;
The book is divided into 3 parts (language, browser, node) and an introduction&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;All source code is available online in an interactive sandbox, where you can edit the code, run it, and see its output instantly.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The code examples and sandbox are at &lt;a href="https://eloquentjavascript.net/code/" rel="noopener noreferrer"&gt;eloquentjavascript.net/code/&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Some translations are available at &lt;a href="https://eloquentjavascript.net/" rel="noopener noreferrer"&gt;eloquentjavascript.net&lt;/a&gt;&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>books</category>
      <category>algorithms</category>
      <category>bookclub</category>
    </item>
    <item>
      <title>Book Club: Grokking Algorithms. 7: Where to go next and Final Discussion</title>
      <dc:creator>ruthmoog</dc:creator>
      <pubDate>Thu, 12 Oct 2023 08:58:09 +0000</pubDate>
      <link>https://dev.to/ruthmoog/book-club-grokking-algorithms-7-where-to-go-next-and-final-discussion-nnl</link>
      <guid>https://dev.to/ruthmoog/book-club-grokking-algorithms-7-where-to-go-next-and-final-discussion-nnl</guid>
      <description>&lt;h4&gt;
  
  
  &lt;strong&gt;Grokking Algorithms&lt;/strong&gt; An &lt;em&gt;illustrated&lt;/em&gt; guide for programmers and other curious people, by Aditya Y. Bhargava
&lt;/h4&gt;




&lt;h2&gt;
  
  
  Chapter 11: Where to go next
&lt;/h2&gt;

&lt;p&gt;If you read this chapter, please go ahead and discuss what you thought in the comments! &lt;/p&gt;

&lt;p&gt;📝 This is the last chapter in the book, and is a summary of 10 algorithms for further optional reading. You can read my notes below.&lt;/p&gt;




&lt;h2&gt;
  
  
  Where to go Next
&lt;/h2&gt;

&lt;p&gt;key topics covered: &lt;code&gt;suggestions&lt;/code&gt;, &lt;code&gt;binary search tree&lt;/code&gt;, &lt;code&gt;The Fourier Transform&lt;/code&gt;, &lt;code&gt;Parallel algorithms&lt;/code&gt;, &lt;code&gt;MapReduce&lt;/code&gt;, &lt;code&gt;Bloom Filters&lt;/code&gt;, &lt;code&gt;HyperLogLog&lt;/code&gt;, &lt;code&gt;SHA&lt;/code&gt;, &lt;code&gt;Diffie-Hellman&lt;/code&gt;, &lt;code&gt;key exchange&lt;/code&gt;, &lt;code&gt;locality-sensitive&lt;/code&gt;, &lt;code&gt;hashing&lt;/code&gt;, &lt;code&gt;linear programming&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Binary Search Tree
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Good for learning about &lt;code&gt;databases&lt;/code&gt; and &lt;code&gt;data structures&lt;/code&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;A &lt;em&gt;binary search tree&lt;/em&gt; is faster for insertions and deletions than a sorted array in average, because a &lt;em&gt;binary search tree&lt;/em&gt; allows you to find or insert in a more granular but sorted way. They &lt;em&gt;don't&lt;/em&gt; allow random access, and the good performance times are based on a balanced tree (too many nodes on one side will be imbalanced, and performance will be affected - &lt;em&gt;red-black trees&lt;/em&gt; are self-balancing so that might be a good option).&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%2Fuploads%2Farticles%2F7b7or8o57jyhteyadybz.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%2Fuploads%2Farticles%2F7b7or8o57jyhteyadybz.png" alt="What is and isn't a binary search tree"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;sup&gt;copyright Manning Publications, drawn by adit.io&lt;/sup&gt;



&lt;h3&gt;
  
  
  Inverted Indexes
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Good for learning about &lt;code&gt;search&lt;/code&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This data structur is a hash that maps words to places where they appear, and is commonly used in search engines.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Fourier Transform
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Good for &lt;code&gt;compression&lt;/code&gt; and &lt;code&gt;format&lt;/code&gt;s like MP3 or JPG, and &lt;code&gt;music tech&lt;/code&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This algorithm can take a digital music signal &amp;amp; break it into individual frequencies so that the file can be reduced (like in MP3) or frequecies can be boosted or reduced in music production. It also works for images in the same way, and can be used in applications like earthquake prediction and DNA analysis, with those digital signals.&lt;/p&gt;

&lt;h3&gt;
  
  
  Parallel algorithms
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Good for speed optimisation&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;These allow you to spread work out in parallel so that it can be completed sooner. But they're hard to design, test, and predict the cost benefit of as the time gains aren't linear.&lt;/p&gt;

&lt;h3&gt;
  
  
  MapReduce
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Good for speed and load balancing&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This is a popular &lt;em&gt;distributed algorithm&lt;/em&gt; (a subtype of parralel algorithm). Distributed algos are useful when you have a lot of work to do as they will cut out a lot of time to do it by spreading work across multiple machines. an example is Apache Hadoop.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bloom filters
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Good for quick approximations&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;These are &lt;em&gt;probabilistic data structures&lt;/em&gt; (they give you a likely correct answer but it could be a false positive). This is an alternative to a &lt;code&gt;hash&lt;/code&gt; (which will give you the correct answer) but for a large hash index might not be practical, and a &lt;code&gt;bloom filter&lt;/code&gt; approximation might be good enough.&lt;/p&gt;

&lt;h3&gt;
  
  
  HyperLogLog
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Good for quick approximations&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;A similar &lt;em&gt;probabilistic algorithm&lt;/em&gt; that approximates the number of unique elements in a set.&lt;/p&gt;

&lt;h3&gt;
  
  
  SHA algorithms
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Good for unbiased comparison&lt;/em&gt;&lt;br&gt;
This is a &lt;em&gt;secure hash algorithm&lt;/em&gt; (a &lt;code&gt;SHA&lt;/code&gt; is a hash function, which generates a string in this context called a &lt;code&gt;hash&lt;/code&gt;). Unlike has functions which goes from (e.g.) string to array index, SHA goes from string to string. You can use the SHA to tell if objects, files or strings (like passwords) are the same without revealing the original content. [note: this is not the gold-standard for password-hashing]&lt;/p&gt;

&lt;h3&gt;
  
  
  Localilty-sensitive hashing
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Good for biased comparison&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;SHA is locality insensitive - similar starting strings will not have similar hashes. A locality-sensitive hash such as &lt;code&gt;Simhash&lt;/code&gt; will generate a string that is similarly represented so that you can compare two hashes for similarity of content - e.g. for plagiarism checks.&lt;/p&gt;

&lt;h3&gt;
  
  
  Diffie-Hellman key exchange
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Good for cryptography&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;Diffie-Hellman algorithm&lt;/em&gt; is used for message encryption. It has a public key for sharing which is used to encrypt a message, and a private key which can decode the message and is 'owned' by one person. It's hard to decode without the private key and the cipher does not need to be communicated so it is still used in practise alongside RSA.&lt;/p&gt;

&lt;h3&gt;
  
  
  Linear programming
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Good for optimization&lt;/em&gt;&lt;br&gt;
Graph algorithms in the book are a subset of &lt;em&gt;linear programming&lt;/em&gt;, which uses the complex &lt;em&gt;Simplex algorithm&lt;/em&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Discussion for this chapter
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Are there any algorithms you're going to investigate that aren't recommended in this list or in the book?&lt;/li&gt;
&lt;li&gt;Have you used any of these 10 algorithms? Or, did you consider any of these but opted for a different algorithm instead?&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Discussion for the entire book
&lt;/h2&gt;

&lt;p&gt;Please visit the &lt;a href="https://dev.to/ruthmoog/book-club-grokking-algorithms-2-2pe6"&gt;discussion questions&lt;/a&gt; post to reflect on the book, and add your answers to the comments along wit any of your own questions or reflections you have.&lt;/p&gt;

</description>
      <category>books</category>
      <category>algorithms</category>
      <category>bookclub</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Book Club: Grokking Algorithms. 6: Dynamic programming and k-nearest neighbours</title>
      <dc:creator>ruthmoog</dc:creator>
      <pubDate>Wed, 13 Sep 2023 14:42:06 +0000</pubDate>
      <link>https://dev.to/ruthmoog/book-club-grokking-algorithms-6-dynamic-programming-and-k-nearest-neighbours-81f</link>
      <guid>https://dev.to/ruthmoog/book-club-grokking-algorithms-6-dynamic-programming-and-k-nearest-neighbours-81f</guid>
      <description>&lt;h4&gt;
  
  
  &lt;strong&gt;Grokking Algorithms&lt;/strong&gt; An &lt;em&gt;illustrated&lt;/em&gt; guide for programmers and other curious people, by Aditya Y. Bhargava
&lt;/h4&gt;




&lt;h2&gt;
  
  
  Chapter 9: Dynamic Programming
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Chapter 10: K-nearest Neighbours
&lt;/h2&gt;

&lt;p&gt;If you read any of these chapters, please go ahead and discuss what you thought in the comments! &lt;/p&gt;

&lt;p&gt;📝 you can read my notes below.&lt;/p&gt;

&lt;p&gt;📆 The next post will be on the final chapter, chapter 11. I'll aim for end of September 2023.&lt;br&gt;
If you're on &lt;a href="https://app.thestorygraph.com/profile/ruthmoog" rel="noopener noreferrer"&gt;Storygraph&lt;/a&gt; and want to join me, say hi and I'll start a Buddy Read.&lt;/p&gt;




&lt;h2&gt;
  
  
  Dynamic Programming
&lt;/h2&gt;

&lt;p&gt;Key topics covered &lt;code&gt;prioritisation&lt;/code&gt;, &lt;code&gt;Levenshtein distance&lt;/code&gt; ...&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Solve sub-problems to solve bigger problems&lt;/em&gt; with &lt;em&gt;dynamic programming&lt;/em&gt; (not to be confused with dynamic programming language). Start by using a grid of sub-problems x scenarios. Always start with a grid, and the cells are usually filled with what you're trying to optimise. Each cell will be a sub-problem.&lt;/p&gt;

&lt;p&gt;The order of the rows doesn't matter, but the column vs row axes &lt;em&gt;can matter&lt;/em&gt;. Adding another item to your grid might mean you have to recalculate at a finer granularity e.g. size in .5lb increments.&lt;/p&gt;

&lt;p&gt;There is no solution in dynamic programming for splitting the existing items - you would use a greedy algorithm for that.&lt;br&gt;
&lt;em&gt;Dynamic programming&lt;/em&gt; only works when each sub-problem is discrete (doesn't depend on other problems), but it's possible for sub-problems to have &lt;em&gt;their own&lt;/em&gt; sub-problems.&lt;/p&gt;




&lt;h2&gt;
  
  
  K-nearest Neighbors
&lt;/h2&gt;

&lt;p&gt;Key topics covered &lt;code&gt;feature extraction&lt;/code&gt;, &lt;code&gt;regression&lt;/code&gt;, &lt;code&gt;prediction&lt;/code&gt;, &lt;code&gt;use cases&lt;/code&gt;, &lt;code&gt;limitations&lt;/code&gt;, &lt;code&gt;classification&lt;/code&gt;, &lt;code&gt;normalization / normalisation&lt;/code&gt;, &lt;code&gt;weighting&lt;/code&gt;, &lt;code&gt;machine learning&lt;/code&gt;, &lt;code&gt;pythagorean formula&lt;/code&gt;, &lt;code&gt;OCR&lt;/code&gt;, &lt;code&gt;optical character recognition&lt;/code&gt;, &lt;code&gt;Naive Bayes classifyer&lt;/code&gt; ...&lt;/p&gt;

&lt;p&gt;The K-nearest neighbor (KNN) algorithm is simple and the first choice if you want to classify something. It depends on &lt;em&gt;feature extraction&lt;/em&gt;; you have to think about many different considerations to pick the right features. You should choose,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;features that correlate to what you're trying to classify or regress&lt;/li&gt;
&lt;li&gt;features that don't have a bias (e.g if you ask a group how much they like cats, you won't know how much they like dogs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use the chosen features to plot items on a graph, so you can find the distance between then using the Pythagorean formula &lt;code&gt;a2 + b2 = c2&lt;/code&gt;, or for an x-y graph, &lt;em&gt;distance&lt;/em&gt; = √(x1-x2)&lt;sup&gt;2&lt;/sup&gt; + (y1-y2)&lt;sup&gt;2&lt;/sup&gt;.&lt;br&gt;
The same formula can be used to calculate the distance in &lt;em&gt;several&lt;/em&gt; dimensions.&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%2FegonSchiele%2Fgrokking_algorithms%2Fblob%2Fmaster%2Fimages%2F10_k_nearest_neighbors%2F102_building_a_recommendations_system%2Fjustin_likes_a_movie.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%2FegonSchiele%2Fgrokking_algorithms%2Fblob%2Fmaster%2Fimages%2F10_k_nearest_neighbors%2F102_building_a_recommendations_system%2Fjustin_likes_a_movie.png%3Fraw%3Dtrue" alt="Justin likes a movie"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;sup&gt;copyright Manning Publications, drawn by adit.io&lt;/sup&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Normalisation&lt;/strong&gt; allows you to compare ratings at the same scale, by adjusting the overall average ratings to be comparable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Weighting&lt;/strong&gt; lets you prioritise particular given points as more influential in your calculation. It's like giving special points an extra vote.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Regression&lt;/strong&gt; is when you use the k-nearest neighbours to forecast or predict an outcome, by taking the average of the k-nearest neighbours.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Naive Bayes classifier&lt;/strong&gt; spam filters use this algorithm which is similar to KNN; you train your classifier on some data (e.g. "legit email subject" = not spam / "you won $ sign up now!!1" = spam). Naive Bayes figures out the probability that each word would show up in a spam email. This wouldn't work well for something like predicting the stock market, because there are no good features to use for regression.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;OCR (Optical Character Recognition)&lt;/strong&gt; Is when you take a photo of text and the computer can automatically read or digitise the text for you - 1. Learn on a bunch of images the features of a text character (this is called training), then 2. when you have a new image, extract the features and see what it's nearest neighbours are. Generally, OCR algorithms measure lines, points and curves. The same ideas are used for speech or face recognition.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
   Key Takeaways
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;em&gt;Dynamic programming&lt;/em&gt; is useful when you want to optimise given a constraint (e.g. the max value of goods you can fit in a bag). Use it when,&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;the problem can be broken into smaller problems&lt;/li&gt;
&lt;li&gt;the smaller problems don't depend on each other&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The values in the cells are (usually) what you want to optimise&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Theres no single formula for calculating a &lt;em&gt;dynamic programming solution&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;KNN is used for classification (categorising things into groups) and regression (predicting a response).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Feature extraction means converting an item into a comparable like a number.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Picking good features is important for KNN to be successful.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Discussion
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Can you think of any other real-world examples that might use dynamic programming to find a longest common sub-string? The examples in the chapter were &lt;a href="https://bio.libretexts.org/Bookshelves/Computational_Biology/Book%3A_Computational_Biology_-_Genomes_Networks_and_Evolution_(Kellis_et_al.)/02%3A_Sequence_Alignment_and_Dynamic_Programming/2.02%3A_Aligning_Sequences" rel="noopener noreferrer"&gt;DNA sequence alignment&lt;/a&gt;, &lt;a href="https://en.wikipedia.org/wiki/Line_wrap_and_word_wrap" rel="noopener noreferrer"&gt;word wrap&lt;/a&gt; in word processing, &lt;a href="https://www.atlassian.com/git/tutorials/saving-changes/git-diff" rel="noopener noreferrer"&gt;&lt;code&gt;git diff&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://en.wikipedia.org/wiki/Spell_checker" rel="noopener noreferrer"&gt;spell check&lt;/a&gt;, and &lt;a href="https://en.wikipedia.org/wiki/Content_similarity_detection" rel="noopener noreferrer"&gt;plagiarism detection&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Have you written a program using a dynamic programming formula - what did you learn when applying the formula in code? Did you use a grid?&lt;/li&gt;
&lt;li&gt;Have you worked on feature extraction? How were the features chosen? Were they the right features?&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>books</category>
      <category>algorithms</category>
      <category>bookclub</category>
      <category>discuss</category>
    </item>
    <item>
      <title>🩰 Schedule automated tests; become premier ballet artiste</title>
      <dc:creator>ruthmoog</dc:creator>
      <pubDate>Fri, 01 Sep 2023 08:52:08 +0000</pubDate>
      <link>https://dev.to/ruthmoog/scheduling-automated-tests-3p4l</link>
      <guid>https://dev.to/ruthmoog/scheduling-automated-tests-3p4l</guid>
      <description>&lt;p&gt;I've been checking this page of the Royal Opera House website everyday lately:&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%2Fuploads%2Farticles%2Fsvf4wwgvhh01t3y4blwf.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%2Fuploads%2Farticles%2Fsvf4wwgvhh01t3y4blwf.png" alt="Events page on the Royal Ballet's website"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;sup&gt;The website shows three sold-out workshops with The Royal Ballet.&lt;/sup&gt;



&lt;p&gt;There's three sold out events and I want to go to any one of them, so I am keeping an eye out for return tickets going on resale. But wait! Computers can help automate this...&lt;/p&gt;
&lt;h2&gt;
  
  
  1. Write a test to check the page automatically
&lt;/h2&gt;

&lt;p&gt;I am not sure how the page will look when a ticket goes back on sale, but I am confident that the page will change so that the header with the words "Sold out" do not appear 3 times. (I expect this will also decrease by 1 after any of the dates have passed - but I haven't written this into my test yet).&lt;/p&gt;

&lt;p&gt;I created an empty &lt;a href="https://vuejs.org/" rel="noopener noreferrer"&gt;Vue.js&lt;/a&gt; project - I don't need a UI, I just want to use tests, so Vue will create a dummy project for me.&lt;/p&gt;
&lt;h3&gt;
  
  
  Playwright
&lt;/h3&gt;

&lt;p&gt;I am going to use a browser based testing tool called &lt;a href="https://playwright.dev/" rel="noopener noreferrer"&gt;Playwright&lt;/a&gt; (But you could use &lt;a href="https://teamcapybara.github.io/capybara/" rel="noopener noreferrer"&gt;Capybara&lt;/a&gt;, or &lt;a href="https://www.selenium.dev/documentation/webdriver/" rel="noopener noreferrer"&gt;Selenium WebDriver&lt;/a&gt; etc.).&lt;/p&gt;

&lt;p&gt;First I'm going to write a 'Hello World' style test to make sure I am on the correct page.  When I navigate to the url, do I see the title I expect?&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="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;a hello world check that we have the right page&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;page&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;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;goto&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://www.roh.org.uk/tickets-and-events/dance-with-the-royal-ballet-dates&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toHaveTitle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/Dance with The Royal Ballet/&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;Then, I'll write my useful test. I want the headless browser to go to the webpage at the given URL. I'm using JavaScript, so I am going to make my test method &lt;code&gt;async&lt;/code&gt; and use &lt;code&gt;await&lt;/code&gt; for actions that will create a &lt;code&gt;Promise&lt;/code&gt; which needs to be fulfilled.&lt;/p&gt;

&lt;p&gt;I used the &lt;a href="https://developer.chrome.com/docs/devtools/open/" rel="noopener noreferrer"&gt;Chrome DevTools&lt;/a&gt; to investigate what elements are used for the "Sold out" text. The Inspect tool tells me this is a &lt;code&gt;h4&lt;/code&gt; and therefore it has the &lt;code&gt;heading&lt;/code&gt; Role.&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%2Fuploads%2Farticles%2F3gejrwkt161da8wqa840.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%2Fuploads%2Farticles%2F3gejrwkt161da8wqa840.png" alt="Use the inspect tool to find out a page elements role"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;sup&gt;The element has a 'heading' Role.&lt;/sup&gt;



&lt;p&gt;I use Playwright's &lt;code&gt;getByRole&lt;/code&gt; method with arguments describing that the role I want is a heading, with the exact text "Sold out".&lt;br&gt;
Then I can add an assertion that I expect there to be three sold out items on the page - I made sure to break my assertion to check that the test can fail, before using the correct assertion.&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="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;check for sold out items&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;page&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;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;goto&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://www.roh.org.uk/tickets-and-events/dance-with-the-royal-ballet-dates&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;soldOutItems&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getByRole&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;heading&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Sold out&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="c1"&gt;// Expects page to have three Sold out items.&lt;/span&gt;
  &lt;span class="c1"&gt;// If there are not 3 sold out items, there may be returns for sale!&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;soldOutItems&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toHaveCount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&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;&lt;a href="https://github.com/ruthmoog/ballert/blob/main/tests/example.spec.js" rel="noopener noreferrer"&gt;The test file on GitHub&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Trigger the test workflows on automated schedule
&lt;/h2&gt;

&lt;p&gt;I've pushed my changes to my GitHub repo, and use &lt;a href="https://docs.github.com/en/actions/using-workflows/about-workflows" rel="noopener noreferrer"&gt;Actions&lt;/a&gt; to set up an automatic test run.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;playwright.yml&lt;/code&gt; file is automatically configured to run when code is pushed or a pull-request is merged, and it will run the browser tests:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Playwright Tests&lt;/span&gt;
&lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;push&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;branches&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt; &lt;span class="nv"&gt;main&lt;/span&gt; &lt;span class="pi"&gt;]&lt;/span&gt;
  &lt;span class="na"&gt;pull_request&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;branches&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt; &lt;span class="nv"&gt;main&lt;/span&gt; &lt;span class="pi"&gt;]&lt;/span&gt;
&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;test&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;timeout-minutes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;60&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;...&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Run Playwright tests&lt;/span&gt;
      &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npx playwright test&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To run these tests on a schedule, I need to add another item within the on section:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;  &lt;span class="na"&gt;schedule&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;cron&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;  &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;1&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;1,10,15&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;*&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;*&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;*'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This uses the &lt;a href="https://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html#tag_20_25_07" rel="noopener noreferrer"&gt;POSIX cron syntax&lt;/a&gt; to add a schedule event. The example above will schedule the tests to run at 1 minute past 2am, 11am and 4pm local time (or, 01:01, 10:01, 15:01 UTC).&lt;/p&gt;

&lt;p&gt;The GitHub Actions docs explain &lt;a href="https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule" rel="noopener noreferrer"&gt;how to use schedule events to trigger workflows&lt;/a&gt;, including how the cron syntax works.&lt;/p&gt;

&lt;p&gt;For the time being, I have guessed which intervals to use - but I have contacted the box office about when tickets are released on the website, so that I can run the tests as few times as possible.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/ruthmoog/ballert/blob/main/.github/workflows/playwright.yml" rel="noopener noreferrer"&gt;Workflow configuration YAML on GitHub&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And with that, my alerts (&lt;em&gt;ballerts&lt;/em&gt;...) are done. GitHub will run my tests at the given times (deferring for heavy usage times) and their email notifications will let me know if there is a test failure and therefore that I should jump over to the website to try and buy a ticket (or update my test!).&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%2Fic.pics.livejournal.com%2Funbelievableme%2F20692558%2F1192847%2F1192847_original.gif" 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%2Fic.pics.livejournal.com%2Funbelievableme%2F20692558%2F1192847%2F1192847_original.gif" alt="*curtsy*"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;sup&gt;｡･:*:･ﾟ☆Graceful curtsy☆･ﾟ:*:･｡&lt;/sup&gt;



</description>
      <category>playwright</category>
      <category>yaml</category>
      <category>tests</category>
    </item>
    <item>
      <title>Book Club: Grokking Algorithms. 5: Dijkstra's algorithm, greedy algorithms</title>
      <dc:creator>ruthmoog</dc:creator>
      <pubDate>Tue, 29 Aug 2023 16:23:52 +0000</pubDate>
      <link>https://dev.to/ruthmoog/book-club-grokking-algorithms-5-dijkstras-algorithm-greedy-algorithms-1io9</link>
      <guid>https://dev.to/ruthmoog/book-club-grokking-algorithms-5-dijkstras-algorithm-greedy-algorithms-1io9</guid>
      <description>&lt;h4&gt;
  
  
  &lt;strong&gt;Grokking Algorithms&lt;/strong&gt; An &lt;em&gt;illustrated&lt;/em&gt; guide for programmers and other curious people, by Aditya Y. Bhargava
&lt;/h4&gt;




&lt;h2&gt;
  
  
  Chapter 7: Dijkstra's algorithm
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Chapter 8: Greedy algorithms
&lt;/h2&gt;

&lt;p&gt;If you read any of these chapters, please go ahead and discuss what you thought in the comments! &lt;/p&gt;

&lt;p&gt;📝 you can read my notes below.&lt;/p&gt;

&lt;p&gt;📆 The next post will be on chapters 9 - 10. I'll aim for September 2023.&lt;br&gt;
If you're on &lt;a href="https://app.thestorygraph.com/profile/ruthmoog" rel="noopener noreferrer"&gt;Storygraph&lt;/a&gt; and want to join me, say hi and I'll start a Buddy Read.&lt;/p&gt;




&lt;h2&gt;
  
  
  Dijkstra's algorithm
&lt;/h2&gt;

&lt;p&gt;key topics in this chapter: &lt;code&gt;weighted graphs&lt;/code&gt;, &lt;code&gt;unweighted graphs&lt;/code&gt;, &lt;code&gt;Dijstra's algorithm&lt;/code&gt;, &lt;code&gt;cycles&lt;/code&gt;, &lt;code&gt;positive and negative weighting&lt;/code&gt; ...&lt;/p&gt;

&lt;p&gt;The shortest path from A to B is not always the fastest path. Dijkstra's algo finds the fastest path, by assigning weight to the edges&lt;/p&gt;

&lt;h3&gt;
  
  
  Cycles
&lt;/h3&gt;

&lt;p&gt;A cycle means you can loop back to the same node.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Following the cycle never gives you the shortest path.&lt;/li&gt;
&lt;li&gt;An undirected graph is a cycle&lt;/li&gt;
&lt;li&gt;Dijkstra's algorithm only works on

&lt;ul&gt;
&lt;li&gt;graphs with no cycles&lt;/li&gt;
&lt;li&gt;graphs with a positive weight cycle (if the weight of a cycle is negative when looking for the shortest path, you'll be stuck in an infinite loop calculating around the ever decrementing cycle)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;Path found with &lt;strong&gt;Breadth-first search&lt;/strong&gt;:&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%2Fuploads%2Farticles%2F01x7ib5c07tqh3poo5uu.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%2Fuploads%2Farticles%2F01x7ib5c07tqh3poo5uu.png" alt="Breadth-first search"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Path found with &lt;strong&gt;Dijkstra's algorithm&lt;/strong&gt;:&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%2Fuploads%2Farticles%2F6auuxir3kt2bqeewk9cv.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%2Fuploads%2Farticles%2F6auuxir3kt2bqeewk9cv.png" alt="Djikstra's algorithm"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Greedy algorithms
&lt;/h2&gt;

&lt;p&gt;Key topics covered &lt;code&gt;Impossible problems&lt;/code&gt;, &lt;code&gt;NP-complete problems&lt;/code&gt;, &lt;code&gt;approximation algorithms&lt;/code&gt;, &lt;code&gt;greedy strategy&lt;/code&gt;, &lt;code&gt;sets&lt;/code&gt;, &lt;code&gt;union&lt;/code&gt;, &lt;code&gt;difference&lt;/code&gt;, &lt;code&gt;intersection&lt;/code&gt;, &lt;code&gt;fractorial function&lt;/code&gt;...&lt;/p&gt;

&lt;p&gt;This chapter covers a few scenarios where writing accurate algorithms is difficult. I found this the hardest to get my head around, because the example algorithms are not smart my mind was automatically trying to optimise the behaviour without realising it.&lt;/p&gt;

&lt;p&gt;Think I might need to revisit this chapter!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The classroom scheduling problem&lt;/strong&gt;: Find the most classes that can be held in the classroom by selecting whichever class ends first, then repeat starting after the previous classes end.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The knapsack problem&lt;/strong&gt;: If you use the process above to steal expensive items that weigh a lot for your knapsack, it won't give you the optimal solution ... but you'll get pretty close, and sometimes that's good enough.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The set-covering problem&lt;/strong&gt;: Make a &lt;em&gt;power set&lt;/em&gt; (calculate everything), then choose the best answer. It takes a long time to do this... O(2&lt;sup&gt;^n&lt;/sup&gt;)&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%2FegonSchiele%2Fgrokking_algorithms%2Fblob%2Fmaster%2Fimages%2F08_greedy_algorithms%2F084_np_complete_problems%2Fnum_routes_factorial.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%2FegonSchiele%2Fgrokking_algorithms%2Fblob%2Fmaster%2Fimages%2F08_greedy_algorithms%2F084_np_complete_problems%2Fnum_routes_factorial.png%3Fraw%3Dtrue" alt="number of factorial routes"&gt;&lt;/a&gt;&lt;/p&gt;
copyright Manning Publications, drawn by adit.io



&lt;p&gt;&lt;strong&gt;The travelling salesperson&lt;/strong&gt;: Find the most efficient route between &lt;em&gt;x&lt;/em&gt; calling points. The number of possible routes becomes very big, very fast (fractorial function)&lt;/p&gt;

&lt;h3&gt;
  
  
  NP-completeness
&lt;/h3&gt;

&lt;p&gt;To figure if a problem is NP-complete, look for...&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Algorithm runs quickly with a few items but slowly with a lot of items&lt;/li&gt;
&lt;li&gt;"All combinations of x" usually suggests NP-completeness, combinations can't be broken into smaller solvable sub-problems&lt;/li&gt;
&lt;li&gt;Involves a &lt;code&gt;set&lt;/code&gt; and is hard to solve&lt;/li&gt;
&lt;li&gt;You can restate the problem as the &lt;em&gt;set-covering problem&lt;/em&gt; or the &lt;em&gt;travelling salesperson problem&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
   Key Takeaways
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Use Breadth-first search for the cheapest path in an unweighted graph, and Dijkstra's algorithm for the cheapest path in a weighted graph&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you have negative weights use Bellman-Ford algorithm and not Dijkstra's algorithm&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Sets have some cool behaviours&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Intersection (select items in BOTH sets)&lt;/li&gt;
&lt;li&gt;Union (select all items)&lt;/li&gt;
&lt;li&gt;Difference (select items NOT in both sets)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;NP-complete problems are when you calculate all scenarios to figure out the shortest/smallest one&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;e.g. the travelling salesperson, set-coverage problem&lt;/li&gt;
&lt;li&gt;they have no known fast solution at scale&lt;/li&gt;
&lt;li&gt;it's best to use an approximation algorithm instead&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Greedy algorithms hope to end up with a global optimum, but optimising locally&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;they're easy to write and fast to run so they make good approximation algorithms&lt;/li&gt;
&lt;li&gt;Greedy algorithms: at each step, pick the optimal move&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;




</description>
      <category>books</category>
      <category>algorithms</category>
      <category>bookclub</category>
    </item>
  </channel>
</rss>
