Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 131 lines (129 sloc) 6.68 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
<!DOCTYPE html>
<html data-require="math math-format expressions">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Writing expressions</title>
    <script data-main="../local-only/main.js" src="../local-only/require.js"></script>
</head>
<body>
    <div class="exercise">
        <div class="problems">
            <div id="original">
                <div class="vars">
                    <var id="M">randRange(1, 4)</var>
                    <var id="B">-randRange(1, 10)</var>

                    <var id="X_TERM_RE">
                        (M === 1 ? "1?" : M === -1 ?
                                "[-\\u2212]\\s*1?" :
                                (M &lt; 0 ? "[-\\u2212]\\s*" + (-M) : M)) +
                            "\\s*(?:\\*\\s*)?x"
                    </var>
                    <var id="C_TERM_RE">
                        B &lt; 0 ?
                            "[-\\u2212]\\s*" + (-B) :
                            "" + B
                    </var>
                    <var id="X_C_RE">
                        X_TERM_RE +
                            (B &lt; 0 ? "\\s*" : "\\s*\\+\\s*") +
                            C_TERM_RE
                    </var>
                    <var id="C_X_RE">
                        C_TERM_RE +
                            (M &lt; 0 ? "\\s*" : "\\s*\\+\\s*") +
                            X_TERM_RE
                    </var>
                    <var id="RE">
                        B === 0 ?
                            "^" + X_TERM_RE + "$" :
                            "^(?:" + X_C_RE + "|" + C_X_RE + ")$"
                    </var>
                </div>
                <div class="problem">
                    <p>Write an expression to represent:</p>
                </div>
                <p class="question">
                    <var>CardinalThrough20(-B)</var> less than the product of <var>cardinalThrough20(M)</var> and a number <code>x</code>.
                </p>
                <p class="solution" data-type="regex"><var>RE</var></p>
                <div class="hints">
                    <p>
                        The product of <var>cardinalThrough20(M)</var> and a number <code>x</code> can be written as
                        <span data-if="M !== 1"><code><var>M</var></code></span><code>x</code>.
                    </p>
                    <p><var>CardinalThrough20(-B)</var> less than something means that we subtract <code><var>-B</var></code> from it.</p>
                    <p>
                        If we subtract <code><var>-B</var></code> from <code><var>expr(["*", M, "x"])</var></code>, we have <code><var>expr(["+", ["*", M, "x"], B])</var></code>.
                    </p>
                </div>
            </div>
            <div data-type="original">
                <div class="vars">
                    <var id="M">randRange(1, 4)</var>
                    <var id="B">randRange(1, 10)</var>
                </div>
                <p class="question">
                    <var>CardinalThrough20(B)</var> more than the product of <var>cardinalThrough20(M)</var> and a number <code>x</code>.
                </p>
                <div class="hints">
                    <p>
                        The product of <var>cardinalThrough20(M)</var> and a number <code>x</code> can be written as
                        <span data-if="M !== 1"><code><var>M</var></code></span><code>x</code>.
                    </p>
                    <p><var>CardinalThrough20(B)</var> more than something means that we add <code><var>B</var></code> to it.</p>
                    <p>
                        If we add <code><var>B</var></code> to <code><var>expr(["*", M, "x"])</var></code>, we have <code><var>expr(["+", B, ["*", M, "x"]])</var></code>.
                    </p>
                </div>
            </div>
            <div data-type="original">
                <div class="vars">
                    <var id="M">-randRange(1, 4)</var>
                    <var id="B">randRange(1, 10)</var>
                </div>
                <p class="question">
                    <var>CardinalThrough20(B)</var> minus the product of <var>cardinalThrough20(-M)</var> and a number <code>x</code>.
                </p>
                <div class="hints">
                    <p>
                        The product of <var>cardinalThrough20(-M)</var> and a number <code>x</code> can be written as
                        <span data-if="-M !== 1"><code><var>-M</var></code></span><code>x</code>.
                    </p>
                    <p><var>CardinalThrough20(B)</var> minus something means that we subtract it from <code><var>B</var></code>.</p>
                    <p>
                        If we subtract <code><var>expr(["*", -M, "x"])</var></code> from <code><var>B</var></code>, we have <code><var>expr(["+", B, ["*", M, "x"]])</var></code>.
                    </p>
                </div>
            </div>
            <div data-type="original">
                <div class="vars">
                    <var id="M">randRange(2, 4)</var>
                    <var id="B">0</var>
                </div>
                <p class="question">The product of <var>cardinalThrough20(M)</var> and a number <code>x</code>.</p>
                <div class="hints">
                    <p>"Product" means that we multiply <code><var>M</var></code> and <code>x</code>.</p>
                    <p>If we multiply <code><var>M</var></code> and <code>x</code>, we have <code><var>expr(["*", M, "x"])</var></code>.</p>
                </div>
            </div>
            <div data-type="original">
                <div class="vars">
                    <var id="M">randRange(1, 4)</var>
                    <var id="B">randRange(1, 10)</var>
                </div>
                <p class="question">
                    The sum of <var>cardinalThrough20(B)</var> and the product of <var>cardinalThrough20(M)</var> and a number <code>x</code>.
                </p>
                <div class="hints">
                    <p>
                        The product of <var>cardinalThrough20(M)</var> and a number <code>x</code> can be written as
                        <span data-if="M !== 1"><code><var>M</var></code></span><code>x</code>.
                    </p>
                    <p>"Sum" means that we add <code><var>B</var></code> and <code><var>expr(["*", M, "x"])</var></code>.</p>
                    <p>If we add <code><var>B</var></code> and <code><var>expr(["*", M, "x"])</var></code>, we have <code><var>expr(["+", B, ["*", M, "x"]])</var></code>.</p>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
Something went wrong with that request. Please try again.