<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Algorithms Q&amp;A - Recent questions in Dynamic Programming</title>
<link>https://notexponential.com/questions/dynamic-programming</link>
<description>Powered by Question2Answer</description>
<item>
<title>Selecting lowest cost hotel rooms, with no adjacent rooms selected</title>
<link>https://notexponential.com/772/selecting-lowest-cost-hotel-rooms-adjacent-rooms-selected</link>
<description>&lt;p&gt;&lt;span style=&quot;color:#000000; font-family:Calibri,sans-serif; font-size:11pt; line-height:16.8667px&quot;&gt;You and your friends (k friends in total, including yourself) are going to Hawaii for a vacation.&amp;nbsp; In Hawaii, you are given a choice of n hotel rooms, in a straight line, numbered from 1 to n.&amp;nbsp; The cost of the i-th room is c[i].&amp;nbsp; You can select any k hotel rooms, but you want to ensure that no two selected hotel rooms selected are adjacent to each other.&amp;nbsp; Your objective is to minimize the cost.&amp;nbsp; Describe an efficient algorithm for this problem.&lt;/span&gt;&lt;/p&gt;</description>
<category>Dynamic Programming</category>
<guid isPermaLink="true">https://notexponential.com/772/selecting-lowest-cost-hotel-rooms-adjacent-rooms-selected</guid>
<pubDate>Sat, 10 Dec 2022 20:43:44 +0000</pubDate>
</item>
<item>
<title>&quot;SpicyBitter&quot; Sequence of Sauces</title>
<link>https://notexponential.com/710/spicybitter-sequence-of-sauces</link>
<description>&lt;p&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;“SpicyBitter” Some people can handle spicy.&lt;span style=&quot;mso-spacerun:yes&quot;&gt;&amp;nbsp; &lt;/span&gt;Some people can tolerate bitter foods.&lt;span style=&quot;mso-spacerun:yes&quot;&gt;&amp;nbsp; &lt;/span&gt;You have access to n different kinds of sauces, with different levels of “spicyness” and bitterness.&lt;span style=&quot;mso-spacerun:yes&quot;&gt;&amp;nbsp; &lt;/span&gt;You are organizing a food festival and want to create a sequence of sauces such that each sauce is both SPICIER AND MORE BITTER than the sauce prior to that.&lt;span style=&quot;mso-spacerun:yes&quot;&gt;&amp;nbsp; &lt;/span&gt;You want to create as long a sequence as possible using the given list of sauces.&lt;span style=&quot;mso-spacerun:yes&quot;&gt;&amp;nbsp; &lt;/span&gt;Consider this kind of structure: “Sauce [spice: double, bitterness: double]”.&lt;span style=&quot;mso-spacerun:yes&quot;&gt;&amp;nbsp; &lt;/span&gt;You are given an array a[1..] of Sauce objects.&lt;span style=&quot;mso-spacerun:yes&quot;&gt;&amp;nbsp; &lt;/span&gt;Give an algorithm to create the longest possible sequence, and analyze the time complexity of your algorithm in terms of &lt;em&gt;n.&lt;/em&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;</description>
<category>Dynamic Programming</category>
<guid isPermaLink="true">https://notexponential.com/710/spicybitter-sequence-of-sauces</guid>
<pubDate>Tue, 16 Jun 2020 22:25:31 +0000</pubDate>
</item>
<item>
<title>Maximize value of coins from k stacks, of n coins each</title>
<link>https://notexponential.com/633/maximize-value-of-coins-from-k-stacks-of-n-coins-each</link>
<description>&lt;p&gt;&lt;span style=&quot;font-family:&amp;quot;Calibri&amp;quot;,sans-serif; font-size:11.0pt&quot;&gt;You are given&amp;nbsp;k stacks, of n coins each.&amp;nbsp; The value of i-th coin in j-th stack is given by v[i][j].&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:&amp;quot;Calibri&amp;quot;,sans-serif; font-size:11.0pt&quot;&gt;You play a game against an opponent by alternating turns. In each turn, a player selects one of the&amp;nbsp;top coins (the coin at the highest location of the stack), removes it&amp;nbsp;permanently, and receives the value of the coin. In each move, each person removes one coin only, and can not remove a coin that is not at the top of its stack.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:&amp;quot;Calibri&amp;quot;,sans-serif; font-size:11.0pt&quot;&gt;Design an algorithm to maximize the money value you can win if you move first.&lt;/span&gt;&lt;/p&gt;</description>
<category>Dynamic Programming</category>
<guid isPermaLink="true">https://notexponential.com/633/maximize-value-of-coins-from-k-stacks-of-n-coins-each</guid>
<pubDate>Wed, 10 Apr 2019 05:05:07 +0000</pubDate>
</item>
<item>
<title>Gold is a precious metal</title>
<link>https://notexponential.com/623/gold-is-a-precious-metal</link>
<description>&lt;p&gt;&lt;span style=&quot;color:#222222; font-family:Arial,Helvetica,sans-serif; font-size:small&quot;&gt;You are given a gold wire that is n feet long.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;You can cut the wire and sell the smaller pieces.&amp;nbsp; The value of smaller pieces of wire is not always proportional to the length of the wire.&amp;nbsp; You are given a mapping, p[1..m] of smaller lengths and the sell price of each, for example:&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;p[1].length = 4, p[1].value = 300,&amp;nbsp; // A piece of wire 4 feet long sells for 300$&lt;/p&gt;&lt;p&gt;p[2].length = 6, p[2].value = 400,&amp;nbsp; // A piece of wire 6 feet long sells for 400$&lt;/p&gt;&lt;p&gt;....&lt;/p&gt;&lt;p&gt;p[m].length = 11, p[m].value = 800&amp;nbsp; &amp;nbsp;// A piece of wire 11 feet long sells for 800 $&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;Give an algorithm to maximize the value that you can extract from the gold wire.&amp;nbsp; Keep in mind that gold is very expensive, so you want to ensure the absolute highest value that you can extract.&lt;/p&gt;</description>
<category>Dynamic Programming</category>
<guid isPermaLink="true">https://notexponential.com/623/gold-is-a-precious-metal</guid>
<pubDate>Fri, 29 Mar 2019 19:07:09 +0000</pubDate>
</item>
<item>
<title>1-D k-means clustering</title>
<link>https://notexponential.com/531/1-d-k-means-clustering</link>
<description>&lt;p&gt;&lt;span style=&quot;color:#000000; font-family:&amp;quot;Times New Roman&amp;quot;,stixgeneral,serif; font-size:15.9991px&quot;&gt;Let&amp;nbsp;&lt;/span&gt;&lt;em style=&quot;color:#000000; font-family:&amp;quot;Times New Roman&amp;quot;,stixgeneral,serif; font-size:15.9991px&quot;&gt;x&lt;/em&gt;&lt;span style=&quot;bottom:-0.25em; color:#000000; font-family:&amp;quot;Times New Roman&amp;quot;,stixgeneral,serif; font-size:0.8461em; line-height:1.6363em; position:relative; top:0.25em; vertical-align:baseline&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#000000; font-family:&amp;quot;Times New Roman&amp;quot;,stixgeneral,serif; font-size:15.9991px&quot;&gt;, . . . ,&amp;nbsp;&lt;/span&gt;&lt;em style=&quot;color:#000000; font-family:&amp;quot;Times New Roman&amp;quot;,stixgeneral,serif; font-size:15.9991px&quot;&gt;x&lt;span style=&quot;bottom:-0.25em; font-size:0.8461em; line-height:1.6363em; position:relative; top:0.25em; vertical-align:baseline&quot;&gt;n&lt;/span&gt;&lt;/em&gt;&lt;span style=&quot;color:#000000; font-family:&amp;quot;Times New Roman&amp;quot;,stixgeneral,serif; font-size:15.9991px&quot;&gt;&amp;nbsp;be an input array of&amp;nbsp;&lt;/span&gt;&lt;em style=&quot;color:#000000; font-family:&amp;quot;Times New Roman&amp;quot;,stixgeneral,serif; font-size:15.9991px&quot;&gt;n&lt;/em&gt;&lt;span style=&quot;color:#000000; font-family:&amp;quot;Times New Roman&amp;quot;,stixgeneral,serif; font-size:15.9991px&quot;&gt;&amp;nbsp;numbers sorted in non-descending order. The problem of 1-D&amp;nbsp;&lt;/span&gt;&lt;em style=&quot;color:#000000; font-family:&amp;quot;Times New Roman&amp;quot;,stixgeneral,serif; font-size:15.9991px&quot;&gt;k&lt;/em&gt;&lt;span style=&quot;color:#000000; font-family:&amp;quot;Times New Roman&amp;quot;,stixgeneral,serif; font-size:15.9991px&quot;&gt;-means clustering is defined as assigning elements of the input 1-D array into&amp;nbsp;&lt;/span&gt;&lt;em style=&quot;color:#000000; font-family:&amp;quot;Times New Roman&amp;quot;,stixgeneral,serif; font-size:15.9991px&quot;&gt;k&lt;/em&gt;&lt;span style=&quot;color:#000000; font-family:&amp;quot;Times New Roman&amp;quot;,stixgeneral,serif; font-size:15.9991px&quot;&gt;&amp;nbsp;clusters so that the sum of squares of within-cluster distances from each element to its corresponding cluster mean is minimized.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;</description>
<category>Dynamic Programming</category>
<guid isPermaLink="true">https://notexponential.com/531/1-d-k-means-clustering</guid>
<pubDate>Thu, 08 Mar 2018 18:35:27 +0000</pubDate>
</item>
<item>
<title>DNA sequences</title>
<link>https://notexponential.com/515/dna-sequences</link>
<description>Given two DNA sequences (sequences of A, C, T, G characters), the longest common subsequence (LCS) problem is to find the longest subsequence (not nescessarily contiguous) that exists in both of the input strings. For example, given strings &amp;quot;ACTGACT&amp;quot; and &amp;quot;CAAGCATA&amp;quot;, the subsequence &amp;quot;CGCT&amp;quot; is common in both. Given two DNA sequences of sizes n1 and n2 respectively, find a dynamic programming algorithm to find the longest common subsequence in O(n1n2) time.&lt;br /&gt;
&lt;br /&gt;
From the midterm practice</description>
<category>Dynamic Programming</category>
<guid isPermaLink="true">https://notexponential.com/515/dna-sequences</guid>
<pubDate>Sun, 04 Mar 2018 19:45:12 +0000</pubDate>
</item>
<item>
<title>If you are happy and you know it, jump up high!</title>
<link>https://notexponential.com/502/if-you-are-happy-and-you-know-it-jump-up-high</link>
<description>&lt;p&gt;You are standing on step 0 of a staircase. Your goal is to reach the step n. At each step i, you have three choices: hop to next step i+1, i+2 or i+3 Give an algorithm to count the number of possible paths to reach n.&lt;/p&gt;&lt;div class=&quot;qa-q-view-content qa-post-content&quot; style=&quot;word-break: break-word; margin-bottom: 16px; font-family: Helvetica, Arial, sans-serif; font-size: 14px;&quot;&gt;&lt;div&gt;Please provide the Notation, optimality, recurrence, and algorithm.&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;</description>
<category>Dynamic Programming</category>
<guid isPermaLink="true">https://notexponential.com/502/if-you-are-happy-and-you-know-it-jump-up-high</guid>
<pubDate>Sun, 04 Mar 2018 03:25:54 +0000</pubDate>
</item>
<item>
<title>Canoeing on the cheap</title>
<link>https://notexponential.com/500/canoeing-on-the-cheap</link>
<description>You are canoeing down a river and there are n renting posts along the way. Before starting your journey, you are given, for each 1 &amp;lt;= i &amp;lt;= j &amp;lt;= n, the fee f(i,j) for renting a canoe from post i to post j. &amp;nbsp;These fees are arbitrary. For example it is possible that f(1,3) = 10 and f(1,4) = 5. You begin at trading post 1 and must end at trading post n (using rented canoes). Your goal is to minimize the rental cost. Give the most efficient algorithm you can for this problem. Prove that your algorithm yields an optimal solution and analyze the time complexity.&lt;br /&gt;
&lt;br /&gt;
Please provide the Notation, optimality, recurrence, and algorithm.</description>
<category>Dynamic Programming</category>
<guid isPermaLink="true">https://notexponential.com/500/canoeing-on-the-cheap</guid>
<pubDate>Sun, 04 Mar 2018 03:18:45 +0000</pubDate>
</item>
<item>
<title>Around the block party planning</title>
<link>https://notexponential.com/499/around-the-block-party-planning</link>
<description>Consider a row of n houses represented as an array: A[1..n], where the phrase &amp;quot;next door neighbor&amp;quot; having its natural meaning. Each resident is assigned a &amp;quot;fun factor&amp;quot; F[1..n], which represents how much fun they bring to a party. Your goal is to maximize the fun of a party that you are arranging, but with the constraint that you cannot select three consecutive neighbors. (So for example, if you invite the A[5] and A[6] family, you cannot invite the A[4] or A[7] families.) Give an efficient algorithm to select the guest list.&lt;br /&gt;
&lt;br /&gt;
Please provide the Notation, optimality, recurrence, and algorithm.</description>
<category>Dynamic Programming</category>
<guid isPermaLink="true">https://notexponential.com/499/around-the-block-party-planning</guid>
<pubDate>Sun, 04 Mar 2018 03:14:53 +0000</pubDate>
</item>
<item>
<title>Love (Skip) thy neighbor</title>
<link>https://notexponential.com/498/love-skip-thy-neighbor</link>
<description>&lt;p&gt;Given a list of n positive numbers, your objective is to select the set of numbers that maximized the sum of selected numbers, given the constraint that we cannot select two numbers that are located adjacent to each other. Describe a linear time algorithm for this problem.&lt;/p&gt;&lt;div class=&quot;qa-q-view-content qa-post-content&quot; style=&quot;word-break: break-word; margin-bottom: 16px; font-family: Helvetica, Arial, sans-serif; font-size: 14px;&quot;&gt;&lt;div&gt;Please provide the Notation, optimality, recurrence, and algorithm.&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;</description>
<category>Dynamic Programming</category>
<guid isPermaLink="true">https://notexponential.com/498/love-skip-thy-neighbor</guid>
<pubDate>Sun, 04 Mar 2018 03:10:07 +0000</pubDate>
</item>
<item>
<title>Barbie&#039;s Array of Diamonds</title>
<link>https://notexponential.com/497/barbies-array-of-diamonds</link>
<description>&lt;p&gt;Barbie has n diamonds. Each diamond has two attributes: shiny value and weight value. Barbie wants to create a &quot;diamond line&quot; in which each diamond is both shinier and heavier than the previous one. &amp;nbsp;She may not be able to use all her diamonds, but wants to maximize the number of diamonds in this diamond line. &amp;nbsp;Give a polynomial time algorithm for creating a diamond line with the maximum number of diamonds. Assume that her initial list of diamonds is not in any specific order.&lt;/p&gt;&lt;div class=&quot;qa-q-view-content qa-post-content&quot; style=&quot;word-break: break-word; margin-bottom: 16px; font-family: Helvetica, Arial, sans-serif; font-size: 14px;&quot;&gt;&lt;div&gt;Please provide the Notation, optimality, recurrence, and algorithm.&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;</description>
<category>Dynamic Programming</category>
<guid isPermaLink="true">https://notexponential.com/497/barbies-array-of-diamonds</guid>
<pubDate>Sun, 04 Mar 2018 03:07:27 +0000</pubDate>
</item>
<item>
<title>Cost Minimizing Ice Cream Shop</title>
<link>https://notexponential.com/493/cost-minimizing-ice-cream-shop</link>
<description>&lt;p&gt;An ice cream shop is looking to minimize their operation costs, under the given constraints:&lt;br&gt;&lt;br&gt;They are faced with costs of purchasing ice cream from a local distributor, where each order has a (potentially large) fixed delivery cost &lt;em&gt;shipping _ cost&lt;/em&gt; as well as the &lt;em&gt;price&lt;/em&gt; price for each pint&lt;br&gt;&lt;br&gt;to minimize delivery costs, they can buy more ice cream than needed for a given day, and keep it stored it in their freezer overnight&lt;br&gt;&lt;br&gt;their freezer can store max capacity pints of ice cream at any time (includes both the shipment as well as any pints stored overnight)&lt;br&gt;&lt;br&gt;However, storing extra ice cream overnight is not free, and it costs them overnight cost dollars per pint (per night) to keep any additional ice cream frozen if they buy in advance&lt;br&gt;&lt;br&gt;Given a list of daily demand (in pints) of ice cream for the next &lt;em&gt;num_days&lt;/em&gt; days, what is the minimum cost for the shop to be stocked up ready to meet their demands each day?&lt;br&gt;&lt;br&gt;Inputs&lt;br&gt;&lt;br&gt;An integer &lt;em&gt;num _ days&lt;/em&gt; , for the number of days&lt;br&gt;&lt;br&gt;A list of &lt;em&gt;n&lt;/em&gt; integers demands, separated by a space, for the pints of ice cream demanded each day&lt;br&gt;&lt;br&gt;An integer &lt;em&gt;max _ capacity&lt;/em&gt; , for the max capacity of their freezer&lt;br&gt;&lt;br&gt;An integer &lt;em&gt;shipping _ cost&lt;/em&gt; , for the fixed cost of each shipment taken&lt;br&gt;&lt;br&gt;An integer &lt;em&gt;price&lt;/em&gt;, for the price they pay for each pint of ice cream&lt;br&gt;&lt;br&gt;An integer &lt;em&gt;overnight_cost&lt;/em&gt;, the cost of storing a pint of ice cream for a day&lt;/p&gt;</description>
<category>Dynamic Programming</category>
<guid isPermaLink="true">https://notexponential.com/493/cost-minimizing-ice-cream-shop</guid>
<pubDate>Thu, 08 Feb 2018 23:37:17 +0000</pubDate>
</item>
<item>
<title>Maximum Value Contiguous Subregion</title>
<link>https://notexponential.com/476/maximum-value-contiguous-subregion</link>
<description>&lt;p&gt;You are given a two dimentional array &lt;em&gt;A[1:n, 1..n]&lt;/em&gt; of real numbers (possibly containing both positive and negative real numbers)&lt;em&gt;.&amp;nbsp; &lt;/em&gt;You want to find a rectangular sub-region of the array that maximizes the sum of that region.&amp;nbsp; For example, the subarray S(1,2,5,8) consists of contiguous rectangle between A[1,2] to A[5,8], both corners inclusive, therefore, it has 35 total numbers.&lt;/p&gt;&lt;p&gt;Give the most efficient algorithm for this problem that you can.&lt;/p&gt;</description>
<category>Dynamic Programming</category>
<guid isPermaLink="true">https://notexponential.com/476/maximum-value-contiguous-subregion</guid>
<pubDate>Mon, 24 Jul 2017 05:25:12 +0000</pubDate>
</item>
<item>
<title>Maximum Value But Limited Neighbors</title>
<link>https://notexponential.com/466/maximum-value-but-limited-neighbors</link>
<description>&lt;p&gt;&lt;span style=&quot;color:rgb(68, 68, 68); font-family:open sans,helvetica,arial,sans-serif; font-size:14px&quot;&gt;You are given an array a[1..n] of positive numbers and an integer k. You have to produce an array b[1..n], such that: (i) For each j, b[j] is 0 or 1, (ii) Array b has adjacent 1s at most k times, and (iii) sum_{j=1 to n} a[j]*b[j] is maximized. For example, given an array [100, 300, 400, 50] and integer k = 1, the array b can be: [0 1 1 0], which maximizes the sum to be 700. Or, given an array [10, 100, 300, 400, 50, 4500, 200, 30, 90] and k = 2, the array b can be [1, 0, 1, 1, 0, 1, 1, 0, 1] which maximizes the sum to 5500.&lt;/span&gt;&lt;/p&gt;</description>
<category>Dynamic Programming</category>
<guid isPermaLink="true">https://notexponential.com/466/maximum-value-but-limited-neighbors</guid>
<pubDate>Tue, 20 Jun 2017 17:39:04 +0000</pubDate>
</item>
<item>
<title>Calculate g(1000) given the following definition of g function..</title>
<link>https://notexponential.com/460/calculate-1000-given-the-following-definition-of-function</link>
<description>g(1) = g(2) = .. g(10) = 1&lt;br /&gt;
&lt;br /&gt;
g(n) = g(n-1) + 3 *g(n-3) + 7*g(n-10)</description>
<category>Dynamic Programming</category>
<guid isPermaLink="true">https://notexponential.com/460/calculate-1000-given-the-following-definition-of-function</guid>
<pubDate>Thu, 08 Jun 2017 23:22:25 +0000</pubDate>
</item>
<item>
<title>Make change using smallest number of coins of given denominations</title>
<link>https://notexponential.com/390/make-change-using-smallest-number-coins-given-denominations</link>
<description>Given a set of k coins with values v[1], v[2], … v[k] such that v[1] = 1, v[1] &amp;lt; v[2] &amp;nbsp;&amp;lt; v[3] &amp;lt; v[4] &amp;lt; … &amp;lt; v[k]. &amp;nbsp;We want to make change for a given value n using as few coins as possible. &amp;nbsp;&amp;nbsp;Present an algorithm to do so. &amp;nbsp;The algorithm must be optimal in terms of the number of coins.</description>
<category>Dynamic Programming</category>
<guid isPermaLink="true">https://notexponential.com/390/make-change-using-smallest-number-coins-given-denominations</guid>
<pubDate>Sat, 03 Dec 2016 13:25:56 +0000</pubDate>
</item>
<item>
<title>Minimizing Weight of a Linear Partition</title>
<link>https://notexponential.com/382/minimizing-weight-of-a-linear-partition</link>
<description>&lt;p&gt;Let &lt;em&gt;A&lt;/em&gt;[1:&lt;em&gt;n&lt;/em&gt;] be a real array, and let &lt;em&gt;k &lt;/em&gt;be an integer, 1 ≤ &lt;em&gt;k &lt;/em&gt;≤ &lt;em&gt;n&lt;/em&gt;. A &lt;em&gt;linear k-partition &lt;/em&gt;of &lt;em&gt;A &lt;/em&gt;is a&amp;nbsp;sequence of subarrays of the form [1:x1],[x1+1:x2],[x2+1:x3],…,[x(k-1)+1:n], for some x1&amp;lt; x2 &amp;lt;… &amp;lt; x(k−1).&amp;nbsp; That is, the array A got divided into&amp;nbsp;&lt;em&gt;k&amp;nbsp;&lt;/em&gt;subarrays.&amp;nbsp; From this, we calculate the sums of each of k subarrays.&amp;nbsp; Finally, we take the maximum of those&amp;nbsp;&lt;em&gt;k&lt;/em&gt;&amp;nbsp;sums, and that is defined as the&amp;nbsp;&lt;em&gt;weight&lt;/em&gt;&lt;em&gt;&amp;nbsp;&lt;/em&gt;of this linear&amp;nbsp;&lt;em&gt;k&lt;/em&gt;-partition.&lt;/p&gt;&lt;p&gt;Give an &lt;em&gt;O(nk)&lt;/em&gt; dynamic programming algorithm to minimize the weight of the linear &lt;em&gt;k&lt;/em&gt;-partition of the given array.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;</description>
<category>Dynamic Programming</category>
<guid isPermaLink="true">https://notexponential.com/382/minimizing-weight-of-a-linear-partition</guid>
<pubDate>Mon, 21 Nov 2016 01:27:02 +0000</pubDate>
</item>
<item>
<title>Magical eggs and tiny floors</title>
<link>https://notexponential.com/180/magical-eggs-and-tiny-floors</link>
<description>&lt;p&gt;You are given &lt;em&gt;4&lt;/em&gt; eggs and a &lt;em&gt;30&lt;/em&gt; floor building.&amp;nbsp; You need to figure out the highest floor an egg can be dropped without breaking, assuming that (i) all eggs are identical, (ii) if an egg breaks after being dropped from one floor, then the egg will also break if dropped from all higher floors, and (iii) if an egg does not break after being thrown from a certain floor, it retains all of its strength and you can continue to use that egg. Your goal is to minimize the number of throws. From which floor do you drop the first egg? How do you handle this problem given generally &lt;em&gt;m&lt;/em&gt; eggs and an &lt;em&gt;n&lt;/em&gt;-floor building?&lt;/p&gt;</description>
<category>Dynamic Programming</category>
<guid isPermaLink="true">https://notexponential.com/180/magical-eggs-and-tiny-floors</guid>
<pubDate>Thu, 30 Jun 2016 01:56:13 +0000</pubDate>
</item>
<item>
<title>“Teleportation” across astro-haunted galaxies</title>
<link>https://notexponential.com/173/teleportation-across-astro-haunted-galaxies</link>
<description>&lt;p&gt;&lt;strong&gt;&lt;em&gt;“Teleportation”&lt;/em&gt;&lt;/strong&gt;: You have a teleporter that can take you from galaxy &lt;em&gt;i&lt;/em&gt; to galaxy &lt;em&gt;j&lt;/em&gt;.&amp;nbsp; Cost to teleport is given by &lt;em&gt;c(i,j) &amp;gt; 0&lt;/em&gt;, which can be arbitrary.&amp;nbsp; Some galaxies are “astro-haunted” - this is specified by a matrix &lt;em&gt;A&lt;/em&gt;, where &lt;em&gt;A[i]&lt;/em&gt; can be &lt;em&gt;0&lt;/em&gt; or &lt;em&gt;1&lt;/em&gt; (&lt;em&gt;1&lt;/em&gt; means that that galaxy is “astro-haunted”).&amp;nbsp; Give a polynomial time algorithm that minimizes the cost of going from galaxy &lt;em&gt;1&lt;/em&gt; to galaxy &lt;em&gt;n&lt;/em&gt;, such that you pass through a maximum of &lt;em&gt;m&lt;/em&gt; astro-haunted galaxies.&amp;nbsp; (You can assume that galaxies &lt;em&gt;1&lt;/em&gt; and &lt;em&gt;n&lt;/em&gt; are not astro-haunted.)&lt;/p&gt;</description>
<category>Dynamic Programming</category>
<guid isPermaLink="true">https://notexponential.com/173/teleportation-across-astro-haunted-galaxies</guid>
<pubDate>Sat, 05 Mar 2016 03:29:22 +0000</pubDate>
</item>
</channel>
</rss>