Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

113 lines (100 sloc) 3.256 kb
<!DOCTYPE html>
<html data-require="math matrix matrix-input">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Scalar matrix multiplication</title>
<script src="../khan-exercise.js"></script>
</head>
<body>
<div class="exercise">
<div class="vars">
<var id="MAT_A">randRange(-2, 4, ROWS, COLS)</var>
<var id="SCALAR">randRange(-5, 5)</var>
<var id="OPERATION">"\\times"</var>
<var id="SOLN_MAT">
deepZipWith(2, function(a) {
return a * SCALAR;
}, MAT_A)
</var>
<var id="PADDED_SOLN_MAT">matrixPad(SOLN_MAT, 3, 3)</var>
<var id="MAT_A_COLOR">BLUE</var>
<var id="SCALAR_COLOR">GREEN</var>
<var id="SOLN_MAT_COLOR">PINK</var>
<var id="PRETTY_MAT_A">
printSimpleMatrix(MAT_A, MAT_A_COLOR)
</var>
<var id="PRETTY_HINT_MAT">
printMatrix(function(a) {
var s = colorMarkup(SCALAR, SCALAR_COLOR);
var b = colorMarkup(a, MAT_A_COLOR);
return s + OPERATION + b;
}, MAT_A)
</var>
<var id="PRETTY_SOLN_MAT">
printSimpleMatrix(SOLN_MAT, SOLN_MAT_COLOR)
</var>
</div>
<div class="question">
<code>
\Large{
\color{<var>SCALAR_COLOR</var>}{<var>SCALAR</var>}
<var>OPERATION</var>
<var>PRETTY_MAT_A</var> = {?}
}
</code>
</div>
<div class="hints">
<div>
<p>To multiply a matrix by a number, multiply each item of the matrix by the number.</p>
<div>
<code>\Large{<var>PRETTY_HINT_MAT</var>}</code>
</div>
</div>
<div>
<p>Now, simplify:</p>
<div>
<code>\Large{<var>PRETTY_SOLN_MAT</var>}</code>
</div>
</div>
</div>
<div class="solution" data-type="multiple">
<div data-each="PADDED_SOLN_MAT as row" class="matrix-row">
<span data-each="row as elem">
<span data-if="elem !== ''" class="sol" data-forms="integer">
<var>elem</var>
</span>
<span data-else data-type="text" class="sol">
<var>elem</var>
</span>
</span>
</div>
</div>
<div class="problems">
<div id="2x2">
<div class="vars" data-apply="prependVars">
<var id="ROWS">2</var>
<var id="COLS">2</var>
</div>
</div>
<div id="2x3">
<div class="vars" data-apply="prependVars">
<var id="ROWS">2</var>
<var id="COLS">3</var>
</div>
</div>
<div id="3x1">
<div class="vars" data-apply="prependVars">
<var id="ROWS">3</var>
<var id="COLS">1</var>
</div>
</div>
<div id="3x2">
<div class="vars" data-apply="prependVars">
<var id="ROWS">3</var>
<var id="COLS">2</var>
</div>
</div>
</div>
</div>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.