# dynamic programming

Published articles for dynamic programming.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Why Dynamic Programming Failed for a Woodworking Project

DevFeed: [Why Dynamic Programming Failed for a Woodworking Project](<https://devfeed.tech/articles/dynamic-programming-fail-40509.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/shortform/2024-09-12-1502/>)

Published: 2024-09-12T22:02:05Z

Content type: opinion

Language: en

Sources: [Jeremy Kun](<https://devfeed.tech/sources/jeremy-kun.md>)

Topics: [Programming](<https://devfeed.tech/topics/programming.md>), [Algorithms](<https://devfeed.tech/topics/algorithms.md>)

Tags: [algorithms](<https://devfeed.tech/tags/algorithms.md>), [dynamic-programming](<https://devfeed.tech/tags/dynamic-programming.md>), [programming](<https://devfeed.tech/tags/programming.md>), [shortform](<https://devfeed.tech/tags/shortform.md>), [woodworking](<https://devfeed.tech/tags/woodworking.md>)

### AI overview

The author describes applying a dynamic programming approach to determine how 2x4 and 2x6 planks could fill a shed floor width. Variations in actual lumber dimensions and board straightness made the exact calculation unreliable, so the author ripped the final board to fit. The experience is presented as a practical contrast to idealized exact-coin-change problems in introductory algorithms courses.

### Source excerpt

This is a story about a failure to apply dynamic programming to a woodworking project. I've been building a shed in my backyard, and for one section I decided to build the floor by laying 2x4 planks side by side. I didn't feel the need to join them with tongue-and-groove, but I did notice that using 2x4s alone wouldn't fit the width they were supposed to fill. I also had some 2x6 boards left over from a different part of the shed, and I realized that gave a neat dynamic programming problem: Can you fill a given width by laying planks of standard dimensional lumber?

## Complete Sequences and Magic Tricks

DevFeed: [Complete Sequences and Magic Tricks](<https://devfeed.tech/articles/complete-sequences-and-magic-tricks-40288.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2012/10/02/complete-sequences-and-magic-tricks/>)

Published: 2012-10-02T11:28:16Z

Content type: tutorial

Language: en

Sources: [Jeremy Kun](<https://devfeed.tech/sources/jeremy-kun.md>)

Topics: [Sequences](<https://devfeed.tech/topics/sequences.md>), [Algorithm](<https://devfeed.tech/topics/algorithm.md>), [JavaScript](<https://devfeed.tech/topics/javascript.md>), [Code](<https://devfeed.tech/topics/code.md>), [Programming](<https://devfeed.tech/topics/programming.md>)

Tags: [algorithm](<https://devfeed.tech/tags/algorithm.md>), [code](<https://devfeed.tech/tags/code.md>), [dynamic-programming](<https://devfeed.tech/tags/dynamic-programming.md>), [greedy-algorithm](<https://devfeed.tech/tags/greedy-algorithm.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [mathematics](<https://devfeed.tech/tags/mathematics.md>), [numberphile](<https://devfeed.tech/tags/numberphile.md>), [primes](<https://devfeed.tech/tags/primes.md>), [programming](<https://devfeed.tech/tags/programming.md>), [sequences](<https://devfeed.tech/tags/sequences.md>)

### AI overview

This tutorial explains complete integer sequences through a card trick inspired by a Numberphile video. It presents a greedy algorithm that generates the cards and selects the smallest representation of each number, then shows how to implement the method in JavaScript.

### Source excerpt

Numberphile posted a video today describing a neat trick based on complete sequences: The mathematics here is pretty simple, but I noticed at the end of the video that Dr. Grime was constructing the cards by hand, when really this is a job for a computer program. I thought it would be a nice warmup exercise (and a treat to all of the Numberphile viewers) to write a program to construct the cards for any complete sequence.

## Dynamic Time Warping for Sequence Comparison

DevFeed: [Dynamic Time Warping for Sequence Comparison](<https://devfeed.tech/articles/dynamic-time-warping-for-sequence-comparison-40281.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2012/07/25/dynamic-time-warping/>)

Published: 2012-07-25T20:11:39Z

Content type: tutorial

Language: en

Sources: [Jeremy Kun](<https://devfeed.tech/sources/jeremy-kun.md>)

Topics: [Sequences](<https://devfeed.tech/topics/sequences.md>), [Python](<https://devfeed.tech/topics/python.md>), [coding](<https://devfeed.tech/topics/coding.md>), [math](<https://devfeed.tech/topics/math.md>)

Tags: [dynamic-programming](<https://devfeed.tech/tags/dynamic-programming.md>), [function](<https://devfeed.tech/tags/function.md>), [lambda](<https://devfeed.tech/tags/lambda.md>), [math](<https://devfeed.tech/tags/math.md>), [mathematics](<https://devfeed.tech/tags/mathematics.md>), [matrix](<https://devfeed.tech/tags/matrix.md>), [min](<https://devfeed.tech/tags/min.md>), [programming](<https://devfeed.tech/tags/programming.md>), [python](<https://devfeed.tech/tags/python.md>), [range](<https://devfeed.tech/tags/range.md>), [return](<https://devfeed.tech/tags/return.md>), [sequences](<https://devfeed.tech/tags/sequences.md>)

### AI overview

This tutorial explains dynamic time warping for comparing sequences of different lengths when their features may occur at different times or rates. It presents a Python implementation using a cost matrix and dynamic programming, with a local numeric distance based on absolute difference.

### Source excerpt

Problem: Write a program that compares two sequences of differing lengths for similarity. Solution: (In Python) import math def dynamicTimeWarp(seqA, seqB, d = lambda x,y: abs(x-y)): # create the cost matrix numRows, numCols = len(seqA), len(seqB) cost = [[0 for _ in range(numCols)] for _ in range(numRows)] # initialize the first row and column cost[0][0] = d(seqA[0], seqB[0]) for i in xrange(1, numRows): cost[i][0] = cost[i-1][0] + d(seqA[i], seqB[0]) for j in xrange(1, numCols): cost[0][j] = cost[0][j-1] + d(seqA[0], seqB[j]) # fill in the rest of the matrix for i in xrange(1, numRows): for j in xrange(1, numCols): choices = cost[i-1][j], cost[i][j-1], cost[i-1][j-1] cost[i][j] = min(choices) + d(seqA[i], seqB[j]) for row in cost: for entry in row: print "%03d" % entry, print "" return cost[-1][-1] Discussion: Comparing sequences of numbers can be tricky business.

## Word Segmentation with Google's N-Gram Corpus

DevFeed: [Word Segmentation with Google's N-Gram Corpus](<https://devfeed.tech/articles/word-segmentation-or-makingsenseofthis-40255.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2012/01/15/word-segmentation/>)

Published: 2012-01-15T11:10:51Z

Content type: tutorial

Language: en

Sources: [Jeremy Kun](<https://devfeed.tech/sources/jeremy-kun.md>)

Topics: [Programming](<https://devfeed.tech/topics/programming.md>), [Algorithm](<https://devfeed.tech/topics/algorithm.md>), [Google](<https://devfeed.tech/topics/google.md>), [Code](<https://devfeed.tech/topics/code.md>), [Python](<https://devfeed.tech/topics/python.md>)

Tags: [algorithm](<https://devfeed.tech/tags/algorithm.md>), [article](<https://devfeed.tech/tags/article.md>), [code](<https://devfeed.tech/tags/code.md>), [dynamic-programming](<https://devfeed.tech/tags/dynamic-programming.md>), [google](<https://devfeed.tech/tags/google.md>), [linguistics](<https://devfeed.tech/tags/linguistics.md>), [mathematics](<https://devfeed.tech/tags/mathematics.md>), [naive-bayes](<https://devfeed.tech/tags/naive-bayes.md>), [ngrams](<https://devfeed.tech/tags/ngrams.md>), [programming](<https://devfeed.tech/tags/programming.md>), [python](<https://devfeed.tech/tags/python.md>)

### AI overview

This tutorial explains word segmentation, counts the exponentially many possible segmentations, and introduces a dynamic-programming approach using a simple model based on a subset of Google's n-gram corpus.

### Source excerpt

A First Look at Google's N-Gram Corpus In this post we will focus on the problem of finding the appropriate word boundaries in strings like "homebuiltairplanes", as is common in web URLs like www.homebuiltairplanes.com. This is an interesting problem because humans do it so easily, but there is no obvious programmatic solution. We will begin this article by addressing the complexity of this problem, continue by implementing a simple model using a subset of Google's n-gram corpus, and finish by describing our future plans to enhance the model.

## A Spoonful of Python (and Dynamic Programming)

DevFeed: [A Spoonful of Python (and Dynamic Programming)](<https://devfeed.tech/articles/a-spoonful-of-python-and-dynamic-programming-40254.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2012/01/12/a-spoonful-of-python/>)

Published: 2012-01-12T23:11:26Z

Content type: tutorial

Language: en

Sources: [Jeremy Kun](<https://devfeed.tech/sources/jeremy-kun.md>)

Topics: [Python](<https://devfeed.tech/topics/python.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [Algorithm](<https://devfeed.tech/topics/algorithm.md>)

Tags: [dynamic-programming](<https://devfeed.tech/tags/dynamic-programming.md>), [fibonacci](<https://devfeed.tech/tags/fibonacci.md>), [memoized-recursion](<https://devfeed.tech/tags/memoized-recursion.md>), [primer](<https://devfeed.tech/tags/primer.md>), [python](<https://devfeed.tech/tags/python.md>), [recursion](<https://devfeed.tech/tags/recursion.md>)

### AI overview

A Python primer covering built-in types such as lists, tuples, and dictionaries, with examples involving Fibonacci numbers and optimal coin change. It introduces dynamic programming and compares inefficient recursive and recursionless approaches.

### Source excerpt

This primer is a third look at Python, and is admittedly selective in which features we investigate (for instance, we don't use classes, as in our second primer on random psychedelic images). We do assume some familiarity with the syntax and basic concepts of the language. For a first primer on Python, see A Dash of Python. We'll investigate some of Python's useful built-in types, including lists, tuples, and dictionaries, and we use them to computing Fibonacci numbers and "optimal" coin change.

## Metrics on Words

DevFeed: [Metrics on Words](<https://devfeed.tech/articles/metrics-on-words-40250.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2011/12/19/metrics-on-words/>)

Published: 2011-12-19T20:59:31Z

Content type: tutorial

Language: en

Sources: [Jeremy Kun](<https://devfeed.tech/sources/jeremy-kun.md>)

Topics: [Mathematics](<https://devfeed.tech/topics/mathematics.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [Algorithms](<https://devfeed.tech/topics/algorithms.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [algorithms](<https://devfeed.tech/tags/algorithms.md>), [analysis](<https://devfeed.tech/tags/analysis.md>), [code](<https://devfeed.tech/tags/code.md>), [decoding](<https://devfeed.tech/tags/decoding.md>), [dynamic-programming](<https://devfeed.tech/tags/dynamic-programming.md>), [functional-programming](<https://devfeed.tech/tags/functional-programming.md>), [github](<https://devfeed.tech/tags/github.md>), [levenshtein-distance](<https://devfeed.tech/tags/levenshtein-distance.md>), [linguistics](<https://devfeed.tech/tags/linguistics.md>), [mathematics](<https://devfeed.tech/tags/mathematics.md>), [metric](<https://devfeed.tech/tags/metric.md>), [monoids](<https://devfeed.tech/tags/monoids.md>), [ngrams](<https://devfeed.tech/tags/ngrams.md>), [optimization](<https://devfeed.tech/tags/optimization.md>), [programming](<https://devfeed.tech/tags/programming.md>), [python](<https://devfeed.tech/tags/python.md>), [string](<https://devfeed.tech/tags/string.md>)

### AI overview

This introductory article defines finite strings over an alphabet and explains that they form a monoid under concatenation, with the empty string as the identity element. It introduces a series on probabilistic analysis of Google's ngrams for tasks including spelling correction, word segmentation, typing prediction, and cipher decoding.

### Source excerpt

We are about to begin a series where we analyze large corpora of English words. In particular, we will use a probabilistic analysis of Google's ngrams to solve various tasks such as spelling correction, word segmentation, on-line typing prediction, and decoding substitution ciphers. This will hopefully take us on a wonderful journey through elementary probability, dynamic programming algorithms, and optimization. As usual, the code implemented in this post is available from this blog's Github page, and we encourage the reader to use the code to implement our suggested exercises.