<?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 ericlee.li on Medium]]></title>
        <description><![CDATA[Stories by ericlee.li on Medium]]></description>
        <link>https://medium.com/@lijingericleeli?source=rss-71f4b3897264------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*0bg24-x_DDZHVHvi.</url>
            <title>Stories by ericlee.li on Medium</title>
            <link>https://medium.com/@lijingericleeli?source=rss-71f4b3897264------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 10:54:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lijingericleeli/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[Quick snapshot of K3 Math foundation]]></title>
            <link>https://medium.com/@lijingericleeli/quick-snapshot-of-k3-math-foundation-3797c4e84544?source=rss-71f4b3897264------2</link>
            <guid isPermaLink="false">https://medium.com/p/3797c4e84544</guid>
            <dc:creator><![CDATA[ericlee.li]]></dc:creator>
            <pubDate>Sat, 05 Jul 2025 05:42:20 GMT</pubDate>
            <atom:updated>2025-07-05T05:49:24.570Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://youtu.be/7w-ULsa_tXU">https://youtu.be/7w-ULsa_tXU</a></p><p>Turning math into magic ✨ with 3Blue1Brown-style Manim animations! For Grades 1–3, we’re turning tricky concepts into eye-popping visuals that <em>kids actually get</em>. No more tears — just “aha!” moments. Bridging the gap to abstract thinking, one beautiful animation at a time. 💡</p><p>小学1–3年级的数学重要概念用3blue1brown编写的教学工具Manim的视觉表现力，数学变成无限可能的动画吸引孩子注意力，为不具备抽象思维的孩子建立抽象概念的桥梁，</p><p>一个字：秒懂；</p><p>#MathMadeEasy #VisualLearning #ManimMagic</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3797c4e84544" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[You help four men The shortest way to cross bridge]]></title>
            <link>https://medium.com/@lijingericleeli/you-help-four-men-the-shortest-way-to-cross-bridge-ed6253ec3efc?source=rss-71f4b3897264------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed6253ec3efc</guid>
            <category><![CDATA[algorithms-from-scratch]]></category>
            <category><![CDATA[mathematics-education]]></category>
            <dc:creator><![CDATA[ericlee.li]]></dc:creator>
            <pubDate>Sat, 04 May 2024 02:15:47 GMT</pubDate>
            <atom:updated>2024-05-04T02:15:47.413Z</atom:updated>
            <content:encoded><![CDATA[<p>Four individuals, A, B, C, and D, need to cross a river.</p><p>The only way to cross is via an old bridge that can accommodate a maximum of 2 people at a time.</p><p>Since it’s dark, they cannot cross without a torch, and they only have one torch between them.</p><p>Therefore, each pair of individuals must travel at the speed of the slower person.</p><p>They need to get everyone to the other side as quickly as possible.</p><p>A is the slowest, taking 10 minutes to cross; B takes 5 minutes; C takes 2 minutes; D takes 1 minute.</p><p>Question: What is the shortest time to get everyone to the other side?</p><p>**Solution:**</p><p>Optimization can further reduce the total time needed for all four individuals to cross. Let’s reconsider the scenario and optimize the strategy:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/487/1*ykUcbpIhXm8zb5-fJiLxwA.png" /><figcaption>source: youtube</figcaption></figure><p>First crossing: D (fastest, takes 1 minute) and C (second fastest, takes 2 minutes) cross together. This takes 2 minutes because they have to move at the speed of the slower one.</p><p>State: A B | C D -&gt; | A B C D</p><p>Second crossing: D returns with the flashlight, taking another 1 minute.</p><p>State: D | A B C -&gt; A B C | D</p><p>Third crossing: A (slowest, takes 10 minutes) and B (second slowest, takes 5 minutes) cross together. This takes 10 minutes.</p><p>State: A B D | C -&gt; C | A B D</p><p>Fourth crossing: Now C, on the original side, returns with the flashlight, taking another 2 minutes.</p><p>State: C D | A B -&gt; A B | C D</p><p>Fifth crossing: C and D cross together again, taking another 2 minutes.</p><p>Final state: | A B C D</p><p>Therefore, the shortest time to get everyone to the other side is 2 + 1 + 10 + 2 + 2 = 17 minutes.</p><p>So, your calculation of the total time being 17 minutes is correct, and the steps you outlined effectively ensure that all four individuals cross the bridge in the least possible time.</p><p>This puzzle is a classic example of optimizing resources and time management under constraints.</p><p>Let me know algorithm which solve it by coding! Thanks!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed6253ec3efc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Binary trick to solve the assignment]]></title>
            <link>https://medium.com/@lijingericleeli/binary-trick-to-solve-the-assignment-aaf5693ad8f1?source=rss-71f4b3897264------2</link>
            <guid isPermaLink="false">https://medium.com/p/aaf5693ad8f1</guid>
            <category><![CDATA[computer-science]]></category>
            <dc:creator><![CDATA[ericlee.li]]></dc:creator>
            <pubDate>Wed, 25 Oct 2023 14:20:09 GMT</pubDate>
            <atom:updated>2023-10-25T14:20:09.163Z</atom:updated>
            <content:encoded><![CDATA[<p>Assignment of the group purchase of fruits A group purchase of fresh fruit was organized spontaneously, and the reserved truck capacity was about 5,000 kg.</p><p>During the epidemic, I will distribute it to more than 100 people in the community.</p><p>Families have different needs in terms of quantity. Fortunately, the experienced supplier took into account the need to distribute the fruit as conveniently as possible, providing bags of different sizes sealed well, so that it was not necessary to open the package after arriving in the neighborhood and was able to put together the ordered quantity through an appropriate combination of several packages.</p><p>Since doing so, it not only saves the time of weighing each family, but also greatly reduces the time of gathering people.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*qsNPUOkjE2u7ehTxuoVKcQ.jpeg" /></figure><p>You as a programmer came up with a good idea.</p><p>Suggest to the fruit supplier to divide the fruit into a fixed number of several pounds of weight of the package, which will eventually ensure that when each family comes to collect the fruit, no matter how many pounds have been ordered, it will definitely find the combination to come up with the amount of fruit needed by each family.</p><p>At the same time will not be left, how to do what seems nearly impossible, I hope you can give the number of various packages.</p><p>Strategy and algorithm</p><p>The first step is to measure exactly 1 -&gt; n consecutively and sum(1+ … +n) &lt;= 5000 less or above.</p><p>Find some combination of patterns that will produce any number of fruits as described above The number of each type of package is accumulated and determined</p><pre>def evensplit(n):<br>    total = 1<br>    i = 1<br>    bench = []<br>    while total &lt;= n:<br>        bench.append(i)<br>        total += i<br>        i += 1<br>        maxwgt = len(bin(bench[-1])[2:])<br>        <br>    bins = [2**i for i in range(maxwgt+1)][::-1]<br>    weights = dict(zip(bins,len(bins)*[0]))</pre><pre>    for n in bench[::-1]:<br>        for k,v in weights.items():<br>            weights[k] += n//k<br>            n = n % k<br>return total,bins,weights</pre><pre>n = 5000<br>print(‘total ‘,evensplit(n))</pre><p>Output:</p><pre>total (5051, [128, 64, 32, 16, 8, 4, 2, 1], {128: 0, 64: 37, 32: 37, 16: 48, 8: 48, 4: 49, 2: 50, 1: 50})</pre><p>Distribution packing for fruit pickup The input parameter is the weight of the pick n</p><pre>def pick(n):<br>    b = bin(n)[2:][::-1]<br>    ans = [2**int(i) for i,e in enumerate(b) if e == ‘1’]<br>    return [f”{i} kg a bag” for i in ans]</pre><pre>n = 10<br>print(pick(n))</pre><pre>n = 17<br>print(pick(n))</pre><pre>n = 50<br>print(pick(n))</pre><pre>n = 100<br>print(pick(n))</pre><pre>[‘2 kg bag’, ‘8 kg bag’]<br>[‘1 kg bag’, ’16 kg bag’]<br>[‘2 kg bag’, ’16 kg bag’, ’32 kg bag’]<br>[‘4 kg bag’, ’32 kg bag’, ’64 kg bag’]</pre><p>Inspiring merchants can use 1, 2, 4, 8,… … . kg packages</p><p>Of course the above example assumes that the number of demands of each family is different at the same time, and that the distribution of the number of combinations of package sizes of wholesale fruits under the constraint that a whole truckload has a fixed weight of 5000 kg.</p><p>How to adjust the distribution of packaging for fruit pickup</p><p>Looking further at the actual situation often encountered with customers ordering the same quantity of demand, the solution now becomes easy.</p><p>Only a slight modification of the code is required.</p><p>For example:</p><p>5 people buy 20kg and 7 people buy 30kg</p><p>We need to adjust the quantity of a specific package while keeping the total amount the same.</p><p>#1 First look at which packages to add</p><pre>s = [(5,20),(7,30)]</pre><pre>def picknum(n):<br>    b = bin(n)[2:][::-1]<br>    ans = [2**int(i) for i,e in enumerate(b) if e == ‘1’]<br>    return ans</pre><p>#Which packages to reduce while keeping the total</p><pre>def adjust(s,n):<br>    n = n — sum([x*y for x,y in s])<br>    wgt = evensplit(n)[2]<br>    t = [(w[0],picknum(w[1])) for w in s]<br>    for m in t:<br>        for k,v in wgt.items():<br>          for i in m[1]:<br>              if i == k:<br>                wgt[k] += m[0]</pre><pre>    return wgt</pre><pre>s,n = [(5,20),(7,30)],5000<br>print(adjust(s,n))</pre><pre>{128: 0, 64: 34, 32: 34, 16: 60, 8: 55, 4: 60, 2: 55, 1: 49}<br>Compare to the original packing scheme.<br>{128: 0, 64: 37, 32: 37, 16: 48, 8: 48, 4: 49, 2: 50, 1: 50})</pre><p>The conclusion is.</p><pre>3 bags less for 64kg<br>3 more bags for 32kg<br>2 more bags for 16kg<br>8kg package increased by 7 bags<br>4kg package increased by 11 bags<br>2kg package increased by 5 bags<br>1kg package decreased by 1 bag</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aaf5693ad8f1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[N weights can be weighted in total]]></title>
            <link>https://medium.com/@lijingericleeli/n-weights-can-be-weighted-in-total-12907ff1dcec?source=rss-71f4b3897264------2</link>
            <guid isPermaLink="false">https://medium.com/p/12907ff1dcec</guid>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[algorithms]]></category>
            <dc:creator><![CDATA[ericlee.li]]></dc:creator>
            <pubDate>Tue, 01 Nov 2022 02:07:01 GMT</pubDate>
            <atom:updated>2022-11-01T02:07:01.355Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Balance with N weights" src="https://cdn-images-1.medium.com/max/1000/0*0wKyt4uO2hVF5778.jpg" /></figure><p>With 1, 2, 4, 8, and 16 weights, how many different weights can be weighed in total?</p><p>Note two rule conventions.<br>a/ Weights can only be placed on one side of the balance.<br>b/ Weights can be placed on both sides of the balance.</p><p>The key to the problem is how is the state of the weights expressed?</p><p>a/ The weights can only be placed on one side of the balance, the weights have only two states</p><h3>status = [0,1]</h3><pre>wgt = [1,2,4,8,16]</pre><pre>def Perweight(wgt):<br>    setweigt = set()<br>    #range(0,max(weight)<br>    maxwgt = int(&#39;0b&#39;+len(wgt)*&#39;1&#39;,2)<br>    status = [bin(n)[2:].rjust(5,&#39;0&#39;) <strong>for</strong> n <strong>in</strong> range(min(wgt),maxwgt+1)]<br>    print(status)<br>    <strong>for</strong> s <strong>in</strong> status:</pre><pre>        w = sum([int(x)*(int(y)-1) <strong>for</strong> x,y <strong>in</strong> zip(wgt,s)])<br>        setweigt.add(abs(w))</pre><pre>    return len(setweigt),setweigt<br>    <br>print(&#39;只放在天平一侧：&#39;,Perweight(wgt))</pre><p>输出结果：</p><pre>31<br>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, <br>11, 12, 13, 14, 15, 16, 17, 18, 19, <br>20, 21, 22, 23, 24, 25, 26, 27, 28, <br>29, 30}</pre><p>如何用数学求解？</p><p>C(1,5) + C(2,5) + C(3,5) + C(4,5) + C(5,5) = 5 + 10 + 10 + 5 + 1 = 31</p><h3>b/ status = [-1,0,1]</h3><p>天平左边 +1，右边 -1，不在天平是 0</p><p>1、构造3进制表达每个砝码的状态。天平左边 +1，右边 -1，不在天平是 0</p><pre>#初始化数组<br>wgt = [1,2,4,8,16]<br>#砝码5个<br></pre><pre>def Trin(n,b): # b = Binary<br>    # 10进制数n 转换为 b进制的数，从0 -&gt; <br>    <strong>if</strong> not n:return &#39;0&#39;<br>    thr,i = &#39;&#39;,1<br>    <br>    <strong>while</strong> n &gt; 0:<br>        d, r = divmod(n, 3)<br>        #print(d,r)<br>        thr += str(r)<br>        <strong>if</strong> d &lt; 3:<br>            thr += str(d)<br>            return thr[::-1]<br>        n = d<br>        i += 1</pre><pre>n,b = 27,3<br>print(&#39;3进制：&#39;,Trin(n,b))</pre><p>2、枚举 b进制数，从0到bits位之间所有的连续正整数</p><pre>def Trinary(bits,b): # str tri -&gt;decimal<br>    # 5位的三进制数00000 -&gt; 11111等于10进制的多少？<br>    d = sum([3**int(i) <strong>for</strong> i <strong>in</strong> range(bits)])<br>    seq = []<br>    <strong>for</strong> i <strong>in</strong> range(0,d+1):<br>        t = Trin(i,b)<br>        t = (bits-len(str(t)))*&#39;0&#39; + t<br>        seq.append(t)<br>    return seq<br>    <br>bits,b = 5,3<br>print(Trinary(bits,b))</pre><p>3、穷举 n个砝码所有状态组合并且做去重！</p><pre>def Perweight(wgt):<br>    setweigt = set()<br>    status = Trinary(len(wgt),b)<br>    <strong>for</strong> s <strong>in</strong> status:<br>   <br>        w = sum([int(x)*(int(y)-1) <strong>for</strong> x,y <strong>in</strong> zip(wgt,s)])<br>        setweigt.add(abs(w))</pre><pre>    return setweigt<br>    <br>print(Perweight(wgt))</pre><pre>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, <br>11, 12, 13, 14, 15, 16, 17, 18, 19, <br>20, 21, 22, 23, 24, 25, 26, 27, 28, <br>29, 30, 31}</pre><p>More attempts at cash denominations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6srUnZ5svDSXD1f3PCWOjA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=12907ff1dcec" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Assignment of the group purchase of fruits
A group purchase of fresh fruit was organized…]]></title>
            <link>https://medium.com/@lijingericleeli/assignment-of-the-group-purchase-of-fruits-a-group-purchase-of-fresh-fruit-was-organized-8856bd953756?source=rss-71f4b3897264------2</link>
            <guid isPermaLink="false">https://medium.com/p/8856bd953756</guid>
            <category><![CDATA[computer-science]]></category>
            <dc:creator><![CDATA[ericlee.li]]></dc:creator>
            <pubDate>Tue, 19 Jul 2022 00:54:43 GMT</pubDate>
            <atom:updated>2022-07-19T00:54:43.308Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*Tv2eT8U586HJURoL5Beypg.jpeg" /></figure><p>Assignment of the group purchase of fruits<br>A group purchase of fresh fruit was organized spontaneously, and the reserved truck capacity was about 5,000 kg. During the epidemic, I will distribute it to more than 100 people in the community.</p><p>Families have different needs in terms of quantity. Fortunately, the experienced supplier took into account the need to distribute the fruit as conveniently as possible, providing bags of different sizes sealed well, so that it was not necessary to open the package after arriving in the neighborhood and was able to put together the ordered quantity through an appropriate combination of several packages. Since doing so, it not only saves the time of weighing each family, but also greatly reduces the time of gathering people.</p><p>Picture</p><p>You as a programmer came up with a good idea. Suggest to the fruit supplier to divide the fruit into a fixed number of several pounds of weight of the package, which will eventually ensure that when each family comes to collect the fruit, no matter how many pounds have been ordered, it will definitely find the combination to come up with the amount of fruit needed by each family. At the same time will not be left, how to do what seems nearly impossible, I hope you can give the number of various packages.</p><p>Strategy and algorithm<br>The first step is to measure exactly 1 -&gt; n consecutively and sum(1+ … +n) &lt;= 5000 less or above<br>Find some combination of patterns that will produce any number of fruits as described above<br>The number of each type of package is accumulated and determined<br>def evensplit(n):<br> total = 1<br> i = 1<br> bench = []<br> while total &lt;= n:<br> bench.append(i)<br> total += i<br> i += 1<br> maxwgt = len(bin(bench[-1])[2:])<br> bins = [2**i for i in range(maxwgt+1)][::-1]<br> weights = dict(zip(bins,len(bins)*[0]))</p><p>for n in bench[::-1]:<br> for k,v in weights.items():<br> weights[k] += n//k<br> n = n % k<br> return total,bins,weights</p><p>n = 5000<br>print(‘total ‘,evensplit(n))</p><p>Output:</p><p>total (5051, [128, 64, 32, 16, 8, 4, 2, 1], {128: 0, 64: 37, 32: 37, 16: 48, 8: 48, 4: 49, 2: 50, 1: 50})</p><p>Distribution packing for fruit pickup<br>The input parameter is the weight of the pick n<br>def pick(n):<br> b = bin(n)[2:][::-1]<br> ans = [2**int(i) for i,e in enumerate(b) if e == ‘1’]<br> return [f”{i} kg a bag” for i in ans]</p><p>n = 10<br>print(pick(n))</p><p>n = 17<br>print(pick(n))</p><p>n = 50<br>print(pick(n))</p><p>n = 100<br>print(pick(n))</p><p>[‘2 kg bag’, ‘8 kg bag’]<br>[‘1 kg bag’, ’16 kg bag’]<br>[‘2 kg bag’, ’16 kg bag’, ’32 kg bag’]<br>[‘4 kg bag’, ’32 kg bag’, ’64 kg bag’]<br>Inspiring merchants can use 1, 2, 4, 8,… … . kg packages<br>Of course the above example assumes that the number of demands of each family is different at the same time, and that the distribution of the number of combinations of package sizes of wholesale fruits under the constraint that a whole truckload has a fixed weight of 5000 kg.<br>How to adjust the distribution of packaging for fruit pickup<br>Looking further at the actual situation often encountered with customers ordering the same quantity of demand, the solution now becomes easy. Only a slight modification of the code is required.<br>For example: 5 people buy 20kg and 7 people buy 30kg<br>We need to adjust the quantity of a specific package while keeping the total amount the same.<br>#1 First look at which packages to add<br>s = [(5,20),(7,30)]</p><p>def picknum(n):<br> b = bin(n)[2:][::-1]<br> ans = [2**int(i) for i,e in enumerate(b) if e == ‘1’]<br> return ans</p><p># Which packages to reduce while keeping the total<br>def adjust(s,n):<br> n = n — sum([x*y for x,y in s])<br> wgt = evensplit(n)[2]<br> t = [(w[0],picknum(w[1])) for w in s]<br> for m in t:<br> for k,v in wgt.items():<br> for i in m[1]:<br> if i == k:<br> wgt[k] += m[0]</p><p>return wgt</p><p>s,n = [(5,20),(7,30)],5000<br>print(adjust(s,n))</p><p>{128: 0, 64: 34, 32: 34, 16: 60, 8: 55, 4: 60, 2: 55, 1: 49}<br>Compare to the original packing scheme.<br>{128: 0, 64: 37, 32: 37, 16: 48, 8: 48, 4: 49, 2: 50, 1: 50})<br>The conclusion is.<br>3 bags less for 64kg<br>3 more bags for 32kg<br>2 more bags for 16kg<br>8kg package increased by 7 bags<br>4kg package increased by 11 bags<br>2kg package increased by 5 bags<br>1kg package decreased by 1 bag</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8856bd953756" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>