<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
    <channel>
        <title>Education - Category - MartinLwx&#39;s Blog</title>
        <link>https://martinlwx.github.io/en/categories/education/</link>
        <description>Education - Category - MartinLwx&#39;s Blog</description>
        <generator>Hugo -- gohugo.io</generator><language>en</language><managingEditor>martinlwx@163.com (MartinLwx)</managingEditor>
            <webMaster>martinlwx@163.com (MartinLwx)</webMaster><copyright>&lt;a rel=&#34;license noopener&#34; href=&#34;https://creativecommons.org/licenses/by-nc-nd/4.0/&#34; target=&#34;_blank&#34;&gt;CC BY-NC-ND 4.0&lt;/a&gt;</copyright><lastBuildDate>Fri, 21 Apr 2023 10:18:16 &#43;0800</lastBuildDate><atom:link href="https://martinlwx.github.io/en/categories/education/" rel="self" type="application/rss+xml" /><item>
    <title>Solution of Proj4. Scheme Interpreter of CS61A (2021-Fall)</title>
    <link>https://martinlwx.github.io/en/proj4-scheme-interpreter-of-cs61a-of-ucb-fa21/</link>
    <pubDate>Fri, 21 Apr 2023 10:18:16 &#43;0800</pubDate><author>
        <name>MartinLwx</name>
    </author><guid>https://martinlwx.github.io/en/proj4-scheme-interpreter-of-cs61a-of-ucb-fa21/</guid>
    <description><![CDATA[<h2 id="intro" class="headerLink">
    <a href="#intro" class="header-mark"></a>Intro</h2><p>Recently, I am reading a book called <a href="https://craftinginterpreters.com/" target="_blank" rel="noopener noreferrer"><em>Crafting interpreters</em></a> written by Robert Nystrom. In the original book, a Tree-walker interpreter jlox was implemented in Java. And I am trying to rewrite in Python - <a href="https://github.com/MartinLwx/pylox" target="_blank" rel="noopener noreferrer">pylox</a>. I highly recommend it👍. At this moment, I suddenly remembered that there were a few small issues with the Scheme interpreter for CS61A that I had not resolved after finishing it a year ago, which kept it in an unfinished state. So today I opened the project and intended to run through it from beginning to end and talk about the ideas.</p>]]></description>
</item><item>
    <title>Solution of Proj3.Ants vs SomeBees of CS61A (2021-Fall)</title>
    <link>https://martinlwx.github.io/en/proj3.ants-vs-somebees-of-cs61a-of-ucb/</link>
    <pubDate>Thu, 10 Mar 2022 21:43:59 &#43;0800</pubDate><author>
        <name>MartinLwx</name>
    </author><guid>https://martinlwx.github.io/en/proj3.ants-vs-somebees-of-cs61a-of-ucb/</guid>
    <description><![CDATA[<h2 id="intro" class="headerLink">
    <a href="#intro" class="header-mark"></a>Intro</h2><hr>
<p>I have finished the first two projects - <a href="https://github.com/MartinLwx/CS61A-Fall-2021-UCB/tree/main/Projects/hog" target="_blank" rel="noopener noreferrer">Hog</a> and <a href="https://github.com/MartinLwx/CS61A-Fall-2021-UCB/tree/main/Projects/cats" target="_blank" rel="noopener noreferrer">Cats</a>. The first two projects are relatively simple and uncomplicated. But today, the difficulty of the third project has indeed increased (you can see how complicated this is by looking at the rules of the game). It feels like <em>Plants vs. Zombies</em></p>
<p>So I&rsquo;m going to write a blog to sort out the ideas when writing code. &#x1f917;</p>
<h2 id="phase-1-basic-gameplay" class="headerLink">
    <a href="#phase-1-basic-gameplay" class="header-mark"></a>Phase 1: Basic gameplay</h2><hr>
<h3 id="problem-1-1-pt" class="headerLink">
    <a href="#problem-1-1-pt" class="header-mark"></a>Problem 1 (1 pt)</h3><blockquote>
  <p><strong>Part A</strong>: Currently, there is no cost for placing any type of <code>Ant</code>, and so there is no challenge to the game. The base class <code>Ant</code> has a <code>food_cost</code> of zero. Override this class attribute for <code>HarvesterAnt</code> and <code>ThrowerAnt</code> according to the &ldquo;Food Cost&rdquo; column in the table below.</p>]]></description>
</item><item>
    <title>Lab14 solutions (UCB CS61A@2021-Fall)</title>
    <link>https://martinlwx.github.io/en/lab14-cs61a-of-ucb/</link>
    <pubDate>Thu, 03 Mar 2022 08:17:14 &#43;0800</pubDate><author>
        <name>MartinLwx</name>
    </author><guid>https://martinlwx.github.io/en/lab14-cs61a-of-ucb/</guid>
    <description><![CDATA[<h2 id="trees" class="headerLink">
    <a href="#trees" class="header-mark"></a>Trees</h2><hr>
<h3 id="q1-prune-min" class="headerLink">
    <a href="#q1-prune-min" class="header-mark"></a>Q1: Prune Min</h3><blockquote>
  <p>Write a function that prunes a <code>Tree</code> <code>t</code> mutatively. <code>t</code> and its branches always have zero or two branches. For the trees with two branches, reduce the number of branches from two to one by keeping the branch that has the smaller label value. Do nothing with trees with zero branches.</p>
<p>Prune the tree in a direction of your choosing (top down or bottom up). The result should be a linear tree.</p>]]></description>
</item><item>
    <title>Hw10 solutions (UCB CS61A@2021 Fall)</title>
    <link>https://martinlwx.github.io/en/hw10-of-cs61a-of-ucb/</link>
    <pubDate>Wed, 02 Mar 2022 13:36:13 &#43;0800</pubDate><author>
        <name>MartinLwx</name>
    </author><guid>https://martinlwx.github.io/en/hw10-of-cs61a-of-ucb/</guid>
    <description><![CDATA[<h2 id="bnf" class="headerLink">
    <a href="#bnf" class="header-mark"></a>BNF</h2><hr>
<h3 id="q1-grouping-and-pipes" class="headerLink">
    <a href="#q1-grouping-and-pipes" class="header-mark"></a>Q1: Grouping and Pipes</h3><blockquote>
  <p>In this question, you will add support for grouping and piping.</p>
<p>Recall that grouping allows for an entire regular expression to be treated as a single unit, and piping allows for a pattern to match an expression on either side. Combined, these will let us create patterns which match multiple strings!</p>
<p>Define the <code>group</code> and <code>pipe</code> expressions in your grammar.</p>
<ol>
<li>A <strong><code>group</code></strong> consists of any <code>regex</code> expression surrounded by parentheses (<code>()</code>).</li>
<li>A <strong><code>pipe</code></strong> operator consists of a <code>regex</code> expression, followed by a pipe (<code>|</code>) character, and lastly followed by another <code>regex</code> expression.</li>
</ol>
<p>For example, <code>r&quot;apples&quot;</code> would match exactly the phrase &ldquo;apples&rdquo; in an input. If we wanted our pattern from before to match &ldquo;oranges&rdquo; as well, we could expand our <code>rstring</code> to do so using groupings and pipes: <code>r&quot;(apples)|(oranges)&quot;</code>.</p>]]></description>
</item><item>
    <title>Lab12 solutions (UCB CS61A@2021 Fall)</title>
    <link>https://martinlwx.github.io/en/lab12-ca61a-of-ucb/</link>
    <pubDate>Wed, 02 Mar 2022 11:15:08 &#43;0800</pubDate><author>
        <name>MartinLwx</name>
    </author><guid>https://martinlwx.github.io/en/lab12-ca61a-of-ucb/</guid>
    <description><![CDATA[<h2 id="regular-expressions" class="headerLink">
    <a href="#regular-expressions" class="header-mark"></a>Regular Expressions</h2><hr>
<h3 id="q1-calculator-ops" class="headerLink">
    <a href="#q1-calculator-ops" class="header-mark"></a>Q1: Calculator Ops</h3><blockquote>
  <p>Write a regular expression that parses strings written in the 61A Calculator language and returns any expressions which have two numeric operands, leaving out the parentheses around them.</p>

</blockquote><p>We need to write a regular expression to match a pattern - <code>(operand operator1 operator2)</code>. The operands consist of <code>+</code>, <code>-</code>, <code>*</code>, <code>/</code>. We can use <code>[]</code> here. Don&rsquo;t forget to put a <code>\</code> in front of <code>-</code> to escape it.</p>]]></description>
</item><item>
    <title>Hw09 solutions (UCB CS61A@2021 Fall)</title>
    <link>https://martinlwx.github.io/en/hw09-of-cs61a-of-ucb/</link>
    <pubDate>Tue, 01 Mar 2022 21:13:22 &#43;0800</pubDate><author>
        <name>MartinLwx</name>
    </author><guid>https://martinlwx.github.io/en/hw09-of-cs61a-of-ucb/</guid>
    <description><![CDATA[<h3 id="q2-roman-numerals" class="headerLink">
    <a href="#q2-roman-numerals" class="header-mark"></a>Q2: Roman Numerals</h3><blockquote>
  <p>Write a regular expression that finds any string of letters that resemble a Roman numeral and aren&rsquo;t part of another word. A Roman numeral is made up of the letters I, V, X, L, C, D, M and is at least one letter long.</p>
<blockquote>
  <p>For the purposes of this problem, don&rsquo;t worry about whether or not a Roman numeral is valid. For example, &ldquo;VIIIII&rdquo; is not a Roman numeral, but it is fine if your regex matches it.</p>]]></description>
</item><item>
    <title>Lab11 solutions (UCB CS61A@2021 Fall)</title>
    <link>https://martinlwx.github.io/en/lab11-cs61a-of-ucb/</link>
    <pubDate>Tue, 01 Mar 2022 00:41:21 &#43;0800</pubDate><author>
        <name>MartinLwx</name>
    </author><guid>https://martinlwx.github.io/en/lab11-cs61a-of-ucb/</guid>
    <description><![CDATA[<h2 id="context" class="headerLink">
    <a href="#context" class="header-mark"></a>Context</h2><hr>
<h3 id="problem-1" class="headerLink">
    <a href="#problem-1" class="header-mark"></a>Problem 1</h3><blockquote>
  <blockquote>
  <p><strong>Important:</strong> Your code for this part should go in <code>buffer.py</code>.</p>

</blockquote><p>Your job in this part is to implement the <code>current</code> and <code>pop_first</code> methods of the <code>Buffer</code> class.</p>
<p><code>current</code> should return the current token of the current line we&rsquo;re on in the <code>Buffer</code> instance <em>without</em> removing it. If there are no more tokens in the current line, then <code>current</code> should move onto the next valid line, and return the <strong>first</strong> token of <em>this</em> line. If there are no more tokens left to return from the entire source (we&rsquo;ve reached the end of all input lines), then <code>current</code> should return <code>None</code> (this logic is already provided for you in the <code>except StopIteration</code> block).</p>]]></description>
</item><item>
    <title>Hw08 solutions (UCB CS61A@2021 Fall)</title>
    <link>https://martinlwx.github.io/en/hw08-of-cs61a-of-ucb/</link>
    <pubDate>Mon, 28 Feb 2022 00:28:31 &#43;0800</pubDate><author>
        <name>MartinLwx</name>
    </author><guid>https://martinlwx.github.io/en/hw08-of-cs61a-of-ucb/</guid>
    <description><![CDATA[<h3 id="q1-my-filter" class="headerLink">
    <a href="#q1-my-filter" class="header-mark"></a>Q1: My Filter</h3><blockquote>
  <p>Write a procedure <code>my-filter</code>, which takes a predicate <code>func</code> and a list <code>lst</code>, and returns a new list containing only elements of the list that satisfy the predicate. The output should contain the elements in the same order that they appeared in the original list.</p>
<p><strong>Note:</strong> Make sure that you are not just calling the built-in <code>filter</code> function in Scheme - we are asking you to re-implement this!</p>]]></description>
</item><item>
    <title>Hw07 of CS61A of UCB(2021-Fall)</title>
    <link>https://martinlwx.github.io/en/hw07-of-cs61a-of-ucb/</link>
    <pubDate>Sun, 27 Feb 2022 16:58:10 &#43;0800</pubDate><author>
        <name>MartinLwx</name>
    </author><guid>https://martinlwx.github.io/en/hw07-of-cs61a-of-ucb/</guid>
    <description><![CDATA[<h3 id="q1-thane-of-cadr" class="headerLink">
    <a href="#q1-thane-of-cadr" class="header-mark"></a>Q1: Thane of Cadr</h3><blockquote>
  <p>Define the procedures <code>cadr</code> and <code>caddr</code>, which return the second and third elements of a list, respectively. If you would like a quick refresher on scheme syntax consider looking at <a href="https://inst.eecs.berkeley.edu/~cs61a/fa21/lab/lab10/#scheme" target="_blank" rel="noopener noreferrer">Lab 10 Scheme Refresher</a>.</p>

</blockquote><p>We need to implement the function <code>c???r</code>. To have a better understanding of this notation, you should look from back to the front in <code>???</code>. For example, the <code>cadr</code> function will call <code>cdr</code> then call <code>car</code> on the input.</p>]]></description>
</item><item>
    <title>Hw06 solutions (UCB CS61A@2021 Fall)</title>
    <link>https://martinlwx.github.io/en/hw06-of-cs61a-of-ucb/</link>
    <pubDate>Sun, 27 Feb 2022 13:17:39 &#43;0800</pubDate><author>
        <name>MartinLwx</name>
    </author><guid>https://martinlwx.github.io/en/hw06-of-cs61a-of-ucb/</guid>
    <description><![CDATA[<h2 id="oop" class="headerLink">
    <a href="#oop" class="header-mark"></a>OOP</h2><hr>
<h3 id="q1-vending-machine" class="headerLink">
    <a href="#q1-vending-machine" class="header-mark"></a>Q1: Vending Machine</h3><blockquote>
  <p>In this question you&rsquo;ll create a <a href="https://en.wikipedia.org/wiki/Vending_machine" target="_blank" rel="noopener noreferrer">vending machine</a> that only outputs a single product and provides change when needed.</p>
<p>Create a class called <code>VendingMachine</code> that represents a vending machine for some product. A <code>Vending Machine</code>object returns strings describing its interactions. Remember to match <strong>exactly</strong> the strings in the doctests &ndash; including punctuation and spacing!</p>
<p>Fill in the <code>VendingMachine</code> class, adding attributes and methods as appropriate, such that its behavior matches the following doctests:</p>]]></description>
</item></channel>
</rss>
