<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Agi Letkiewicz Tanner on Medium]]></title>
        <description><![CDATA[Stories by Agi Letkiewicz Tanner on Medium]]></description>
        <link>https://medium.com/@altanner?source=rss-a0374f23c93e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*TNitGb1gcNhuYfOYi0h3yQ.jpeg</url>
            <title>Stories by Agi Letkiewicz Tanner on Medium</title>
            <link>https://medium.com/@altanner?source=rss-a0374f23c93e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 15:14:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@altanner/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How we built a one-shot PR creator at Inkitt]]></title>
            <link>https://medium.com/inkitt-tech/how-we-built-a-one-shot-pr-creator-at-inkitt-e1b8dbc52cda?source=rss-a0374f23c93e------2</link>
            <guid isPermaLink="false">https://medium.com/p/e1b8dbc52cda</guid>
            <category><![CDATA[ai-workflow-automation]]></category>
            <category><![CDATA[ai-workflow]]></category>
            <dc:creator><![CDATA[Agi Letkiewicz Tanner]]></dc:creator>
            <pubDate>Wed, 26 Aug 2026 22:24:13 GMT</pubDate>
            <atom:updated>2026-08-26T22:24:13.281Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i7e783IUxz7dr_Z-dqjrAg.png" /></figure><p>The classic problem: small tasks take more than their fair share of resources because the context switch costs more than the change itself.</p><p>As models keep improving, taking some of those well-defined tasks from idea to completion with no human input is now genuinely possible. Developers can run these end-to-end workflows on their machines, but that still spends developer time (a constrained resource). In principle anyone in the business could run one, but local machine setup is a wall for most people.</p><p><strong>So we set out to build a one-shot PR creator for low-risk, small-blast-radius tasks that runs on remote servers instead. You ask our agent in Slack or add a label in Linear and you get a PR ready for testing and review.</strong></p><p>Here is how we did it.</p><h3>Some ground rules</h3><ul><li>Don’t pay for idle resources. The expensive part should only exist while it’s working.</li><li>Access is the absolute minimum needed.</li><li>Production data and apps are guarded against unintended actions and bugs.</li><li>Rejecting is a feature. Risky, large or ambiguous tasks are not attempted.</li></ul><h3>Key design choices</h3><p><strong>1. A loop, not a pipeline</strong></p><p>A single orchestrator listens for events and runs stages. Each stage is one container with a model in it, one prompt, and one job: turn the request into a spec, write the change, check the change against the spec, fix CI, resolve a conflict.</p><p>The orchestrator’s core is a pure function (run state, event) -&gt; next action. No network, no database, no model call. A run is one row in a database and the loop can be picked up mid-flight.</p><p>The main guardrails live in ordinary code, not in the model’s judgement: two verify rounds, two CI fix attempts, two goes at a merge conflict. We also enforce hard rules on what a change may touch: no DB migrations or schema changes, no shared contract changes, no CI or container-build config, no auth or payment code, and no package additions or updates.</p><p><strong>2. The agent containers have no access to the outside world</strong></p><p>The orchestrator holds the credentials. It posts to Linear and Slack, opens PRs, applies labels, and pushes to shared branches. The containers running agents hold only a short-lived repo token and a model key. No Slack token, no Linear key, no cloud identity, and no tools for making arbitrary network calls.</p><p>So a stage can read code and write code. It cannot file a ticket, open a PR, message anyone, or fetch something off the internet. Everything that leaves the building goes through the orchestrator, which means there is one place where actions reach the outside world, and one place to audit.</p><p>It also means the guardrails don’t run on the honor system. The check for “did this change touch a file it isn’t allowed to touch?” reads the diff from git, not from the agent’s own report of what it changed.</p><p><strong>3. The user is the bot</strong></p><p>Linear, GitHub and Slack all see a single bot account. The big advantage is permissions: the bot can be granted far less than a typical dev. It can’t force-push, can’t bypass branch protection, can’t merge its own work, and can’t touch the paths we’ve marked off-limits.</p><p>It also keeps attribution honest. The commits are the bot’s, and every message the bot sends names the human who asked for the run.</p><p>The last checkpoint stays human. PRs open as drafts. The requester is notified when a PR has passed CI checks and the changes are live in staging, ready for testing. Marking it <em>Ready for review</em> is the moment a human vouches for it. The bot suggests reviewers in plain text, but the human does the requesting and the approving.</p><h3>The full architecture, in summary</h3><p><strong>A trigger. </strong>A Linear label, a Slack mention, or an API call from another agent. All three come through one front door, authenticated and deduped.</p><p><strong>A long-lived orchestrator.</strong> Small and mostly asleep. It decides the next action, performs every side effect, and owns every credential.</p><p><strong>Short-lived stage containers.</strong> One per step, started on demand, alive for minutes, then gone.</p><p><strong>One row per run.</strong> Anything that must happen at most once — claiming the branch, the PR number, the next retry attempt — is won in a single conditional write. Duplicate deliveries are routine, so the loser of the race stops instead of starting a second container.</p><p><strong>A path gate, run twice.</strong> We check for paths we’ve marked off-limits once before any code is written, and again on the real diff before the PR opens.</p><p><strong>All outputs from the orchestrator.</strong> Linear ticket and status, draft PR with labels and suggested reviewers, the staging build, the Slack message.</p><p><strong>The run itself is one line:</strong></p><pre>intake → gate → implement → verify → gate → review → ticket → draft PR → build → CI green → done</pre><p>Everything else is a detour that rejoins it. A failed verify goes back to implement. Red CI goes to a fix stage. A conflicted cherry-pick goes to a resolver. Each detour twice at most, then it stops and says why.</p><h3>Two things that surprised us</h3><p><strong>The model was the easy part.</strong> Almost all of the difficulty was in the boring stuff: idempotency, locks, retry budgets, and who is allowed to say what.</p><p><strong>Writing to a tool that webhooks can trigger is a loop waiting to happen.</strong> Filtering and de-duping is key, because Linear and GitHub webhooks are noisy. CI completion events, for example, fire on every CI job, not once per PR. So to know whether all of a PR’s jobs have actually finished, we call back to the GitHub API and ask, rather than taking action on every event that arrives.</p><h3>Where it is now</h3><p>This workflow ships code for us daily, sometimes moving a ticket from idea to done during the meeting that it was mentioned. There’s also a local “pro” version for tasks too big for one shot, where a human stays in the loop but the development process stays obfuscated.</p><p>With a more clear backlog and fewer interruptions, our dev team is freed up to think about the big, important problems. And that is the biggest unlock of the whole project.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e1b8dbc52cda" width="1" height="1" alt=""><hr><p><a href="https://medium.com/inkitt-tech/how-we-built-a-one-shot-pr-creator-at-inkitt-e1b8dbc52cda">How we built a one-shot PR creator at Inkitt</a> was originally published in <a href="https://medium.com/inkitt-tech">Inkitt Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Persistent Video Playback in Next.js]]></title>
            <link>https://medium.com/inkitt-tech/persistent-video-playback-in-next-js-09bc5c430548?source=rss-a0374f23c93e------2</link>
            <guid isPermaLink="false">https://medium.com/p/09bc5c430548</guid>
            <dc:creator><![CDATA[Agi Letkiewicz Tanner]]></dc:creator>
            <pubDate>Thu, 30 Oct 2025 22:21:00 GMT</pubDate>
            <atom:updated>2025-10-30T22:21:00.514Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H9jjrCXnm_WWrmskf0miLA.png" /></figure><p>Here at Inkitt we recently expanded CandyJar streaming to the web. One of the challenges we encountered was ensuring smooth transitions between episodes while maintaining a clean, maintainable architecture.</p><p>Using <strong>Next.js</strong> makes handling route changes straightforward — the framework efficiently repaints the DOM when moving between routes like series/:id/episode/:number. The results looked smooth out of the box, however browser limitations added some complexity. For instance, browsers only allow entering fullscreen mode in response to user actions. This means that <strong>unmounting the video player or changing its source between episodes would break fullscreen mode</strong>, leading to a jarring user experience.</p><p>In this post, we’ll share the architecture decisions we made to keep the video player mounted between episodes, while maintaining proper routing and code project structure. This is a foundational step toward leveraging <strong>Media Source Extensions (MSE)</strong> to allow continuous playback across episodes.</p><h3>State Management: Series Page ↔ Episode Page</h3><p>Initially, we deliberately avoided adding global state management tools like <strong>Redux</strong>, as the app didn’t require that level of complexity. But keeping a single video player mounted across episodes introduces a need to share state between components that don’t have a direct parent-child relationship.</p><h3>Options We Considered:</h3><ol><li><strong>Redux</strong>: Powerful but overkill for a single discrete feature.</li></ol><p><strong>2. React Context</strong>: Lightweight, built-in, and sufficient for our use case.</p><p>While React Context is generally not recommended for large-scale or frequently updated state due to potential performance issues, in this case, it works well because:</p><ul><li>The shared state is limited to one feature.</li><li>It won’t grow unpredictably.</li></ul><p>By using React Context, we can manage shared state — like the current episode or playback position — without introducing unnecessary complexity.</p><h3>Managing the UI</h3><p>The video player is now mounted on the <strong>series page layout</strong>, but the rest of the UI belongs to the <strong>episode page</strong>. Normally, one might consider a <strong>React portal</strong> to render the player in a different part of the DOM.</p><p>The catch: we <strong>cannot portal the video player into the episode page</strong> because the target DOM element would unmount and remount with every route change, defeating our goal of keeping the player persistent.</p><h3>Our Solution:</h3><p>We portal the <strong>episode page UI into the series layout</strong> instead. This keeps the video player mounted in the series layout while allowing the episode-specific UI and logic to live in the episode folder. This structure maintains clear separation of concerns while avoiding remounting issues.</p><p>The UI:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PWnW8hp5uYux8BsiBu9PHg.png" /></figure><p>The code structure:</p><pre>series/<br>└── [seriesId]/<br>    ├── layout.tsx  &lt;-- VideoPlayer mounted here<br>    │      │<br>    │      ├─ VideoPlayer Component<br>    │      │     (initialization &amp; playback state)<br>    │      │<br>    │      └─ Anchors for Episode UI (portaled content)<br>    │<br>    ├── page.tsx  &lt;-- Series logic here<br>    │      └─ fetch series metadata, episodes list, etc.<br>    │<br>    ├── providers/<br>    │      └─ PlayerContextProvider.tsx<br>    │            (provides shared video/episode state to layout &amp; children)<br>    │<br>    └── episode/<br>           └── [episodeNumber]/<br>                ├── page.tsx  &lt;-- Episode page logic<br>                │      ├─ Render portaled UI components into layout anchors<br>                │      └─ Fetch episode data<br>                │<br>                └── components/<br>                       ├─ EpisodeVideoContainer.tsx<br>                       │      (locked view / paid content)<br>                       │<br>                       └─ EpisodeBridge.tsx<br>                              (maps fetched episode data to PlayerContext state)</pre><h3>State Management: Video Player</h3><p>With the player now mounted for across episode navigation, we needed to carefully manage both the <strong>player instance</strong> and <strong>episode-specific data</strong>.</p><h3>Key Architectural Decisions:</h3><p><strong>Separate useEffects</strong> for:</p><ol><li><strong>Player initialization</strong> — configure Shaka Player, set up UI overlays, listen for errors.</li><li><strong>Episode loading</strong> — load the new video source, set up progress event listeners, update playback state.</li></ol><p>This separation ensures that the player instance is created only on mount while episode-specific logic listens for changes in episode data.</p><p><strong>Event listeners and reactive values</strong>: Variables passed to event listeners are not reactive, so you have two options:</p><ol><li>Destroy and recreate listeners</li><li>Use ref objects to store state that can be updated without re-registering listeners</li></ol><p>In the end we did both — destroyed the event listeners between episodes and created a ref for more frequently changing data (like current position).</p><h3>Conclusion</h3><p>Keeping a video player mounted between episodes in a Next.js app requires thoughtful architecture:</p><ul><li>Lightweight state sharing (React Context) for specific needs.</li><li>Strategic use of portals to manage UI without remounting the player.</li><li>Clear separation of player initialization and episode loading logic.</li></ul><p>These choices not only preserve fullscreen playback and improve the user experience but also set the stage for <strong>advanced features like continuous playback with Media Source Extensions</strong>.</p><p>By focusing on simplicity, maintainability, and modularity, we were able to provide a smooth, professional streaming experience on the web, matching the expectations set by mobile platforms.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=09bc5c430548" width="1" height="1" alt=""><hr><p><a href="https://medium.com/inkitt-tech/persistent-video-playback-in-next-js-09bc5c430548">Persistent Video Playback in Next.js</a> was originally published in <a href="https://medium.com/inkitt-tech">Inkitt Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Taming Circular Dependencies in TypeScript]]></title>
            <link>https://medium.com/inkitt-tech/taming-circular-dependencies-in-typescript-d63df1ec8c80?source=rss-a0374f23c93e------2</link>
            <guid isPermaLink="false">https://medium.com/p/d63df1ec8c80</guid>
            <dc:creator><![CDATA[Agi Letkiewicz Tanner]]></dc:creator>
            <pubDate>Tue, 17 Jun 2025 18:05:40 GMT</pubDate>
            <atom:updated>2025-06-17T18:05:40.011Z</atom:updated>
            <content:encoded><![CDATA[<h3>Background</h3><p>During our 2025 Spring Hackathon, we set out to migrate the Galatea app from vanilla React Native to Expo in order to improve build times and simplify native configuration.</p><p>The first time we optimistically tried expo run we hit a hard crash:</p><pre>Uncaught Error: apiRequest.getGoEndpoint is not a function (it is undefined)</pre><p>As far as we were concerned, getGoEndpoint is very much defined. The stack trace pointed to one of our API services, but the true culprit was an innocent-looking device info class being imported everywhere.</p><h4>Why did Expo surface the bug now?</h4><p>Expo Metro ships with a different default Metro configuration than React Native CLI, which can shift the timing of module evaluation in a circular dependency.</p><p>In Expo inlineRequires is not enabled by default and in React Native it is enabled by default, which can cause code execution order to change. See more information here: <a href="https://github.com/expo/expo/issues/27279">https://github.com/expo/expo/issues/27279</a></p><p>If React Compiler is enabled, this GitHub issue (open at time of writing) points out that cyclical dependencies can result in undefined imports: <a href="https://github.com/facebook/react/issues/32440">https://github.com/facebook/react/issues/32440</a></p><p>Because we didn’t have guardrails around preventing circular imports, we had 800+ of them. Most of these were benign, but the sheer number made it difficult to debug which are the ones that can cause undefined errors. Leaving them unaddressed would open us up to the risk of exposing latent cycles during any tooling upgrade, just like what are experiencing now.</p><h3>Finding the cycles fast</h3><p>To see a list of circular dependencies we used dpdm: <a href="https://github.com/acrazing/dpdm">https://github.com/acrazing/dpdm</a></p><p>Once this handy command line tool is installed with npm i -g dpdmyou can run dpdm — no-warning — no-tree -T **/*.ts to see a full list of dependencies.</p><p>To stop new ones coming in, eslint is your friend: eslint-plugin-import/no-cycle</p><h3>Three lessons</h3><p>After spending our hackathon dealing with circular dependencies, here are the takeaways.</p><h4>1 Avoid barrel files</h4><p>Barrels (index.ts files that re-export everything) guarantee that unrelated modules start depending on each other — and that’s fertile ground for cycles.</p><pre>// ❌ packages/user/index.ts<br>export * from &#39;./UserRepository&#39;;<br>export * from &#39;./CachedDeviceInfo&#39;; // &lt;- drags device layer into user layer</pre><pre>// ✅ explicit, layer-aware imports<br>import { UserRepository } from &#39;@data/user/UserRepository&#39;;<br>Pattern: Be explicit at module boundaries</pre><h4>2 Keep shared types in separate files</h4><p>If you always import types with import type instead of import it is safe to export values and types from the same file because then runtime values don’t get imported alongside type imports. However, it is easy to forget to do this and accidentally create circular dependencies.</p><p>It’s safer and more organized to keep shared types in their own files.</p><pre>// ❌ packages/network/Request.ts<br>export type RequestMeta = { deviceType: string };<br>export function sendRequest()</pre><pre>// ❌ packages/ui/SomeScreen.tsx<br>import { sendRequest, RequestMeta } from &#39;@network/Request&#39;; // runtime pulled in!</pre><p><strong>Safer:</strong></p><pre>// ✅ packages/network/types.ts<br>export type RequestMeta = { deviceType: string };</pre><pre>// ✅ packages/network/Request.ts<br>import type { RequestMeta } from &#39;./types&#39;;<br>export function sendRequest(meta: RequestMeta)</pre><pre>// ✅ packages/ui/SomeScreen.tsx<br>import type { RequestMeta } from &#39;@network/types&#39;;<br>Pattern: &quot;Types-only&quot; modules + import type keep the dependency graph pure.</pre><h4>3 Use dependency injection</h4><p>The bug that caused our crash was caused by a device info class which imports api services, that in turn imports services which require device info.</p><pre>DeviceInfo ─▶ apiServices ─▶ … ─▶ DeviceInfo (cycle)</pre><p>When two modules need each other’s data, the cure is to invert that relationship: push the shared dependency up to a higher-level layer and hand it down rather than importing it sideways.</p><p>In this case, DeviceInfo is a class for storing and providing data about the user’s device but also includes a side effect of storing some of the information on the backend. Instead of knowing about the api call, the consumer (the module that instantiates the DeviceInfo class) should retrieve device info and then pass it down to the api call. This would break the cycle.</p><pre>import { deviceInfoCache } from ‘./deviceInfo’;<br>import { sendDeviceInfoToBackend } from &#39;./api&#39;;<br><br>// The app (a higher-level module) coordinates the two<br>function initializeApp() {<br>  const deviceInfo = deviceInfoCache.init();<br>  sendDeviceInfoToBackend(deviceInfo);<br>}<br><br>initializeApp();</pre><p>This change is all that is needed because the data here is relatively static. But if we needed to update the data and have reactivity, React Context is a React-specific way to achieve dependency injection. Mark Erikson (a Redux maintainer) gives great detail about Context patterns here: <a href="https://blog.isquaredsoftware.com/2021/01/context-redux-differences/">https://blog.isquaredsoftware.com/2021/01/context-redux-differences/</a></p><h3>Summary</h3><p>During the hackathon we thought we would work on a tooling upgrade but ended up paying down important technical debt.</p><p>What we accomplished:</p><ul><li>Cataloged cycles with dpdm</li><li>Reduced cycles by 15% and identified the production-blocking cycles</li></ul><p>The next steps are to put guardrails in place to make sure that new cycles get kept out.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d63df1ec8c80" width="1" height="1" alt=""><hr><p><a href="https://medium.com/inkitt-tech/taming-circular-dependencies-in-typescript-d63df1ec8c80">Taming Circular Dependencies in TypeScript</a> was originally published in <a href="https://medium.com/inkitt-tech">Inkitt Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Successfully Planning a Coding Project]]></title>
            <link>https://medium.com/@altanner/successfully-planning-a-coding-project-fd94c8939f22?source=rss-a0374f23c93e------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd94c8939f22</guid>
            <dc:creator><![CDATA[Agi Letkiewicz Tanner]]></dc:creator>
            <pubDate>Tue, 13 Apr 2021 00:03:54 GMT</pubDate>
            <atom:updated>2021-04-13T00:06:26.805Z</atom:updated>
            <content:encoded><![CDATA[<p>I started learning to code a year ago, coming into software with a background in fashion buying, operations and marketing. Despite experience heavy in strategy and planning, I found myself making the classic mistake of jumping into coding too quickly before understanding the problem and making a plan.</p><p><strong>The common lesson</strong></p><p>Over the last year I have had the opportunity to work on personal projects, solo freelance work and work on project in a team environment. The common learning is that <strong>planning is key</strong>.</p><p><strong>Why is planning so crucial? </strong>It saves time, leads to better code and a better end product in general, gets a team on the same page as each other and saves a lot of frustration in the process of coding.</p><p>I wrote another blog post on the PEDAC problem solving framework, which helps me slow down and breakdown individual problems. In this post I want to talk about how I approach planning an entire project or feature.</p><ol><li><a href="#7a0c">Create user stories</a></li><li><a href="#9f47">Create subtasks</a></li><li><a href="#0e3b">Map the schema</a></li><li><a href="#2302">Create wireframes</a></li><li><a href="#cd4f">Write the code</a></li></ol><h3>Write the User Stories</h3><p>Starting with a clear, robust user story puts the user front and center of the app. Whether or not the project at hand will be monetized, it’s still important to put the user first to give context for development.</p><p>From my perspective, I think this is incredibly important even for the simplest app because it encourages creative problem solving. The best problem solving starts with thinking about the why and the intended end result, instead of going too quickly into the technical details.</p><p><strong>A user story describes one feature of an app, only focusing on the intended use and not at all about the implementation.</strong></p><p>Here is a framework:</p><blockquote><em>As a </em><em>&lt;type of user&gt;</em></blockquote><blockquote><em>I want </em><em>&lt;some goal&gt;</em></blockquote><blockquote><em>So that </em><em>&lt;some reason&gt;</em></blockquote><p>Write out one of these for every feature of the app. For example:</p><blockquote><em>“As the project owner, I want to assign tasks to team members to ensure the team is clear and the project will be completed.”</em></blockquote><h3>Create Subtasks</h3><p>Now that the user stories are mapped out, we can create subtasks under each one that outline the steps that need to be taken to complete the feature.</p><p>This will create a plan for building one feature at a time; getting it up and running and only then moving on to the next. This is the basis of agile development. Find more <a href="https://www.atlassian.com/agile/manifesto">here</a>.</p><p>Here is an example from one of my bootcamp projects:*</p><p><em>My domain is a goal tracking app that allows a user to create and track a tangible plan for achieving each of their personal goals.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q_hTNx-zXMtN0HRt3ip3sg.jpeg" /></figure><h3>Map the schema</h3><p>If you are working on a brand new project, the user stories and subtasks should give a good idea of what the models and associations needed in the database. Now is a great time in the planning process to map out to map these out using a service like <a href="https://www.draw.io/">draw.io</a> to visualize associations.</p><p>This is the schema for my example goals project:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*Sf-qFlYBcKG8_cAcBImbKQ.jpeg" /></figure><p>If you are working on a new feature for an existing project it is very possible that changes to the database are needed. If that is the case, map any new models and associations to the existing database.</p><h3>Create a Wireframe</h3><p>A wireframe is a visual representation of the intended framework of a website. You can create a basic one of these with no experience using an intuitive site like <a href="https://www.figma.com/">Figma</a>.</p><p>The importance of a wireframe is that it gives a visual guide of what to work toward. It’s much easier to move a box around with a curser than to write code to figure out if it looks right. Sometimes a low-fidelity wireframe is all that is needed, showing the content in the correct places on the screen.</p><p>Following on from my example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PZlLwjiDY3crxm-TFZlr0A.png" /><figcaption>Homepage/ User Show Page</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NzmW-NGGTMe7sQPpIHsMTA.png" /><figcaption>“Manage Goals” / Goal Index Page</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1ZPczcuysd1hZBSFsciJkQ.png" /><figcaption>Goal Show Page</figcaption></figure><p>Sometimes a high-fidelity wireframe is necessary. For example, I was working on a marketing site for a client. In this case, it was crucial to show her the full design and get her feedback and approval.</p><p>Example prototype, also made using Figma:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*ZVSs7LLG-gw3sy4o-BDM4w.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ykjgBOWzjlsxbPColm8KwQ.png" /></figure><h3>Write the Code</h3><p>Now that we have our plan in place, it’s time to write the code! With the user stories and subtasks in place we know what to build and in what order, and with our wireframes we have a north star to guide the design.</p><p>Finished product of my goals app:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*76jf6BjyiN2GrUSnyaf4cA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f6nxVgXafWA8d-iwvYsonQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lBUS6Mesuk_4CvZez2iYuw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd94c8939f22" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Airtable as a CMS]]></title>
            <link>https://medium.com/@altanner/using-airtable-as-a-cms-d52abf2de963?source=rss-a0374f23c93e------2</link>
            <guid isPermaLink="false">https://medium.com/p/d52abf2de963</guid>
            <dc:creator><![CDATA[Agi Letkiewicz Tanner]]></dc:creator>
            <pubDate>Tue, 30 Mar 2021 04:39:39 GMT</pubDate>
            <atom:updated>2021-03-30T04:39:39.116Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently I created a small business marketing website and came across a dilemma: I wanted to give the website owner control over their own content (saving them future development time and costs) but didn’t need a solution as complex as WordPress (along with the drawbacks).</p><p>I found a solution using Airtable and found it so easy and fun that I wanted to share!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4MkMrX8fVTMS7BBCBhKKtQ.jpeg" /></figure><h3><strong>What is Airtable?</strong></h3><p>Airtable is a cloud collaboration tool that can be used to create no-code relational databases that look and feel like spreadsheets. It can be used as a powerful and user-friendly collaboration tool for teams, with use cases such as a content calendar, product roadmap, event calendar and more.</p><h3>Why Airtable as a CMS?</h3><p>Having the website owner be able to update their own content without involving a developer is a big time and money saver. This of course is a big reason to use a content management system like WordPress, but sometimes you don’t need something so complex that comes with many drawbacks such as slower loading speed and decreased security.</p><p>I recently tried out using Airtable as a lightweight, simple CMS and was very pleased with the results.</p><p>With Airtable, each base (short for database) comes with its own API endpoint and can easily be shared with collaborators. Each base can have multiple tables that can be customized to your needs. For my recent project of a small business website I populated a table with the client’s text and images. To the client, the base feels like a regular spreadsheet making it easy to use.</p><h3>Step by step set up</h3><ol><li><strong>Sign up for Airtable and add a base</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pupqH43gXVqVVINpp50POA.png" /></figure><p>2. <strong>Decide on a format for your table and add content</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hHMQgn-ad5aHlL5FgR0LRw.png" /></figure><p>The free plan comes with 2GB of attachments and 1,200 records per base.</p><p>3. <strong>Go to help =&gt; API documentation</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JEU4aCy1k7ipF5aljkfOWw.png" /></figure><p>Here you will find your <strong>custom</strong> API documentation for the base, including the base ID and your API key for fetching the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pUBnWhuJcePnqaJRqgIFRA.png" /></figure><p>The response from the API is an array of objects, with each object being a row of the table. The content in each row is returned as the value to the key of fields.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yAxMyMYk0NZLa-ErJuwscA.png" /></figure><p>4. <strong>Go to Share =&gt; Add collaborators to give editing permissions to your team</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tX27FOF1j1qJj7s-R4tWyg.png" /></figure><p>5. <strong>Lock important fields </strong>(Pro plan)</p><p>Use the dropdown menu to edit permissions on fields, locking fields that you want to remain unchanged.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*zjYe0HSzNcMP3aRhJv3ucA.png" /></figure><h4>Voila! A simple CMS.</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d52abf2de963" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Two Pointer Technique Part 3]]></title>
            <link>https://medium.com/@altanner/two-pointer-technique-part-3-d0be7c7e95cd?source=rss-a0374f23c93e------2</link>
            <guid isPermaLink="false">https://medium.com/p/d0be7c7e95cd</guid>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[bootcamp]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Agi Letkiewicz Tanner]]></dc:creator>
            <pubDate>Tue, 23 Mar 2021 00:20:23 GMT</pubDate>
            <atom:updated>2021-03-23T00:20:23.797Z</atom:updated>
            <content:encoded><![CDATA[<p>I would like to expand on my series about the two pointer technique to talk about a more advanced subset of the technique: <strong>sliding window</strong>.</p><p>If you aren’t familiar with the two pointer technique, you can go back to <a href="https://medium.com/agi-coding-bootcamp/two-pointer-technique-and-arrays-985f740f00be">Part 1</a> and <a href="https://medium.com/agi-coding-bootcamp/two-pointer-technique-and-arrays-part-2-8ca030770b9d">Part 2.</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OYmGBClXiCGHg1d5Oj-AwA.jpeg" /></figure><h3>Defining sliding window</h3><p>The sliding window technique, like two pointer generally, is an algorithm that can be used to optimize brute force solutions that have O(n²) or O(n³) time complexity to O(n) time complexity.</p><p>The implementation involves forming a window over the data structure using two pointers. A key difference between this approach and a general two pointer is that we <em>care what data is contained between the two pointers</em>, not just the data at the two pointers themselves. The sliding window can be fixed (the length of the window never changes) or dynamic.</p><p><strong>Potential uses:</strong></p><ul><li>Calculating a running average or sum</li><li>Identifying the longest, shortest, or most optimal sequence that satisfies a given condition</li></ul><h3>Example problem</h3><p>To illustrate what sliding window looks like in practise, let’s look at LeetCode problem <a href="https://leetcode.com/problems/longest-substring-without-repeating-characters/">Longest Substring Without Repeating Characters</a>.</p><p>Prompt:</p><blockquote>Given a string s, find the length of the <strong>longest substring</strong> without repeating characters.</blockquote><p><strong>Sliding window clues:</strong></p><p>One strong clue that the sliding window algorithm can be used to solve this problem is the inclusion of keywords “substring” and “longest”. Based on these keywords, we are looking for a subsequence that meets a given condition.</p><p>We know that this is sliding window specifically (as opposed to a different implementation of the two pointer technique) because we care what is between the two pointers (looking for only unique characters).</p><p>The brute force solution to this problem of checking every possible substring for no duplicate characters would have a time complexity of O(n³). With sliding window we can optimize this to O(n).</p><p><strong>Data structure:</strong></p><p>Since we always care what is between the two pointers for this algorithm, to keep track of values we need a data structure. I work in JavaScript and the data structure that would most typically be used here is <strong>an object</strong>.</p><p>However, in this particular case the given condition is having <em>no repeating characters </em>so I think the best data structure is <strong>a Set</strong>. A Set is an object that lets you store unique values of any type and is new to ES6. I wrote a blog post about it <a href="https://medium.com/agi-coding-bootcamp/benefits-of-using-sets-in-javascript-382254dbfa4b">here</a>.</p><p><strong>Sliding window JavaScript solution:</strong></p><pre>var lengthOfLongestSubstring = function(s) {<br>        let seen = new Set;<br>        let p1 = 0;<br>        let longest = 0;<br>        <br>        for (let p2=0; p2&lt;s.length; p2++) {<br>            if (seen.has(s[p2])) {<br>                <br>                if (p2 - p1 &gt; longest) {<br>                    longest = p2 - p1;<br>                }<br>                <br>                while (seen.has(s[p2])) {<br>                    seen.delete(s[p1]);<br>                    p1++<br>                }<br>                    <br>            }<br>                <br>          seen.add(s[p2]);<br>        <br>        }<br>        <br>        return Math.max(longest, s.length - p1)<br>};</pre><p><strong>Breaking down the code:</strong></p><p>To create a sliding window we need two pointers. In this case I create a variable for the first pointer called p1 and my second pointer p2 is the index of each iteration through the input string.</p><p>I also need to keep track of the values I have in between my two pointers. For that I create a new Set object and store it in a variable called seen.</p><p>My second pointer p2 moves until a duplicate character is found. At that point, I know that everything between the two pointers, including the value at p1 but excluding the value at p2 is a valid substring that meets our condition. I check if this is the longest substring that I have seen so far, if so I store that length in the variable longest. Then, I move p1 until the duplicate value is removed from my Set.</p><p><strong>Time/space complexity</strong></p><p>This solution has a time complexity of O(n) (simplified from O(2n)) which is much better than the brute force of O(n³). It has a space complexity of O(k), where k is the size of the Set.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d0be7c7e95cd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Two Pointer Technique and Arrays, Part 2]]></title>
            <link>https://medium.com/@altanner/two-pointer-technique-and-arrays-part-2-8ca030770b9d?source=rss-a0374f23c93e------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ca030770b9d</guid>
            <category><![CDATA[bootcamp]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[algorithms]]></category>
            <dc:creator><![CDATA[Agi Letkiewicz Tanner]]></dc:creator>
            <pubDate>Tue, 16 Mar 2021 00:59:41 GMT</pubDate>
            <atom:updated>2021-03-16T00:59:41.603Z</atom:updated>
            <content:encoded><![CDATA[<p>This is the second post in a series about the two pointer technique, a technique for solving algorithm problems. Find the <a href="https://medium.com/agi-coding-bootcamp/two-pointer-technique-and-arrays-985f740f00be">first post here</a>.</p><p>In this post I will talk about using the two pointer technique for problems that include <strong>two sequences</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OYmGBClXiCGHg1d5Oj-AwA.jpeg" /></figure><p>In some other scenarios we need to compare in two sequences. Using the two pointer technique, each pointer represents the current position in the corresponding sequence.</p><p>To bring this to life, let’s work on the <a href="https://leetcode.com/problems/interval-list-intersections/">‘Interval List Intersections’ problem on LeetCode</a>.</p><p>Prompt:</p><blockquote>You are given two lists of closed intervals, firstList and secondList, where firstList[i] = [starti, endi] and secondList[j] = [startj, endj]. Each list of intervals is pairwise <strong>disjoint</strong> and in <strong>sorted order</strong>.</blockquote><blockquote>Return <em>the intersection of these two interval lists</em>.</blockquote><blockquote>-LeetCode</blockquote><p>The first example from the LeetCode prompt:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*0bYkxytOAFzM7if9TCOKVw.png" /><figcaption>From <a href="https://leetcode.com/problems/interval-list-intersections/">leetcode.com</a></figcaption></figure><h3>Why 2 pointer for this problem?</h3><p>One of the things that I like to ask myself when creating the pseudocode for an algorithm problem is: <em>how would I solve this problem outside of code?</em></p><p>Looking at the above intervals visually, I compare two at a time- one from List A and one from List B. If those overlap, I record the intersection. Then, I move on to compare another two until I get to the end.</p><p>With the above breakdown of the problem I see a clue that the two pointer technique can be useful. If I am comparing intervals two at a time, one from each sequence, I can use two pointers to keep track of the current position in the corresponding sequence.</p><h3>Pseudocode solution</h3><p>I think this problem is very visual, so to help create the pseudocode I drew an example, noting what I do step by step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1ZJ8fhrihwSuoGdTiBy9Sw.jpeg" /></figure><p>Step 1: I found an intersection, so I push that to a solution and move pointer for List A.</p><p>Step 2: There is no intersection. My current position is interval 1 from List B and interval 2 from List A. Because List B’s interval ends before List A’s interval starts, I move pointer for List B.</p><p>Step 3: Again no there is no intersection. My current position is interval 2 from List B and interval 2 from List A. Because List A’s interval ends before List B’s interval starts, I move pointer for List A.</p><p>Step 4: I found an intersection, so I push that to a solution and move pointer for List B.</p><p>Step 5: At step 4, the pointer for List B got to the end. This means we are finished.</p><p><strong>Let’s convert this to pseudocode:</strong></p><pre>Initialize an array to keep track of solution<br>Declare a variable for pointerA starting at Index 0<br>Declare a variable for pointerB starting at Index 0</pre><pre>If we have finished exploring either list, return the solution</pre><pre>While we are still exploring both lists:</pre><pre>   If interval B ends before interval A begins, increment pointerB</pre><pre>   If interval A ends before interval B begins, increment pointerA</pre><pre>   If neither of the above are true, we have found an intersection:</pre><pre>      The beginning of the intersection is the maximum of the starts<br>      The end of the intersection is the minimum of the ends<br>      Increment the pointer of the interval that ends first</pre><h3>JavaScript solution</h3><p>I converted the pseudocode to a solution using JavaScript. This can be refactored and I can use shorter names for the variable, but I wanted it to be as similar to the pseudocode as possible to start off with.</p><pre>var intervalIntersection = function(A, B) {<br>    let pointerA = 0;<br>    let pointerB = 0;<br>    <br>    let solution = [];<br>    <br>    while (pointerA &lt; A.length &amp;&amp; pointerB &lt; B.length) {<br>           if (B[pointerB][1] &lt; A[pointerA][0]) {<br>               pointerB++;<br>           } else if (A[pointerA][1] &lt; B[pointerB][0]) {<br>               pointerA++;<br>           } else {<br>               solution.push([Math.max(A[pointerA][0], B[pointerB][0]), Math.min(A[pointerA][1], B[pointerB][1])]);<br>               A[pointerA][1] &lt; B[pointerB][1] ? pointerA++ : pointerB++; <br>           }<br>          }<br>    <br>    return solution;</pre><pre>};</pre><p>The time and space complexities for this solution are both O(N+M), where N is the length of List A and M is the length of List B.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ca030770b9d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Double vs Triple Equals in JavaScript]]></title>
            <link>https://medium.com/@altanner/double-vs-triple-equals-in-javascript-c870377d2638?source=rss-a0374f23c93e------2</link>
            <guid isPermaLink="false">https://medium.com/p/c870377d2638</guid>
            <category><![CDATA[bootcamp]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Agi Letkiewicz Tanner]]></dc:creator>
            <pubDate>Tue, 09 Mar 2021 04:16:47 GMT</pubDate>
            <atom:updated>2021-03-09T04:16:47.993Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7qvE9jr9eKEWX2KArACYBA.png" /></figure><p>Being one year into my journey of learning JavaScript, some adages stick in my mind. One of these is “<em>always use triple equals for equality testing</em>”.</p><p>Today I want to explore why, and what the difference between === and == really means.</p><p>This is my summary of <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness">MDN documentation</a> on equality comparison.</p><h3>Definitions</h3><p>== <strong>The Equality Operator</strong></p><ul><li>aka “double equals”, aka “loose equality”</li><li>Uses the <a href="https://262.ecma-international.org/5.1/#sec-11.9.3">Abstract Equality Comparison Algorithm</a></li></ul><p>=== <strong>The Identity Operator</strong></p><ul><li>aka “triple equals”, aka “strict equality”</li><li>Uses the <a href="https://262.ecma-international.org/5.1/#sec-11.9.6">Strict Equality Comparison Algorithm</a></li></ul><h3>What is the difference?</h3><p>The comparison algorithms performed by the identify operator (===) and the equality operator (==) both first check the type of both operands (the subjects of the operation). If the types are the same, both algorithms check for equality of the values the same way.</p><p>The key difference is that if the types of the operands are different, an expression using strict equality (===) returns false. An expression using loose equality will first attempt to convert the values to a common type before continuing to check for equality.</p><p>A simple example:</p><pre>1 === 1<br>// <em>true</em></pre><pre>1 === &#39;1&#39;<br>// <em>false</em></pre><pre>1 === true <br>// <em>false<br></em></pre><pre>1 == 1<br>// <em>true</em></pre><pre>1 == &quot;1&quot;<br>// <em>true</em></pre><pre>1 == true<br>// <em>true</em></pre><p>In the above example, 1 is type number, “1” is type string and true is type boolean. Using strict equality, 1 is only equal to itself: 1. Using loose equality we convert type string (“1”) and type boolean (true) to a number. In both cases, both “1” and true converted to a number both equal 1.</p><h4>Exception for NaN</h4><p>“Not A Number” is a value of type number in JavaScript. Loose and strict equality treat NaN as unequal to everything, including itself.</p><pre>NaN === NaN <br>// <em>false</em></pre><pre>NaN == NaN <br>// <em>false</em></pre><h3>Converting values to a common type</h3><p>If an expression uses the equality operator (==) and the two operands are different types, the <a href="https://262.ecma-international.org/5.1/#sec-11.9.3">Abstract Equality Comparison Algorithm</a> will attempt to convert both values to a common type before performing the equality comparison.</p><h4>Null and undefined</h4><p>If one operand is null and the other is undefined, loose equality returns true</p><h4>Primitive Types</h4><p>If one operand is a number and the other is a string, or if either operand is a boolean, the algorithm uses <a href="https://262.ecma-international.org/5.1/#sec-9.3">the abstract operation </a><a href="https://262.ecma-international.org/5.1/#sec-9.3">ToNumber</a> to convert the string or boolean to a number</p><h4>Objects</h4><p>If either operand is an object, the algorithm <a href="https://262.ecma-international.org/5.1/#sec-9.1">uses the abstract operation </a><a href="https://262.ecma-international.org/5.1/#sec-9.1">ToPrimitive</a> to convert the object to a primitive to a non-object type</p><h3>When to use double equals vs triple equals</h3><p>From MDN documentation:</p><blockquote>In most cases, using loose equality is discouraged. The result of a comparison using strict equality is easier to predict, and may evaluate more quickly due to the lack of type coercion.</blockquote><p>There is some hot debate online about if == should be used at all. There are some specific use cases, one being if we want to check if a value is equal to either undefined or null.</p><p>There is negligible performance difference so that is not a reason to chose one over the other.</p><p>Considering that == can lead to bugs and there is no noticeable performance gain, it makes sense to default to === unless there is a strong use case to use ==.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c870377d2638" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Two Pointer Technique and Arrays]]></title>
            <link>https://medium.com/@altanner/two-pointer-technique-and-arrays-985f740f00be?source=rss-a0374f23c93e------2</link>
            <guid isPermaLink="false">https://medium.com/p/985f740f00be</guid>
            <dc:creator><![CDATA[Agi Letkiewicz Tanner]]></dc:creator>
            <pubDate>Tue, 23 Feb 2021 04:53:30 GMT</pubDate>
            <atom:updated>2021-03-16T01:00:28.752Z</atom:updated>
            <content:encoded><![CDATA[<h3>Two Pointer Technique and Arrays, Part 1</h3><p>The two pointer technique is very useful to understand for solving array problems efficiently.</p><p>To use the two pointer technique we use pointers to keep track of indices of an array, string or linked list. Today I am talking about the implementation for arrays.</p><p>A pointer is defined as a reference to an object. To use this technique we declare two local variables to use as pointers. We can use the pointers to explore two elements in an array at the same time, in contrast to using a nested loop to do the same.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7o3AqzuNqPH0jJ3uHCiJZQ.jpeg" /></figure><p>There are three main approaches that I want to go over to get started that don’t overlap with other more specific techniques.</p><ol><li><strong>Left/Right</strong>: One pointer starts at the beginning of the array and the other at the end. They move one at a time until they meet.</li><li><strong>Fast/Slow</strong>: One pointer moves faster than the other.</li><li><strong>Two Sequences</strong>: Each pointer represents the current position in the corresponding sequence.</li></ol><p>The two pointer technique can be extended to more advanced techniques such as sliding window and dynamic programming.</p><p><strong>The uses</strong> for two pointer are searching for pairs in a sorted array, array transformation or comparing two arrays to each other.</p><p><strong>The benefit</strong> of using a two pointer solution is that it improves on the brute force solution to comparing elements of an array to all other elements of that same array by using a nested loop (or multiple).</p><h3>Approach 1: pointers at the beginning and end of an array</h3><p>This approach is useful for searching for pairs in an array. Let’s look at the classic Two Sum problem that I wrote about previously <a href="https://medium.com/agi-coding-bootcamp/intro-to-algorithms-answer-to-the-two-sum-problem-using-javascript-93c01eef72af">here</a>. This problem is the perfect candidate for pointers:</p><blockquote>Given an array of integers nums and an integer target, return an array with the two integers that add up to the target in any order..</blockquote><blockquote>There will be at most one solution. If no solution exists, return an empty array.</blockquote><p><strong>Solution</strong></p><pre>function twoNumberSum(array, targetSum) {</pre><pre>  array.sort((a,b) =&gt; a-b)<br> <br>  let leftIdx = 0;<br>  let rightIdx = array.length - 1;<br> <br>  while (leftIdx &lt; rightIdx) {<br>    if (array[leftIdx] + array[rightIdx] === targetSum) {<br>      return [array[leftIdx], array[rightIdx]];<br>    } else if (array[leftIdx] + array[rightIdx] &lt; targetSum) {<br>      leftIdx++;<br>    } else {<br>      rightIdx--;<br>    }<br>  }<br> <br> return [];</pre><pre>}</pre><p><strong>Steps:</strong></p><ul><li>In this case, the input array is not necessarily sorted so we sort it. This techniques relies on a sorted array. Because the .sort method in JavaScript is destructive we can do so in place (assuming it is okay to mutate the original array. If not, we can make a copy first).</li><li>We declare a local variable for the first index and set it equal to 0 and declare a local variable or the last index and set it equal to the array’s length minus 1.</li><li>While the left index is smaller than the right index, we check to see if our 2 candidates (the numbers at those indices) are a match. If so, we return them. If the sum of the candidates is smaller than the target, we increase the left index. This is because we need our sum to be larger, and since the array is sorted increasing the left index will get us a larger number. If the sum is larger than the target, we decrease the right index.</li><li>If the left and right indices cross each other (the left index is larger than or equal to the right) then we have explored every number and return an empty array.</li></ul><p>The time complexity of this solution is O(nlogn) compared to the brute force O(n²) (a nested loop). This is because had to sort the input array. If we did not have to sort the time complexity would be O(n).</p><p>The space complexity is O(1).</p><h3>Approach 2: one pointer moves faster than the other</h3><p>This approach is typically used for linked lists but can also be useful for array transformation problems.</p><p>To implement this approach on an array, typically we declare a local variable and set it equal to 0, and then loop through the array. The variable acts as one pointer and the index of the loop acts as the second.</p><p>This can be used to solve problems such as <a href="https://leetcode.com/problems/remove-duplicates-from-sorted-array/">removing duplicates from an array</a> or moving elements in an array.</p><p>Let’s look at the <a href="https://leetcode.com/problems/move-zeroes/">Move Zeros</a> problem on Leetcode:</p><blockquote>Given an array nums, write a function to move all 0&#39;s to the end of it while maintaining the relative order of the non-zero elements.</blockquote><p>Let’s check out a two pointer <strong>solution:</strong></p><pre>var moveZeroes = function(nums) {<br>    let leftIdx = 0;<br>    <br>    for (let i=0; i&lt;nums.length; i++) {<br>        if (nums[i] !== 0) {<br>            if (leftIdx === i) {<br>                leftIdx++<br>                continue;<br>            }<br>            nums[leftIdx] = nums[i];<br>            nums[i] = 0;<br>            leftIdx++<br>        }<br>    }<br>};</pre><p><strong>Steps:</strong></p><ul><li>Declare a local variable for the first index and set it equal to 0.</li><li>Loop through the array, the index of the iteration is our second pointer.</li><li>When we encounter a 0, our first pointer (here called leftIdx) will keep track of the index. The other pointer continues. When we encounter a number that is not 0, we swap the numbers using the 2 pointers and move the left pointer. When the loop completes, all the zeros will be moved to the end.</li><li>Until we encounter the first zero, we can move both pointers and take no further action (what this block of code is doing: if(leftIdx === i)).</li></ul><p>This solution optimizes for both time (O(n) time) and space (O(1) space).</p><h3>Next post</h3><p><a href="https://medium.com/agi-coding-bootcamp/two-pointer-technique-and-arrays-part-2-8ca030770b9d">I talk about the approach involving 2 sequences on the next post in this series.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=985f740f00be" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Problem Solving with PEDAC]]></title>
            <link>https://medium.com/@altanner/problem-solving-with-pedac-3ab3c78f813e?source=rss-a0374f23c93e------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ab3c78f813e</guid>
            <dc:creator><![CDATA[Agi Letkiewicz Tanner]]></dc:creator>
            <pubDate>Tue, 16 Feb 2021 05:00:50 GMT</pubDate>
            <atom:updated>2021-02-16T23:53:59.090Z</atom:updated>
            <content:encoded><![CDATA[<p>PEDAC is a framework that can be used to break down complex coding problems.</p><blockquote>PEDAC has two primary objectives: <strong>process the problem</strong> (PEDA) and <strong>code with intent</strong> ©. - Launch School</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HB7aSeT8fKcZeTavViGB0A.jpeg" /></figure><p>I am writing about PEDAC because beyond the objectives laid out by Launch School, this framework has helped me <strong>vocalize my thought process.</strong></p><p>When working with others, whether it be on a group project or in a coding interview, it can be hard to talk and think at the same time. In this situation I found myself doing one of two things: falling silent or talking aimlessly. The former would leave the other party confused and the latter distracted from finding a solution.</p><p><strong>What I personally like about PEDAC is that it gives me a clear path to follow in solving complex problems so that I can find a solution and talk it out at the same time.</strong></p><p>In my experience following the PEDAC process I have created deeper understanding of the problem, found more edge cases and gotten to a solution faster.</p><p>I don’t claim that PEDAC is the only or even best process to follow, but it is a great tool to have in the toolkit. This is an overview to get you started. Let’s dive in!</p><h3>PEDAC stands for:</h3><ul><li><strong>P</strong>roblem</li><li><strong>E</strong>xamples</li><li><strong>D</strong>ata Structure</li><li><strong>A</strong>lgorithm</li><li><strong>C</strong>ode</li></ul><h3>Step by Step through PEDAC</h3><p>To use the PEDAC process we go through each step (Problem, Examples, Data Structure, Algorithm, Code) one by one in a linear way. Each step builds on the last. Along the way new insights or questions might come up, in which case we can go back to a previous step and continue again from there.</p><p><strong>Problem</strong>:</p><p>The goal of the first step is to make sure you understand the problem. Prompts should be read thoroughly and multiple times as every word is significant.</p><p>A nice checklist to go through is: list the <strong>inputs and outputs</strong>,<strong> </strong>restate the <strong>explicit requirements</strong>, identify <strong>implicit requirements</strong> (ask clarifying questions if necessary) and <strong>define</strong> every word, making sure you know exactly what it means.</p><p>When you have gone through this list, it’s beneficial to restate the problem in your own words in the simplest form possible.</p><p><strong>Examples:</strong></p><p>Clarify understanding of the problem by brainstorming multiple test cases. Make a list of inputs and the expected outputs.</p><p>This is the time to think through edge cases and ask clarifying questions about the expected output for the edge cases should be.</p><p><strong>Data Structure:</strong></p><p>Think of data structures that suit the problem and brainstorm pros and cons of each.</p><p>Depending on the problem, this may be quick and obvious or it might take some time to work through.</p><p><strong>Algorithm:</strong></p><p>Write a pseudocode solution to the problem. Go step by step in plain language so that the instructions can be converted to code. A great thing to think of here is: how would your brain solve this problem outside of programming?</p><p>This step is going to reveal if you missed something earlier. Go back if you need to, ask questions and think of alternatives.</p><p>This is not the time to think of the best solution possible. Focus on getting a solution working and then go back to refactor.</p><p><strong>Code:</strong></p><p>Finally time to write code! With all the time spent planning, this step should be much easier than if you jumped in right away.</p><p>Follow the algorithm you wrote to code the solution to the problem. Take the opportunity to validate along the way with console logs or return statements to make sure your code is working as intended.</p><p>Since the logic of the solution is already done, here you can focus on correct syntax and clean code (great variable names, proper indentation, etc).</p><p>Pro tip: console log your test cases from the ‘Example’ step to check that you are getting the expected results!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ab3c78f813e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>