Spaces:
Running
Running
aepstar
commited on
Commit
·
4103597
1
Parent(s):
cc5e003
delete
Browse files- countsheep.html +0 -535
- evenodd.html +0 -551
- intro.html +0 -484
- make_negative.html +0 -532
- multiply.html +0 -532
- positive_sum.html +0 -542
- reducegrow.html +0 -529
- references.html +0 -449
- summary.html +0 -448
countsheep.html
DELETED
|
@@ -1,535 +0,0 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
|
| 3 |
-
|
| 4 |
-
<meta charset="utf-8">
|
| 5 |
-
<meta name="generator" content="quarto-1.3.433">
|
| 6 |
-
|
| 7 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
<title>Codewars Challenge 2024 Menggunakan R dan RStudio - 3 If you can’t sleep, just count sheep!!</title>
|
| 11 |
-
<style>
|
| 12 |
-
code{white-space: pre-wrap;}
|
| 13 |
-
span.smallcaps{font-variant: small-caps;}
|
| 14 |
-
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
| 15 |
-
div.column{flex: auto; overflow-x: auto;}
|
| 16 |
-
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
| 17 |
-
ul.task-list{list-style: none;}
|
| 18 |
-
ul.task-list li input[type="checkbox"] {
|
| 19 |
-
width: 0.8em;
|
| 20 |
-
margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
|
| 21 |
-
vertical-align: middle;
|
| 22 |
-
}
|
| 23 |
-
/* CSS for syntax highlighting */
|
| 24 |
-
pre > code.sourceCode { white-space: pre; position: relative; }
|
| 25 |
-
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
|
| 26 |
-
pre > code.sourceCode > span:empty { height: 1.2em; }
|
| 27 |
-
.sourceCode { overflow: visible; }
|
| 28 |
-
code.sourceCode > span { color: inherit; text-decoration: inherit; }
|
| 29 |
-
div.sourceCode { margin: 1em 0; }
|
| 30 |
-
pre.sourceCode { margin: 0; }
|
| 31 |
-
@media screen {
|
| 32 |
-
div.sourceCode { overflow: auto; }
|
| 33 |
-
}
|
| 34 |
-
@media print {
|
| 35 |
-
pre > code.sourceCode { white-space: pre-wrap; }
|
| 36 |
-
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
|
| 37 |
-
}
|
| 38 |
-
pre.numberSource code
|
| 39 |
-
{ counter-reset: source-line 0; }
|
| 40 |
-
pre.numberSource code > span
|
| 41 |
-
{ position: relative; left: -4em; counter-increment: source-line; }
|
| 42 |
-
pre.numberSource code > span > a:first-child::before
|
| 43 |
-
{ content: counter(source-line);
|
| 44 |
-
position: relative; left: -1em; text-align: right; vertical-align: baseline;
|
| 45 |
-
border: none; display: inline-block;
|
| 46 |
-
-webkit-touch-callout: none; -webkit-user-select: none;
|
| 47 |
-
-khtml-user-select: none; -moz-user-select: none;
|
| 48 |
-
-ms-user-select: none; user-select: none;
|
| 49 |
-
padding: 0 4px; width: 4em;
|
| 50 |
-
}
|
| 51 |
-
pre.numberSource { margin-left: 3em; padding-left: 4px; }
|
| 52 |
-
div.sourceCode
|
| 53 |
-
{ }
|
| 54 |
-
@media screen {
|
| 55 |
-
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
|
| 56 |
-
}
|
| 57 |
-
</style>
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
<script src="site_libs/quarto-nav/quarto-nav.js"></script>
|
| 61 |
-
<script src="site_libs/quarto-nav/headroom.min.js"></script>
|
| 62 |
-
<script src="site_libs/clipboard/clipboard.min.js"></script>
|
| 63 |
-
<script src="site_libs/quarto-search/autocomplete.umd.js"></script>
|
| 64 |
-
<script src="site_libs/quarto-search/fuse.min.js"></script>
|
| 65 |
-
<script src="site_libs/quarto-search/quarto-search.js"></script>
|
| 66 |
-
<meta name="quarto:offset" content="./">
|
| 67 |
-
<link href="./reducegrow.html" rel="next">
|
| 68 |
-
<link href="./multiply.html" rel="prev">
|
| 69 |
-
<script src="site_libs/quarto-html/quarto.js"></script>
|
| 70 |
-
<script src="site_libs/quarto-html/popper.min.js"></script>
|
| 71 |
-
<script src="site_libs/quarto-html/tippy.umd.min.js"></script>
|
| 72 |
-
<script src="site_libs/quarto-html/anchor.min.js"></script>
|
| 73 |
-
<link href="site_libs/quarto-html/tippy.css" rel="stylesheet">
|
| 74 |
-
<link href="site_libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
|
| 75 |
-
<script src="site_libs/bootstrap/bootstrap.min.js"></script>
|
| 76 |
-
<link href="site_libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
|
| 77 |
-
<link href="site_libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">
|
| 78 |
-
<link href="site_libs/quarto-contrib/badge/badge.css" rel="stylesheet">
|
| 79 |
-
<script id="quarto-search-options" type="application/json">{
|
| 80 |
-
"location": "sidebar",
|
| 81 |
-
"copy-button": false,
|
| 82 |
-
"collapse-after": 3,
|
| 83 |
-
"panel-placement": "start",
|
| 84 |
-
"type": "textbox",
|
| 85 |
-
"limit": 20,
|
| 86 |
-
"language": {
|
| 87 |
-
"search-no-results-text": "No results",
|
| 88 |
-
"search-matching-documents-text": "matching documents",
|
| 89 |
-
"search-copy-link-title": "Copy link to search",
|
| 90 |
-
"search-hide-matches-text": "Hide additional matches",
|
| 91 |
-
"search-more-match-text": "more match in this document",
|
| 92 |
-
"search-more-matches-text": "more matches in this document",
|
| 93 |
-
"search-clear-button-title": "Clear",
|
| 94 |
-
"search-detached-cancel-button-title": "Cancel",
|
| 95 |
-
"search-submit-button-title": "Submit",
|
| 96 |
-
"search-label": "Search"
|
| 97 |
-
}
|
| 98 |
-
}</script>
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
</head>
|
| 102 |
-
|
| 103 |
-
<body class="nav-sidebar floating">
|
| 104 |
-
|
| 105 |
-
<div id="quarto-search-results"></div>
|
| 106 |
-
<header id="quarto-header" class="headroom fixed-top">
|
| 107 |
-
<nav class="quarto-secondary-nav">
|
| 108 |
-
<div class="container-fluid d-flex">
|
| 109 |
-
<button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
|
| 110 |
-
<i class="bi bi-layout-text-sidebar-reverse"></i>
|
| 111 |
-
</button>
|
| 112 |
-
<nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="./countsheep.html"><span class="chapter-number">3</span> <span class="chapter-title">If you can't sleep, just count sheep!!</span></a></li></ol></nav>
|
| 113 |
-
<a class="flex-grow-1" role="button" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
|
| 114 |
-
</a>
|
| 115 |
-
<button type="button" class="btn quarto-search-button" aria-label="" onclick="window.quartoOpenSearch();">
|
| 116 |
-
<i class="bi bi-search"></i>
|
| 117 |
-
</button>
|
| 118 |
-
</div>
|
| 119 |
-
</nav>
|
| 120 |
-
</header>
|
| 121 |
-
<!-- content -->
|
| 122 |
-
<div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article">
|
| 123 |
-
<!-- sidebar -->
|
| 124 |
-
<nav id="quarto-sidebar" class="sidebar collapse collapse-horizontal sidebar-navigation floating overflow-auto">
|
| 125 |
-
<div class="pt-lg-2 mt-2 text-left sidebar-header">
|
| 126 |
-
<div class="sidebar-title mb-0 py-0">
|
| 127 |
-
<a href="./">Codewars Challenge 2024 Menggunakan R dan RStudio</a>
|
| 128 |
-
</div>
|
| 129 |
-
</div>
|
| 130 |
-
<div class="mt-2 flex-shrink-0 align-items-center">
|
| 131 |
-
<div class="sidebar-search">
|
| 132 |
-
<div id="quarto-search" class="" title="Search"></div>
|
| 133 |
-
</div>
|
| 134 |
-
</div>
|
| 135 |
-
<div class="sidebar-menu-container">
|
| 136 |
-
<ul class="list-unstyled mt-1">
|
| 137 |
-
<li class="sidebar-item">
|
| 138 |
-
<div class="sidebar-item-container">
|
| 139 |
-
<a href="./index.html" class="sidebar-item-text sidebar-link">
|
| 140 |
-
<span class="menu-text">Pengantar</span></a>
|
| 141 |
-
</div>
|
| 142 |
-
</li>
|
| 143 |
-
<li class="sidebar-item">
|
| 144 |
-
<div class="sidebar-item-container">
|
| 145 |
-
<a href="./evenodd.html" class="sidebar-item-text sidebar-link">
|
| 146 |
-
<span class="menu-text"><span class="chapter-number">1</span> <span class="chapter-title">Even or Odd</span></span></a>
|
| 147 |
-
</div>
|
| 148 |
-
</li>
|
| 149 |
-
<li class="sidebar-item">
|
| 150 |
-
<div class="sidebar-item-container">
|
| 151 |
-
<a href="./multiply.html" class="sidebar-item-text sidebar-link">
|
| 152 |
-
<span class="menu-text"><span class="chapter-number">2</span> <span class="chapter-title">Multiply</span></span></a>
|
| 153 |
-
</div>
|
| 154 |
-
</li>
|
| 155 |
-
<li class="sidebar-item">
|
| 156 |
-
<div class="sidebar-item-container">
|
| 157 |
-
<a href="./countsheep.html" class="sidebar-item-text sidebar-link active">
|
| 158 |
-
<span class="menu-text"><span class="chapter-number">3</span> <span class="chapter-title">If you can’t sleep, just count sheep!!</span></span></a>
|
| 159 |
-
</div>
|
| 160 |
-
</li>
|
| 161 |
-
<li class="sidebar-item">
|
| 162 |
-
<div class="sidebar-item-container">
|
| 163 |
-
<a href="./reducegrow.html" class="sidebar-item-text sidebar-link">
|
| 164 |
-
<span class="menu-text"><span class="chapter-number">4</span> <span class="chapter-title">Beginner - Reduce but Grow</span></span></a>
|
| 165 |
-
</div>
|
| 166 |
-
</li>
|
| 167 |
-
<li class="sidebar-item">
|
| 168 |
-
<div class="sidebar-item-container">
|
| 169 |
-
<a href="./make_negative.html" class="sidebar-item-text sidebar-link">
|
| 170 |
-
<span class="menu-text"><span class="chapter-number">5</span> <span class="chapter-title">Return Negative</span></span></a>
|
| 171 |
-
</div>
|
| 172 |
-
</li>
|
| 173 |
-
<li class="sidebar-item">
|
| 174 |
-
<div class="sidebar-item-container">
|
| 175 |
-
<a href="./positive_sum.html" class="sidebar-item-text sidebar-link">
|
| 176 |
-
<span class="menu-text"><span class="chapter-number">6</span> <span class="chapter-title">Sum of positive</span></span></a>
|
| 177 |
-
</div>
|
| 178 |
-
</li>
|
| 179 |
-
<li class="sidebar-item">
|
| 180 |
-
<div class="sidebar-item-container">
|
| 181 |
-
<a href="./references.html" class="sidebar-item-text sidebar-link">
|
| 182 |
-
<span class="menu-text">References</span></a>
|
| 183 |
-
</div>
|
| 184 |
-
</li>
|
| 185 |
-
</ul>
|
| 186 |
-
</div>
|
| 187 |
-
</nav>
|
| 188 |
-
<div id="quarto-sidebar-glass" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass"></div>
|
| 189 |
-
<!-- margin-sidebar -->
|
| 190 |
-
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
|
| 191 |
-
<nav id="TOC" role="doc-toc" class="toc-active">
|
| 192 |
-
<h2 id="toc-title">Table of contents</h2>
|
| 193 |
-
|
| 194 |
-
<ul>
|
| 195 |
-
<li><a href="#instruction" id="toc-instruction" class="nav-link active" data-scroll-target="#instruction"><span class="header-section-number">3.1</span> Instruction</a></li>
|
| 196 |
-
<li><a href="#youtube-video" id="toc-youtube-video" class="nav-link" data-scroll-target="#youtube-video"><span class="header-section-number">3.2</span> YouTube Video</a></li>
|
| 197 |
-
<li><a href="#solution-code" id="toc-solution-code" class="nav-link" data-scroll-target="#solution-code"><span class="header-section-number">3.3</span> Solution Code</a></li>
|
| 198 |
-
<li><a href="#test" id="toc-test" class="nav-link" data-scroll-target="#test"><span class="header-section-number">3.4</span> Test</a></li>
|
| 199 |
-
<li><a href="#supported-by" id="toc-supported-by" class="nav-link" data-scroll-target="#supported-by"><span class="header-section-number">3.5</span> Supported by</a></li>
|
| 200 |
-
</ul>
|
| 201 |
-
</nav>
|
| 202 |
-
</div>
|
| 203 |
-
<!-- main -->
|
| 204 |
-
<main class="content" id="quarto-document-content">
|
| 205 |
-
|
| 206 |
-
<header id="title-block-header" class="quarto-title-block default">
|
| 207 |
-
<div class="quarto-title">
|
| 208 |
-
<h1 class="title"><span class="chapter-number">3</span> <span class="chapter-title">If you can’t sleep, just count sheep!!</span></h1>
|
| 209 |
-
</div>
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
<div class="quarto-title-meta">
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
</div>
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
</header>
|
| 222 |
-
|
| 223 |
-
<p>Tantangan #3/366 - 17 Feb 2024</p>
|
| 224 |
-
<p><a href="https://www.codewars.com/kata/5b077ebdaf15be5c7f000077/train/r" class="uri">https://www.codewars.com/kata/5b077ebdaf15be5c7f000077/train/r</a></p>
|
| 225 |
-
<p><span class="badge rounded-pill quarto-badge " style="background-color: grey;">8kyu</span> If you can’t sleep, just count sheep!!</p>
|
| 226 |
-
<section id="instruction" class="level2" data-number="3.1">
|
| 227 |
-
<h2 data-number="3.1" class="anchored" data-anchor-id="instruction"><span class="header-section-number">3.1</span> Instruction</h2>
|
| 228 |
-
<p>Given a non-negative integer, 3 for example, return a string with a murmur: “1 sheep…2 sheep…3 sheep…”. Input will always be valid, i.e. no negative integers.</p>
|
| 229 |
-
</section>
|
| 230 |
-
<section id="youtube-video" class="level2" data-number="3.2">
|
| 231 |
-
<h2 data-number="3.2" class="anchored" data-anchor-id="youtube-video"><span class="header-section-number">3.2</span> YouTube Video</h2>
|
| 232 |
-
<div class="quarto-video ratio ratio-16x9"><iframe data-external="1" src="https://www.youtube.com/embed/L8aczEhqymk?si=DSx84acpNvbkucrK" title="" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe></div>
|
| 233 |
-
</section>
|
| 234 |
-
<section id="solution-code" class="level2" data-number="3.3">
|
| 235 |
-
<h2 data-number="3.3" class="anchored" data-anchor-id="solution-code"><span class="header-section-number">3.3</span> Solution Code</h2>
|
| 236 |
-
<p>Solusi bar-bar</p>
|
| 237 |
-
<div class="cell">
|
| 238 |
-
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a>countSheep <span class="ot"><-</span> <span class="cf">function</span>(num){</span>
|
| 239 |
-
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span>(num <span class="sc">==</span> <span class="dv">0</span>){</span>
|
| 240 |
-
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">return</span>(<span class="st">""</span>)</span>
|
| 241 |
-
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a> } <span class="cf">else</span> {</span>
|
| 242 |
-
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a> result <span class="ot"><-</span> <span class="st">""</span></span>
|
| 243 |
-
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a> <span class="cf">for</span>(i <span class="cf">in</span> <span class="dv">1</span><span class="sc">:</span>num){</span>
|
| 244 |
-
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a> result <span class="ot"><-</span> <span class="fu">paste</span>(result, i, <span class="st">" sheep..."</span>, <span class="at">sep =</span> <span class="st">""</span>)</span>
|
| 245 |
-
<span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a> }</span>
|
| 246 |
-
<span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">return</span>(result)</span>
|
| 247 |
-
<span id="cb1-10"><a href="#cb1-10" aria-hidden="true" tabindex="-1"></a> }</span>
|
| 248 |
-
<span id="cb1-11"><a href="#cb1-11" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 249 |
-
</div>
|
| 250 |
-
<p>Solusi simple</p>
|
| 251 |
-
<div class="cell">
|
| 252 |
-
<div class="sourceCode cell-code" id="cb2"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>countSheep <span class="ot"><-</span> <span class="cf">function</span>(num){</span>
|
| 253 |
-
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">ifelse</span>(num <span class="sc">==</span> <span class="dv">0</span>, <span class="st">""</span>, <span class="fu">paste</span>(<span class="dv">1</span><span class="sc">:</span>num, <span class="st">"sheep..."</span>, <span class="at">collapse =</span> <span class="st">""</span>))</span>
|
| 254 |
-
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 255 |
-
</div>
|
| 256 |
-
</section>
|
| 257 |
-
<section id="test" class="level2" data-number="3.4">
|
| 258 |
-
<h2 data-number="3.4" class="anchored" data-anchor-id="test"><span class="header-section-number">3.4</span> Test</h2>
|
| 259 |
-
<div class="cell">
|
| 260 |
-
<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(testthat)</span>
|
| 261 |
-
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a></span>
|
| 262 |
-
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="fu">test_that</span>(<span class="st">"Fixed tests"</span>, {</span>
|
| 263 |
-
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">expect_equal</span>(<span class="fu">countSheep</span>(<span class="dv">0</span>), <span class="st">""</span>)</span>
|
| 264 |
-
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">expect_equal</span>(<span class="fu">countSheep</span>(<span class="dv">1</span>), <span class="st">"1 sheep..."</span>)</span>
|
| 265 |
-
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">expect_equal</span>(<span class="fu">countSheep</span>(<span class="dv">2</span>), <span class="st">"1 sheep...2 sheep..."</span>)</span>
|
| 266 |
-
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">expect_equal</span>(<span class="fu">countSheep</span>(<span class="dv">3</span>), <span class="st">"1 sheep...2 sheep...3 sheep..."</span>)</span>
|
| 267 |
-
<span id="cb3-8"><a href="#cb3-8" aria-hidden="true" tabindex="-1"></a>})</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 268 |
-
<div class="cell-output cell-output-stdout">
|
| 269 |
-
<pre><code>Test passed 😸</code></pre>
|
| 270 |
-
</div>
|
| 271 |
-
</div>
|
| 272 |
-
</section>
|
| 273 |
-
<section id="supported-by" class="level2" data-number="3.5">
|
| 274 |
-
<h2 data-number="3.5" class="anchored" data-anchor-id="supported-by"><span class="header-section-number">3.5</span> Supported by</h2>
|
| 275 |
-
<div class="quarto-figure quarto-figure-center">
|
| 276 |
-
<figure class="figure">
|
| 277 |
-
<p><a href="https://www.starcore.co"><img src="new_starcore_logo.png" class="img-fluid figure-img"></a></p>
|
| 278 |
-
<figcaption class="figure-caption">StarCore Analytics</figcaption>
|
| 279 |
-
</figure>
|
| 280 |
-
</div>
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
</section>
|
| 284 |
-
|
| 285 |
-
</main> <!-- /main -->
|
| 286 |
-
<script id="quarto-html-after-body" type="application/javascript">
|
| 287 |
-
window.document.addEventListener("DOMContentLoaded", function (event) {
|
| 288 |
-
const toggleBodyColorMode = (bsSheetEl) => {
|
| 289 |
-
const mode = bsSheetEl.getAttribute("data-mode");
|
| 290 |
-
const bodyEl = window.document.querySelector("body");
|
| 291 |
-
if (mode === "dark") {
|
| 292 |
-
bodyEl.classList.add("quarto-dark");
|
| 293 |
-
bodyEl.classList.remove("quarto-light");
|
| 294 |
-
} else {
|
| 295 |
-
bodyEl.classList.add("quarto-light");
|
| 296 |
-
bodyEl.classList.remove("quarto-dark");
|
| 297 |
-
}
|
| 298 |
-
}
|
| 299 |
-
const toggleBodyColorPrimary = () => {
|
| 300 |
-
const bsSheetEl = window.document.querySelector("link#quarto-bootstrap");
|
| 301 |
-
if (bsSheetEl) {
|
| 302 |
-
toggleBodyColorMode(bsSheetEl);
|
| 303 |
-
}
|
| 304 |
-
}
|
| 305 |
-
toggleBodyColorPrimary();
|
| 306 |
-
const icon = "";
|
| 307 |
-
const anchorJS = new window.AnchorJS();
|
| 308 |
-
anchorJS.options = {
|
| 309 |
-
placement: 'right',
|
| 310 |
-
icon: icon
|
| 311 |
-
};
|
| 312 |
-
anchorJS.add('.anchored');
|
| 313 |
-
const isCodeAnnotation = (el) => {
|
| 314 |
-
for (const clz of el.classList) {
|
| 315 |
-
if (clz.startsWith('code-annotation-')) {
|
| 316 |
-
return true;
|
| 317 |
-
}
|
| 318 |
-
}
|
| 319 |
-
return false;
|
| 320 |
-
}
|
| 321 |
-
const clipboard = new window.ClipboardJS('.code-copy-button', {
|
| 322 |
-
text: function(trigger) {
|
| 323 |
-
const codeEl = trigger.previousElementSibling.cloneNode(true);
|
| 324 |
-
for (const childEl of codeEl.children) {
|
| 325 |
-
if (isCodeAnnotation(childEl)) {
|
| 326 |
-
childEl.remove();
|
| 327 |
-
}
|
| 328 |
-
}
|
| 329 |
-
return codeEl.innerText;
|
| 330 |
-
}
|
| 331 |
-
});
|
| 332 |
-
clipboard.on('success', function(e) {
|
| 333 |
-
// button target
|
| 334 |
-
const button = e.trigger;
|
| 335 |
-
// don't keep focus
|
| 336 |
-
button.blur();
|
| 337 |
-
// flash "checked"
|
| 338 |
-
button.classList.add('code-copy-button-checked');
|
| 339 |
-
var currentTitle = button.getAttribute("title");
|
| 340 |
-
button.setAttribute("title", "Copied!");
|
| 341 |
-
let tooltip;
|
| 342 |
-
if (window.bootstrap) {
|
| 343 |
-
button.setAttribute("data-bs-toggle", "tooltip");
|
| 344 |
-
button.setAttribute("data-bs-placement", "left");
|
| 345 |
-
button.setAttribute("data-bs-title", "Copied!");
|
| 346 |
-
tooltip = new bootstrap.Tooltip(button,
|
| 347 |
-
{ trigger: "manual",
|
| 348 |
-
customClass: "code-copy-button-tooltip",
|
| 349 |
-
offset: [0, -8]});
|
| 350 |
-
tooltip.show();
|
| 351 |
-
}
|
| 352 |
-
setTimeout(function() {
|
| 353 |
-
if (tooltip) {
|
| 354 |
-
tooltip.hide();
|
| 355 |
-
button.removeAttribute("data-bs-title");
|
| 356 |
-
button.removeAttribute("data-bs-toggle");
|
| 357 |
-
button.removeAttribute("data-bs-placement");
|
| 358 |
-
}
|
| 359 |
-
button.setAttribute("title", currentTitle);
|
| 360 |
-
button.classList.remove('code-copy-button-checked');
|
| 361 |
-
}, 1000);
|
| 362 |
-
// clear code selection
|
| 363 |
-
e.clearSelection();
|
| 364 |
-
});
|
| 365 |
-
function tippyHover(el, contentFn) {
|
| 366 |
-
const config = {
|
| 367 |
-
allowHTML: true,
|
| 368 |
-
content: contentFn,
|
| 369 |
-
maxWidth: 500,
|
| 370 |
-
delay: 100,
|
| 371 |
-
arrow: false,
|
| 372 |
-
appendTo: function(el) {
|
| 373 |
-
return el.parentElement;
|
| 374 |
-
},
|
| 375 |
-
interactive: true,
|
| 376 |
-
interactiveBorder: 10,
|
| 377 |
-
theme: 'quarto',
|
| 378 |
-
placement: 'bottom-start'
|
| 379 |
-
};
|
| 380 |
-
window.tippy(el, config);
|
| 381 |
-
}
|
| 382 |
-
const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
|
| 383 |
-
for (var i=0; i<noterefs.length; i++) {
|
| 384 |
-
const ref = noterefs[i];
|
| 385 |
-
tippyHover(ref, function() {
|
| 386 |
-
// use id or data attribute instead here
|
| 387 |
-
let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
|
| 388 |
-
try { href = new URL(href).hash; } catch {}
|
| 389 |
-
const id = href.replace(/^#\/?/, "");
|
| 390 |
-
const note = window.document.getElementById(id);
|
| 391 |
-
return note.innerHTML;
|
| 392 |
-
});
|
| 393 |
-
}
|
| 394 |
-
let selectedAnnoteEl;
|
| 395 |
-
const selectorForAnnotation = ( cell, annotation) => {
|
| 396 |
-
let cellAttr = 'data-code-cell="' + cell + '"';
|
| 397 |
-
let lineAttr = 'data-code-annotation="' + annotation + '"';
|
| 398 |
-
const selector = 'span[' + cellAttr + '][' + lineAttr + ']';
|
| 399 |
-
return selector;
|
| 400 |
-
}
|
| 401 |
-
const selectCodeLines = (annoteEl) => {
|
| 402 |
-
const doc = window.document;
|
| 403 |
-
const targetCell = annoteEl.getAttribute("data-target-cell");
|
| 404 |
-
const targetAnnotation = annoteEl.getAttribute("data-target-annotation");
|
| 405 |
-
const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation));
|
| 406 |
-
const lines = annoteSpan.getAttribute("data-code-lines").split(",");
|
| 407 |
-
const lineIds = lines.map((line) => {
|
| 408 |
-
return targetCell + "-" + line;
|
| 409 |
-
})
|
| 410 |
-
let top = null;
|
| 411 |
-
let height = null;
|
| 412 |
-
let parent = null;
|
| 413 |
-
if (lineIds.length > 0) {
|
| 414 |
-
//compute the position of the single el (top and bottom and make a div)
|
| 415 |
-
const el = window.document.getElementById(lineIds[0]);
|
| 416 |
-
top = el.offsetTop;
|
| 417 |
-
height = el.offsetHeight;
|
| 418 |
-
parent = el.parentElement.parentElement;
|
| 419 |
-
if (lineIds.length > 1) {
|
| 420 |
-
const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]);
|
| 421 |
-
const bottom = lastEl.offsetTop + lastEl.offsetHeight;
|
| 422 |
-
height = bottom - top;
|
| 423 |
-
}
|
| 424 |
-
if (top !== null && height !== null && parent !== null) {
|
| 425 |
-
// cook up a div (if necessary) and position it
|
| 426 |
-
let div = window.document.getElementById("code-annotation-line-highlight");
|
| 427 |
-
if (div === null) {
|
| 428 |
-
div = window.document.createElement("div");
|
| 429 |
-
div.setAttribute("id", "code-annotation-line-highlight");
|
| 430 |
-
div.style.position = 'absolute';
|
| 431 |
-
parent.appendChild(div);
|
| 432 |
-
}
|
| 433 |
-
div.style.top = top - 2 + "px";
|
| 434 |
-
div.style.height = height + 4 + "px";
|
| 435 |
-
let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter");
|
| 436 |
-
if (gutterDiv === null) {
|
| 437 |
-
gutterDiv = window.document.createElement("div");
|
| 438 |
-
gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter");
|
| 439 |
-
gutterDiv.style.position = 'absolute';
|
| 440 |
-
const codeCell = window.document.getElementById(targetCell);
|
| 441 |
-
const gutter = codeCell.querySelector('.code-annotation-gutter');
|
| 442 |
-
gutter.appendChild(gutterDiv);
|
| 443 |
-
}
|
| 444 |
-
gutterDiv.style.top = top - 2 + "px";
|
| 445 |
-
gutterDiv.style.height = height + 4 + "px";
|
| 446 |
-
}
|
| 447 |
-
selectedAnnoteEl = annoteEl;
|
| 448 |
-
}
|
| 449 |
-
};
|
| 450 |
-
const unselectCodeLines = () => {
|
| 451 |
-
const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"];
|
| 452 |
-
elementsIds.forEach((elId) => {
|
| 453 |
-
const div = window.document.getElementById(elId);
|
| 454 |
-
if (div) {
|
| 455 |
-
div.remove();
|
| 456 |
-
}
|
| 457 |
-
});
|
| 458 |
-
selectedAnnoteEl = undefined;
|
| 459 |
-
};
|
| 460 |
-
// Attach click handler to the DT
|
| 461 |
-
const annoteDls = window.document.querySelectorAll('dt[data-target-cell]');
|
| 462 |
-
for (const annoteDlNode of annoteDls) {
|
| 463 |
-
annoteDlNode.addEventListener('click', (event) => {
|
| 464 |
-
const clickedEl = event.target;
|
| 465 |
-
if (clickedEl !== selectedAnnoteEl) {
|
| 466 |
-
unselectCodeLines();
|
| 467 |
-
const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active');
|
| 468 |
-
if (activeEl) {
|
| 469 |
-
activeEl.classList.remove('code-annotation-active');
|
| 470 |
-
}
|
| 471 |
-
selectCodeLines(clickedEl);
|
| 472 |
-
clickedEl.classList.add('code-annotation-active');
|
| 473 |
-
} else {
|
| 474 |
-
// Unselect the line
|
| 475 |
-
unselectCodeLines();
|
| 476 |
-
clickedEl.classList.remove('code-annotation-active');
|
| 477 |
-
}
|
| 478 |
-
});
|
| 479 |
-
}
|
| 480 |
-
const findCites = (el) => {
|
| 481 |
-
const parentEl = el.parentElement;
|
| 482 |
-
if (parentEl) {
|
| 483 |
-
const cites = parentEl.dataset.cites;
|
| 484 |
-
if (cites) {
|
| 485 |
-
return {
|
| 486 |
-
el,
|
| 487 |
-
cites: cites.split(' ')
|
| 488 |
-
};
|
| 489 |
-
} else {
|
| 490 |
-
return findCites(el.parentElement)
|
| 491 |
-
}
|
| 492 |
-
} else {
|
| 493 |
-
return undefined;
|
| 494 |
-
}
|
| 495 |
-
};
|
| 496 |
-
var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
|
| 497 |
-
for (var i=0; i<bibliorefs.length; i++) {
|
| 498 |
-
const ref = bibliorefs[i];
|
| 499 |
-
const citeInfo = findCites(ref);
|
| 500 |
-
if (citeInfo) {
|
| 501 |
-
tippyHover(citeInfo.el, function() {
|
| 502 |
-
var popup = window.document.createElement('div');
|
| 503 |
-
citeInfo.cites.forEach(function(cite) {
|
| 504 |
-
var citeDiv = window.document.createElement('div');
|
| 505 |
-
citeDiv.classList.add('hanging-indent');
|
| 506 |
-
citeDiv.classList.add('csl-entry');
|
| 507 |
-
var biblioDiv = window.document.getElementById('ref-' + cite);
|
| 508 |
-
if (biblioDiv) {
|
| 509 |
-
citeDiv.innerHTML = biblioDiv.innerHTML;
|
| 510 |
-
}
|
| 511 |
-
popup.appendChild(citeDiv);
|
| 512 |
-
});
|
| 513 |
-
return popup.innerHTML;
|
| 514 |
-
});
|
| 515 |
-
}
|
| 516 |
-
}
|
| 517 |
-
});
|
| 518 |
-
</script>
|
| 519 |
-
<nav class="page-navigation">
|
| 520 |
-
<div class="nav-page nav-page-previous">
|
| 521 |
-
<a href="./multiply.html" class="pagination-link">
|
| 522 |
-
<i class="bi bi-arrow-left-short"></i> <span class="nav-page-text"><span class="chapter-number">2</span> <span class="chapter-title">Multiply</span></span>
|
| 523 |
-
</a>
|
| 524 |
-
</div>
|
| 525 |
-
<div class="nav-page nav-page-next">
|
| 526 |
-
<a href="./reducegrow.html" class="pagination-link">
|
| 527 |
-
<span class="nav-page-text"><span class="chapter-number">4</span> <span class="chapter-title">Beginner - Reduce but Grow</span></span> <i class="bi bi-arrow-right-short"></i>
|
| 528 |
-
</a>
|
| 529 |
-
</div>
|
| 530 |
-
</nav>
|
| 531 |
-
</div> <!-- /content -->
|
| 532 |
-
|
| 533 |
-
|
| 534 |
-
|
| 535 |
-
</body></html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
-
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
<title>Codewars Challenge 2024 Menggunakan R dan RStudio - 1 Even or Odd</title>
|
| 11 |
-
<style>
|
| 12 |
-
code{white-space: pre-wrap;}
|
| 13 |
-
span.smallcaps{font-variant: small-caps;}
|
| 14 |
-
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
| 15 |
-
div.column{flex: auto; overflow-x: auto;}
|
| 16 |
-
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
| 17 |
-
ul.task-list{list-style: none;}
|
| 18 |
-
ul.task-list li input[type="checkbox"] {
|
| 19 |
-
width: 0.8em;
|
| 20 |
-
margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
|
| 21 |
-
vertical-align: middle;
|
| 22 |
-
}
|
| 23 |
-
/* CSS for syntax highlighting */
|
| 24 |
-
pre > code.sourceCode { white-space: pre; position: relative; }
|
| 25 |
-
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
|
| 26 |
-
pre > code.sourceCode > span:empty { height: 1.2em; }
|
| 27 |
-
.sourceCode { overflow: visible; }
|
| 28 |
-
code.sourceCode > span { color: inherit; text-decoration: inherit; }
|
| 29 |
-
div.sourceCode { margin: 1em 0; }
|
| 30 |
-
pre.sourceCode { margin: 0; }
|
| 31 |
-
@media screen {
|
| 32 |
-
div.sourceCode { overflow: auto; }
|
| 33 |
-
}
|
| 34 |
-
@media print {
|
| 35 |
-
pre > code.sourceCode { white-space: pre-wrap; }
|
| 36 |
-
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
|
| 37 |
-
}
|
| 38 |
-
pre.numberSource code
|
| 39 |
-
{ counter-reset: source-line 0; }
|
| 40 |
-
pre.numberSource code > span
|
| 41 |
-
{ position: relative; left: -4em; counter-increment: source-line; }
|
| 42 |
-
pre.numberSource code > span > a:first-child::before
|
| 43 |
-
{ content: counter(source-line);
|
| 44 |
-
position: relative; left: -1em; text-align: right; vertical-align: baseline;
|
| 45 |
-
border: none; display: inline-block;
|
| 46 |
-
-webkit-touch-callout: none; -webkit-user-select: none;
|
| 47 |
-
-khtml-user-select: none; -moz-user-select: none;
|
| 48 |
-
-ms-user-select: none; user-select: none;
|
| 49 |
-
padding: 0 4px; width: 4em;
|
| 50 |
-
}
|
| 51 |
-
pre.numberSource { margin-left: 3em; padding-left: 4px; }
|
| 52 |
-
div.sourceCode
|
| 53 |
-
{ }
|
| 54 |
-
@media screen {
|
| 55 |
-
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
|
| 56 |
-
}
|
| 57 |
-
</style>
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
<script src="site_libs/quarto-nav/quarto-nav.js"></script>
|
| 61 |
-
<script src="site_libs/quarto-nav/headroom.min.js"></script>
|
| 62 |
-
<script src="site_libs/clipboard/clipboard.min.js"></script>
|
| 63 |
-
<script src="site_libs/quarto-search/autocomplete.umd.js"></script>
|
| 64 |
-
<script src="site_libs/quarto-search/fuse.min.js"></script>
|
| 65 |
-
<script src="site_libs/quarto-search/quarto-search.js"></script>
|
| 66 |
-
<meta name="quarto:offset" content="./">
|
| 67 |
-
<link href="./multiply.html" rel="next">
|
| 68 |
-
<link href="./index.html" rel="prev">
|
| 69 |
-
<script src="site_libs/quarto-html/quarto.js"></script>
|
| 70 |
-
<script src="site_libs/quarto-html/popper.min.js"></script>
|
| 71 |
-
<script src="site_libs/quarto-html/tippy.umd.min.js"></script>
|
| 72 |
-
<script src="site_libs/quarto-html/anchor.min.js"></script>
|
| 73 |
-
<link href="site_libs/quarto-html/tippy.css" rel="stylesheet">
|
| 74 |
-
<link href="site_libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
|
| 75 |
-
<script src="site_libs/bootstrap/bootstrap.min.js"></script>
|
| 76 |
-
<link href="site_libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
|
| 77 |
-
<link href="site_libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">
|
| 78 |
-
<link href="site_libs/quarto-contrib/badge/badge.css" rel="stylesheet">
|
| 79 |
-
<script id="quarto-search-options" type="application/json">{
|
| 80 |
-
"location": "sidebar",
|
| 81 |
-
"copy-button": false,
|
| 82 |
-
"collapse-after": 3,
|
| 83 |
-
"panel-placement": "start",
|
| 84 |
-
"type": "textbox",
|
| 85 |
-
"limit": 20,
|
| 86 |
-
"language": {
|
| 87 |
-
"search-no-results-text": "No results",
|
| 88 |
-
"search-matching-documents-text": "matching documents",
|
| 89 |
-
"search-copy-link-title": "Copy link to search",
|
| 90 |
-
"search-hide-matches-text": "Hide additional matches",
|
| 91 |
-
"search-more-match-text": "more match in this document",
|
| 92 |
-
"search-more-matches-text": "more matches in this document",
|
| 93 |
-
"search-clear-button-title": "Clear",
|
| 94 |
-
"search-detached-cancel-button-title": "Cancel",
|
| 95 |
-
"search-submit-button-title": "Submit",
|
| 96 |
-
"search-label": "Search"
|
| 97 |
-
}
|
| 98 |
-
}</script>
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
</head>
|
| 102 |
-
|
| 103 |
-
<body class="nav-sidebar floating">
|
| 104 |
-
|
| 105 |
-
<div id="quarto-search-results"></div>
|
| 106 |
-
<header id="quarto-header" class="headroom fixed-top">
|
| 107 |
-
<nav class="quarto-secondary-nav">
|
| 108 |
-
<div class="container-fluid d-flex">
|
| 109 |
-
<button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
|
| 110 |
-
<i class="bi bi-layout-text-sidebar-reverse"></i>
|
| 111 |
-
</button>
|
| 112 |
-
<nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="./evenodd.html"><span class="chapter-number">1</span> <span class="chapter-title">Even or Odd</span></a></li></ol></nav>
|
| 113 |
-
<a class="flex-grow-1" role="button" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
|
| 114 |
-
</a>
|
| 115 |
-
<button type="button" class="btn quarto-search-button" aria-label="" onclick="window.quartoOpenSearch();">
|
| 116 |
-
<i class="bi bi-search"></i>
|
| 117 |
-
</button>
|
| 118 |
-
</div>
|
| 119 |
-
</nav>
|
| 120 |
-
</header>
|
| 121 |
-
<!-- content -->
|
| 122 |
-
<div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article">
|
| 123 |
-
<!-- sidebar -->
|
| 124 |
-
<nav id="quarto-sidebar" class="sidebar collapse collapse-horizontal sidebar-navigation floating overflow-auto">
|
| 125 |
-
<div class="pt-lg-2 mt-2 text-left sidebar-header">
|
| 126 |
-
<div class="sidebar-title mb-0 py-0">
|
| 127 |
-
<a href="./">Codewars Challenge 2024 Menggunakan R dan RStudio</a>
|
| 128 |
-
</div>
|
| 129 |
-
</div>
|
| 130 |
-
<div class="mt-2 flex-shrink-0 align-items-center">
|
| 131 |
-
<div class="sidebar-search">
|
| 132 |
-
<div id="quarto-search" class="" title="Search"></div>
|
| 133 |
-
</div>
|
| 134 |
-
</div>
|
| 135 |
-
<div class="sidebar-menu-container">
|
| 136 |
-
<ul class="list-unstyled mt-1">
|
| 137 |
-
<li class="sidebar-item">
|
| 138 |
-
<div class="sidebar-item-container">
|
| 139 |
-
<a href="./index.html" class="sidebar-item-text sidebar-link">
|
| 140 |
-
<span class="menu-text">Pengantar</span></a>
|
| 141 |
-
</div>
|
| 142 |
-
</li>
|
| 143 |
-
<li class="sidebar-item">
|
| 144 |
-
<div class="sidebar-item-container">
|
| 145 |
-
<a href="./evenodd.html" class="sidebar-item-text sidebar-link active">
|
| 146 |
-
<span class="menu-text"><span class="chapter-number">1</span> <span class="chapter-title">Even or Odd</span></span></a>
|
| 147 |
-
</div>
|
| 148 |
-
</li>
|
| 149 |
-
<li class="sidebar-item">
|
| 150 |
-
<div class="sidebar-item-container">
|
| 151 |
-
<a href="./multiply.html" class="sidebar-item-text sidebar-link">
|
| 152 |
-
<span class="menu-text"><span class="chapter-number">2</span> <span class="chapter-title">Multiply</span></span></a>
|
| 153 |
-
</div>
|
| 154 |
-
</li>
|
| 155 |
-
<li class="sidebar-item">
|
| 156 |
-
<div class="sidebar-item-container">
|
| 157 |
-
<a href="./countsheep.html" class="sidebar-item-text sidebar-link">
|
| 158 |
-
<span class="menu-text"><span class="chapter-number">3</span> <span class="chapter-title">If you can’t sleep, just count sheep!!</span></span></a>
|
| 159 |
-
</div>
|
| 160 |
-
</li>
|
| 161 |
-
<li class="sidebar-item">
|
| 162 |
-
<div class="sidebar-item-container">
|
| 163 |
-
<a href="./reducegrow.html" class="sidebar-item-text sidebar-link">
|
| 164 |
-
<span class="menu-text"><span class="chapter-number">4</span> <span class="chapter-title">Beginner - Reduce but Grow</span></span></a>
|
| 165 |
-
</div>
|
| 166 |
-
</li>
|
| 167 |
-
<li class="sidebar-item">
|
| 168 |
-
<div class="sidebar-item-container">
|
| 169 |
-
<a href="./make_negative.html" class="sidebar-item-text sidebar-link">
|
| 170 |
-
<span class="menu-text"><span class="chapter-number">5</span> <span class="chapter-title">Return Negative</span></span></a>
|
| 171 |
-
</div>
|
| 172 |
-
</li>
|
| 173 |
-
<li class="sidebar-item">
|
| 174 |
-
<div class="sidebar-item-container">
|
| 175 |
-
<a href="./positive_sum.html" class="sidebar-item-text sidebar-link">
|
| 176 |
-
<span class="menu-text"><span class="chapter-number">6</span> <span class="chapter-title">Sum of positive</span></span></a>
|
| 177 |
-
</div>
|
| 178 |
-
</li>
|
| 179 |
-
<li class="sidebar-item">
|
| 180 |
-
<div class="sidebar-item-container">
|
| 181 |
-
<a href="./references.html" class="sidebar-item-text sidebar-link">
|
| 182 |
-
<span class="menu-text">References</span></a>
|
| 183 |
-
</div>
|
| 184 |
-
</li>
|
| 185 |
-
</ul>
|
| 186 |
-
</div>
|
| 187 |
-
</nav>
|
| 188 |
-
<div id="quarto-sidebar-glass" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass"></div>
|
| 189 |
-
<!-- margin-sidebar -->
|
| 190 |
-
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
|
| 191 |
-
<nav id="TOC" role="doc-toc" class="toc-active">
|
| 192 |
-
<h2 id="toc-title">Table of contents</h2>
|
| 193 |
-
|
| 194 |
-
<ul>
|
| 195 |
-
<li><a href="#instruction" id="toc-instruction" class="nav-link active" data-scroll-target="#instruction"><span class="header-section-number">1.1</span> Instruction</a></li>
|
| 196 |
-
<li><a href="#youtube-video" id="toc-youtube-video" class="nav-link" data-scroll-target="#youtube-video"><span class="header-section-number">1.2</span> YouTube Video</a></li>
|
| 197 |
-
<li><a href="#solution-code" id="toc-solution-code" class="nav-link" data-scroll-target="#solution-code"><span class="header-section-number">1.3</span> Solution Code</a></li>
|
| 198 |
-
<li><a href="#test" id="toc-test" class="nav-link" data-scroll-target="#test"><span class="header-section-number">1.4</span> Test</a></li>
|
| 199 |
-
<li><a href="#supported-by" id="toc-supported-by" class="nav-link" data-scroll-target="#supported-by"><span class="header-section-number">1.5</span> Supported by</a></li>
|
| 200 |
-
</ul>
|
| 201 |
-
</nav>
|
| 202 |
-
</div>
|
| 203 |
-
<!-- main -->
|
| 204 |
-
<main class="content" id="quarto-document-content">
|
| 205 |
-
|
| 206 |
-
<header id="title-block-header" class="quarto-title-block default">
|
| 207 |
-
<div class="quarto-title">
|
| 208 |
-
<h1 class="title"><span id="evenodd" class="quarto-section-identifier"><span class="chapter-number">1</span> <span class="chapter-title">Even or Odd</span></span></h1>
|
| 209 |
-
</div>
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
<div class="quarto-title-meta">
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
</div>
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
</header>
|
| 222 |
-
|
| 223 |
-
<p>Tantangan #1/366 - 15 Feb 2024</p>
|
| 224 |
-
<p><a href="https://www.codewars.com/kata/53da3dbb4a5168369a0000fe/train/r" class="uri">https://www.codewars.com/kata/53da3dbb4a5168369a0000fe/train/r</a></p>
|
| 225 |
-
<p><span class="badge rounded-pill quarto-badge " style="background-color: grey;">8kyu</span> Even or Odd</p>
|
| 226 |
-
<section id="instruction" class="level2" data-number="1.1">
|
| 227 |
-
<h2 data-number="1.1" class="anchored" data-anchor-id="instruction"><span class="header-section-number">1.1</span> Instruction</h2>
|
| 228 |
-
<p>Create a function that takes an integer as an argument and returns <code>"Even"</code> for even numbers or <code>"Odd"</code> for odd numbers.</p>
|
| 229 |
-
</section>
|
| 230 |
-
<section id="youtube-video" class="level2" data-number="1.2">
|
| 231 |
-
<h2 data-number="1.2" class="anchored" data-anchor-id="youtube-video"><span class="header-section-number">1.2</span> YouTube Video</h2>
|
| 232 |
-
<div class="quarto-video ratio ratio-16x9"><iframe data-external="1" src="https://www.youtube.com/embed/L8aczEhqymk?si=DSx84acpNvbkucrK" title="" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe></div>
|
| 233 |
-
</section>
|
| 234 |
-
<section id="solution-code" class="level2" data-number="1.3">
|
| 235 |
-
<h2 data-number="1.3" class="anchored" data-anchor-id="solution-code"><span class="header-section-number">1.3</span> Solution Code</h2>
|
| 236 |
-
<p>Solusi bar-bar</p>
|
| 237 |
-
<div class="cell">
|
| 238 |
-
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a>even_or_odd <span class="ot"><-</span> <span class="cf">function</span>(n) {</span>
|
| 239 |
-
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">ifelse</span>(<span class="fu">abs</span>(n<span class="sc">/</span><span class="dv">2</span> <span class="sc">-</span> <span class="fu">as.integer</span>(n<span class="sc">/</span><span class="dv">2</span>)) <span class="sc">==</span> <span class="fl">0.5</span>, <span class="st">"Odd"</span>, <span class="st">"Even"</span>)</span>
|
| 240 |
-
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 241 |
-
</div>
|
| 242 |
-
<p>Solusi simple</p>
|
| 243 |
-
<div class="cell">
|
| 244 |
-
<div class="sourceCode cell-code" id="cb2"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>even_or_odd <span class="ot"><-</span> <span class="cf">function</span>(n) {</span>
|
| 245 |
-
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> <span class="co"># %% operator modulo</span></span>
|
| 246 |
-
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">ifelse</span>(n <span class="sc">%%</span> <span class="dv">2</span> <span class="sc">==</span> <span class="dv">1</span>, <span class="st">"Odd"</span>, <span class="st">"Even"</span>)</span>
|
| 247 |
-
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 248 |
-
</div>
|
| 249 |
-
<div class="cell">
|
| 250 |
-
<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a>even_or_odd <span class="ot"><-</span> <span class="cf">function</span>(n) <span class="fu">c</span>(<span class="st">"Even"</span>, <span class="st">"Odd"</span>)[n <span class="sc">%%</span> <span class="dv">2</span> <span class="sc">+</span> <span class="dv">1</span>]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 251 |
-
</div>
|
| 252 |
-
</section>
|
| 253 |
-
<section id="test" class="level2" data-number="1.4">
|
| 254 |
-
<h2 data-number="1.4" class="anchored" data-anchor-id="test"><span class="header-section-number">1.4</span> Test</h2>
|
| 255 |
-
<div class="cell">
|
| 256 |
-
<div class="sourceCode cell-code" id="cb4"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(testthat)</span>
|
| 257 |
-
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="fu">test_that</span>(<span class="st">'even_or_odd(1) returns "Odd"'</span>, {</span>
|
| 258 |
-
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">expect_equal</span>(<span class="fu">even_or_odd</span>(<span class="dv">1</span>), <span class="st">"Odd"</span>)</span>
|
| 259 |
-
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a>})</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 260 |
-
<div class="cell-output cell-output-stdout">
|
| 261 |
-
<pre><code>Test passed 🥳</code></pre>
|
| 262 |
-
</div>
|
| 263 |
-
<div class="sourceCode cell-code" id="cb6"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="fu">test_that</span>(<span class="st">'even_or_odd(2) returns "Even"'</span>, {</span>
|
| 264 |
-
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">expect_equal</span>(<span class="fu">even_or_odd</span>(<span class="dv">2</span>), <span class="st">"Even"</span>)</span>
|
| 265 |
-
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a>})</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 266 |
-
<div class="cell-output cell-output-stdout">
|
| 267 |
-
<pre><code>Test passed 🎊</code></pre>
|
| 268 |
-
</div>
|
| 269 |
-
<div class="sourceCode cell-code" id="cb8"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="fu">test_that</span>(<span class="st">'even_or_odd(0) returns "Even"'</span>, {</span>
|
| 270 |
-
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">expect_equal</span>(<span class="fu">even_or_odd</span>(<span class="dv">0</span>), <span class="st">"Even"</span>)</span>
|
| 271 |
-
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a>})</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 272 |
-
<div class="cell-output cell-output-stdout">
|
| 273 |
-
<pre><code>Test passed 🌈</code></pre>
|
| 274 |
-
</div>
|
| 275 |
-
<div class="sourceCode cell-code" id="cb10"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="fu">test_that</span>(<span class="st">'even_or_odd(-1) returns "Odd"'</span>, {</span>
|
| 276 |
-
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">expect_equal</span>(<span class="fu">even_or_odd</span>(<span class="sc">-</span><span class="dv">1</span>), <span class="st">"Odd"</span>)</span>
|
| 277 |
-
<span id="cb10-3"><a href="#cb10-3" aria-hidden="true" tabindex="-1"></a>})</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 278 |
-
<div class="cell-output cell-output-stdout">
|
| 279 |
-
<pre><code>Test passed 😀</code></pre>
|
| 280 |
-
</div>
|
| 281 |
-
<div class="sourceCode cell-code" id="cb12"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="fu">test_that</span>(<span class="st">'even_or_odd(-2) returns "Even"'</span>, {</span>
|
| 282 |
-
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">expect_equal</span>(<span class="fu">even_or_odd</span>(<span class="sc">-</span><span class="dv">2</span>), <span class="st">"Even"</span>)</span>
|
| 283 |
-
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a>})</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 284 |
-
<div class="cell-output cell-output-stdout">
|
| 285 |
-
<pre><code>Test passed 🥇</code></pre>
|
| 286 |
-
</div>
|
| 287 |
-
</div>
|
| 288 |
-
</section>
|
| 289 |
-
<section id="supported-by" class="level2" data-number="1.5">
|
| 290 |
-
<h2 data-number="1.5" class="anchored" data-anchor-id="supported-by"><span class="header-section-number">1.5</span> Supported by</h2>
|
| 291 |
-
<div class="quarto-figure quarto-figure-center">
|
| 292 |
-
<figure class="figure">
|
| 293 |
-
<p><a href="https://www.starcore.co"><img src="new_starcore_logo.png" class="img-fluid figure-img"></a></p>
|
| 294 |
-
<figcaption class="figure-caption">StarCore Analytics</figcaption>
|
| 295 |
-
</figure>
|
| 296 |
-
</div>
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
</section>
|
| 300 |
-
|
| 301 |
-
</main> <!-- /main -->
|
| 302 |
-
<script id="quarto-html-after-body" type="application/javascript">
|
| 303 |
-
window.document.addEventListener("DOMContentLoaded", function (event) {
|
| 304 |
-
const toggleBodyColorMode = (bsSheetEl) => {
|
| 305 |
-
const mode = bsSheetEl.getAttribute("data-mode");
|
| 306 |
-
const bodyEl = window.document.querySelector("body");
|
| 307 |
-
if (mode === "dark") {
|
| 308 |
-
bodyEl.classList.add("quarto-dark");
|
| 309 |
-
bodyEl.classList.remove("quarto-light");
|
| 310 |
-
} else {
|
| 311 |
-
bodyEl.classList.add("quarto-light");
|
| 312 |
-
bodyEl.classList.remove("quarto-dark");
|
| 313 |
-
}
|
| 314 |
-
}
|
| 315 |
-
const toggleBodyColorPrimary = () => {
|
| 316 |
-
const bsSheetEl = window.document.querySelector("link#quarto-bootstrap");
|
| 317 |
-
if (bsSheetEl) {
|
| 318 |
-
toggleBodyColorMode(bsSheetEl);
|
| 319 |
-
}
|
| 320 |
-
}
|
| 321 |
-
toggleBodyColorPrimary();
|
| 322 |
-
const icon = "";
|
| 323 |
-
const anchorJS = new window.AnchorJS();
|
| 324 |
-
anchorJS.options = {
|
| 325 |
-
placement: 'right',
|
| 326 |
-
icon: icon
|
| 327 |
-
};
|
| 328 |
-
anchorJS.add('.anchored');
|
| 329 |
-
const isCodeAnnotation = (el) => {
|
| 330 |
-
for (const clz of el.classList) {
|
| 331 |
-
if (clz.startsWith('code-annotation-')) {
|
| 332 |
-
return true;
|
| 333 |
-
}
|
| 334 |
-
}
|
| 335 |
-
return false;
|
| 336 |
-
}
|
| 337 |
-
const clipboard = new window.ClipboardJS('.code-copy-button', {
|
| 338 |
-
text: function(trigger) {
|
| 339 |
-
const codeEl = trigger.previousElementSibling.cloneNode(true);
|
| 340 |
-
for (const childEl of codeEl.children) {
|
| 341 |
-
if (isCodeAnnotation(childEl)) {
|
| 342 |
-
childEl.remove();
|
| 343 |
-
}
|
| 344 |
-
}
|
| 345 |
-
return codeEl.innerText;
|
| 346 |
-
}
|
| 347 |
-
});
|
| 348 |
-
clipboard.on('success', function(e) {
|
| 349 |
-
// button target
|
| 350 |
-
const button = e.trigger;
|
| 351 |
-
// don't keep focus
|
| 352 |
-
button.blur();
|
| 353 |
-
// flash "checked"
|
| 354 |
-
button.classList.add('code-copy-button-checked');
|
| 355 |
-
var currentTitle = button.getAttribute("title");
|
| 356 |
-
button.setAttribute("title", "Copied!");
|
| 357 |
-
let tooltip;
|
| 358 |
-
if (window.bootstrap) {
|
| 359 |
-
button.setAttribute("data-bs-toggle", "tooltip");
|
| 360 |
-
button.setAttribute("data-bs-placement", "left");
|
| 361 |
-
button.setAttribute("data-bs-title", "Copied!");
|
| 362 |
-
tooltip = new bootstrap.Tooltip(button,
|
| 363 |
-
{ trigger: "manual",
|
| 364 |
-
customClass: "code-copy-button-tooltip",
|
| 365 |
-
offset: [0, -8]});
|
| 366 |
-
tooltip.show();
|
| 367 |
-
}
|
| 368 |
-
setTimeout(function() {
|
| 369 |
-
if (tooltip) {
|
| 370 |
-
tooltip.hide();
|
| 371 |
-
button.removeAttribute("data-bs-title");
|
| 372 |
-
button.removeAttribute("data-bs-toggle");
|
| 373 |
-
button.removeAttribute("data-bs-placement");
|
| 374 |
-
}
|
| 375 |
-
button.setAttribute("title", currentTitle);
|
| 376 |
-
button.classList.remove('code-copy-button-checked');
|
| 377 |
-
}, 1000);
|
| 378 |
-
// clear code selection
|
| 379 |
-
e.clearSelection();
|
| 380 |
-
});
|
| 381 |
-
function tippyHover(el, contentFn) {
|
| 382 |
-
const config = {
|
| 383 |
-
allowHTML: true,
|
| 384 |
-
content: contentFn,
|
| 385 |
-
maxWidth: 500,
|
| 386 |
-
delay: 100,
|
| 387 |
-
arrow: false,
|
| 388 |
-
appendTo: function(el) {
|
| 389 |
-
return el.parentElement;
|
| 390 |
-
},
|
| 391 |
-
interactive: true,
|
| 392 |
-
interactiveBorder: 10,
|
| 393 |
-
theme: 'quarto',
|
| 394 |
-
placement: 'bottom-start'
|
| 395 |
-
};
|
| 396 |
-
window.tippy(el, config);
|
| 397 |
-
}
|
| 398 |
-
const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
|
| 399 |
-
for (var i=0; i<noterefs.length; i++) {
|
| 400 |
-
const ref = noterefs[i];
|
| 401 |
-
tippyHover(ref, function() {
|
| 402 |
-
// use id or data attribute instead here
|
| 403 |
-
let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
|
| 404 |
-
try { href = new URL(href).hash; } catch {}
|
| 405 |
-
const id = href.replace(/^#\/?/, "");
|
| 406 |
-
const note = window.document.getElementById(id);
|
| 407 |
-
return note.innerHTML;
|
| 408 |
-
});
|
| 409 |
-
}
|
| 410 |
-
let selectedAnnoteEl;
|
| 411 |
-
const selectorForAnnotation = ( cell, annotation) => {
|
| 412 |
-
let cellAttr = 'data-code-cell="' + cell + '"';
|
| 413 |
-
let lineAttr = 'data-code-annotation="' + annotation + '"';
|
| 414 |
-
const selector = 'span[' + cellAttr + '][' + lineAttr + ']';
|
| 415 |
-
return selector;
|
| 416 |
-
}
|
| 417 |
-
const selectCodeLines = (annoteEl) => {
|
| 418 |
-
const doc = window.document;
|
| 419 |
-
const targetCell = annoteEl.getAttribute("data-target-cell");
|
| 420 |
-
const targetAnnotation = annoteEl.getAttribute("data-target-annotation");
|
| 421 |
-
const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation));
|
| 422 |
-
const lines = annoteSpan.getAttribute("data-code-lines").split(",");
|
| 423 |
-
const lineIds = lines.map((line) => {
|
| 424 |
-
return targetCell + "-" + line;
|
| 425 |
-
})
|
| 426 |
-
let top = null;
|
| 427 |
-
let height = null;
|
| 428 |
-
let parent = null;
|
| 429 |
-
if (lineIds.length > 0) {
|
| 430 |
-
//compute the position of the single el (top and bottom and make a div)
|
| 431 |
-
const el = window.document.getElementById(lineIds[0]);
|
| 432 |
-
top = el.offsetTop;
|
| 433 |
-
height = el.offsetHeight;
|
| 434 |
-
parent = el.parentElement.parentElement;
|
| 435 |
-
if (lineIds.length > 1) {
|
| 436 |
-
const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]);
|
| 437 |
-
const bottom = lastEl.offsetTop + lastEl.offsetHeight;
|
| 438 |
-
height = bottom - top;
|
| 439 |
-
}
|
| 440 |
-
if (top !== null && height !== null && parent !== null) {
|
| 441 |
-
// cook up a div (if necessary) and position it
|
| 442 |
-
let div = window.document.getElementById("code-annotation-line-highlight");
|
| 443 |
-
if (div === null) {
|
| 444 |
-
div = window.document.createElement("div");
|
| 445 |
-
div.setAttribute("id", "code-annotation-line-highlight");
|
| 446 |
-
div.style.position = 'absolute';
|
| 447 |
-
parent.appendChild(div);
|
| 448 |
-
}
|
| 449 |
-
div.style.top = top - 2 + "px";
|
| 450 |
-
div.style.height = height + 4 + "px";
|
| 451 |
-
let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter");
|
| 452 |
-
if (gutterDiv === null) {
|
| 453 |
-
gutterDiv = window.document.createElement("div");
|
| 454 |
-
gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter");
|
| 455 |
-
gutterDiv.style.position = 'absolute';
|
| 456 |
-
const codeCell = window.document.getElementById(targetCell);
|
| 457 |
-
const gutter = codeCell.querySelector('.code-annotation-gutter');
|
| 458 |
-
gutter.appendChild(gutterDiv);
|
| 459 |
-
}
|
| 460 |
-
gutterDiv.style.top = top - 2 + "px";
|
| 461 |
-
gutterDiv.style.height = height + 4 + "px";
|
| 462 |
-
}
|
| 463 |
-
selectedAnnoteEl = annoteEl;
|
| 464 |
-
}
|
| 465 |
-
};
|
| 466 |
-
const unselectCodeLines = () => {
|
| 467 |
-
const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"];
|
| 468 |
-
elementsIds.forEach((elId) => {
|
| 469 |
-
const div = window.document.getElementById(elId);
|
| 470 |
-
if (div) {
|
| 471 |
-
div.remove();
|
| 472 |
-
}
|
| 473 |
-
});
|
| 474 |
-
selectedAnnoteEl = undefined;
|
| 475 |
-
};
|
| 476 |
-
// Attach click handler to the DT
|
| 477 |
-
const annoteDls = window.document.querySelectorAll('dt[data-target-cell]');
|
| 478 |
-
for (const annoteDlNode of annoteDls) {
|
| 479 |
-
annoteDlNode.addEventListener('click', (event) => {
|
| 480 |
-
const clickedEl = event.target;
|
| 481 |
-
if (clickedEl !== selectedAnnoteEl) {
|
| 482 |
-
unselectCodeLines();
|
| 483 |
-
const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active');
|
| 484 |
-
if (activeEl) {
|
| 485 |
-
activeEl.classList.remove('code-annotation-active');
|
| 486 |
-
}
|
| 487 |
-
selectCodeLines(clickedEl);
|
| 488 |
-
clickedEl.classList.add('code-annotation-active');
|
| 489 |
-
} else {
|
| 490 |
-
// Unselect the line
|
| 491 |
-
unselectCodeLines();
|
| 492 |
-
clickedEl.classList.remove('code-annotation-active');
|
| 493 |
-
}
|
| 494 |
-
});
|
| 495 |
-
}
|
| 496 |
-
const findCites = (el) => {
|
| 497 |
-
const parentEl = el.parentElement;
|
| 498 |
-
if (parentEl) {
|
| 499 |
-
const cites = parentEl.dataset.cites;
|
| 500 |
-
if (cites) {
|
| 501 |
-
return {
|
| 502 |
-
el,
|
| 503 |
-
cites: cites.split(' ')
|
| 504 |
-
};
|
| 505 |
-
} else {
|
| 506 |
-
return findCites(el.parentElement)
|
| 507 |
-
}
|
| 508 |
-
} else {
|
| 509 |
-
return undefined;
|
| 510 |
-
}
|
| 511 |
-
};
|
| 512 |
-
var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
|
| 513 |
-
for (var i=0; i<bibliorefs.length; i++) {
|
| 514 |
-
const ref = bibliorefs[i];
|
| 515 |
-
const citeInfo = findCites(ref);
|
| 516 |
-
if (citeInfo) {
|
| 517 |
-
tippyHover(citeInfo.el, function() {
|
| 518 |
-
var popup = window.document.createElement('div');
|
| 519 |
-
citeInfo.cites.forEach(function(cite) {
|
| 520 |
-
var citeDiv = window.document.createElement('div');
|
| 521 |
-
citeDiv.classList.add('hanging-indent');
|
| 522 |
-
citeDiv.classList.add('csl-entry');
|
| 523 |
-
var biblioDiv = window.document.getElementById('ref-' + cite);
|
| 524 |
-
if (biblioDiv) {
|
| 525 |
-
citeDiv.innerHTML = biblioDiv.innerHTML;
|
| 526 |
-
}
|
| 527 |
-
popup.appendChild(citeDiv);
|
| 528 |
-
});
|
| 529 |
-
return popup.innerHTML;
|
| 530 |
-
});
|
| 531 |
-
}
|
| 532 |
-
}
|
| 533 |
-
});
|
| 534 |
-
</script>
|
| 535 |
-
<nav class="page-navigation">
|
| 536 |
-
<div class="nav-page nav-page-previous">
|
| 537 |
-
<a href="./index.html" class="pagination-link">
|
| 538 |
-
<i class="bi bi-arrow-left-short"></i> <span class="nav-page-text">Pengantar</span>
|
| 539 |
-
</a>
|
| 540 |
-
</div>
|
| 541 |
-
<div class="nav-page nav-page-next">
|
| 542 |
-
<a href="./multiply.html" class="pagination-link">
|
| 543 |
-
<span class="nav-page-text"><span class="chapter-number">2</span> <span class="chapter-title">Multiply</span></span> <i class="bi bi-arrow-right-short"></i>
|
| 544 |
-
</a>
|
| 545 |
-
</div>
|
| 546 |
-
</nav>
|
| 547 |
-
</div> <!-- /content -->
|
| 548 |
-
|
| 549 |
-
|
| 550 |
-
|
| 551 |
-
</body></html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
intro.html
DELETED
|
@@ -1,484 +0,0 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
|
| 3 |
-
|
| 4 |
-
<meta charset="utf-8">
|
| 5 |
-
<meta name="generator" content="quarto-1.3.433">
|
| 6 |
-
|
| 7 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
<title>Codewars Using R and RStudio - Introduction</title>
|
| 11 |
-
<style>
|
| 12 |
-
code{white-space: pre-wrap;}
|
| 13 |
-
span.smallcaps{font-variant: small-caps;}
|
| 14 |
-
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
| 15 |
-
div.column{flex: auto; overflow-x: auto;}
|
| 16 |
-
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
| 17 |
-
ul.task-list{list-style: none;}
|
| 18 |
-
ul.task-list li input[type="checkbox"] {
|
| 19 |
-
width: 0.8em;
|
| 20 |
-
margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
|
| 21 |
-
vertical-align: middle;
|
| 22 |
-
}
|
| 23 |
-
/* CSS for syntax highlighting */
|
| 24 |
-
pre > code.sourceCode { white-space: pre; position: relative; }
|
| 25 |
-
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
|
| 26 |
-
pre > code.sourceCode > span:empty { height: 1.2em; }
|
| 27 |
-
.sourceCode { overflow: visible; }
|
| 28 |
-
code.sourceCode > span { color: inherit; text-decoration: inherit; }
|
| 29 |
-
div.sourceCode { margin: 1em 0; }
|
| 30 |
-
pre.sourceCode { margin: 0; }
|
| 31 |
-
@media screen {
|
| 32 |
-
div.sourceCode { overflow: auto; }
|
| 33 |
-
}
|
| 34 |
-
@media print {
|
| 35 |
-
pre > code.sourceCode { white-space: pre-wrap; }
|
| 36 |
-
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
|
| 37 |
-
}
|
| 38 |
-
pre.numberSource code
|
| 39 |
-
{ counter-reset: source-line 0; }
|
| 40 |
-
pre.numberSource code > span
|
| 41 |
-
{ position: relative; left: -4em; counter-increment: source-line; }
|
| 42 |
-
pre.numberSource code > span > a:first-child::before
|
| 43 |
-
{ content: counter(source-line);
|
| 44 |
-
position: relative; left: -1em; text-align: right; vertical-align: baseline;
|
| 45 |
-
border: none; display: inline-block;
|
| 46 |
-
-webkit-touch-callout: none; -webkit-user-select: none;
|
| 47 |
-
-khtml-user-select: none; -moz-user-select: none;
|
| 48 |
-
-ms-user-select: none; user-select: none;
|
| 49 |
-
padding: 0 4px; width: 4em;
|
| 50 |
-
}
|
| 51 |
-
pre.numberSource { margin-left: 3em; padding-left: 4px; }
|
| 52 |
-
div.sourceCode
|
| 53 |
-
{ }
|
| 54 |
-
@media screen {
|
| 55 |
-
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
|
| 56 |
-
}
|
| 57 |
-
/* CSS for citations */
|
| 58 |
-
div.csl-bib-body { }
|
| 59 |
-
div.csl-entry {
|
| 60 |
-
clear: both;
|
| 61 |
-
}
|
| 62 |
-
.hanging-indent div.csl-entry {
|
| 63 |
-
margin-left:2em;
|
| 64 |
-
text-indent:-2em;
|
| 65 |
-
}
|
| 66 |
-
div.csl-left-margin {
|
| 67 |
-
min-width:2em;
|
| 68 |
-
float:left;
|
| 69 |
-
}
|
| 70 |
-
div.csl-right-inline {
|
| 71 |
-
margin-left:2em;
|
| 72 |
-
padding-left:1em;
|
| 73 |
-
}
|
| 74 |
-
div.csl-indent {
|
| 75 |
-
margin-left: 2em;
|
| 76 |
-
}</style>
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
<script src="site_libs/quarto-nav/quarto-nav.js"></script>
|
| 80 |
-
<script src="site_libs/quarto-nav/headroom.min.js"></script>
|
| 81 |
-
<script src="site_libs/clipboard/clipboard.min.js"></script>
|
| 82 |
-
<script src="site_libs/quarto-search/autocomplete.umd.js"></script>
|
| 83 |
-
<script src="site_libs/quarto-search/fuse.min.js"></script>
|
| 84 |
-
<script src="site_libs/quarto-search/quarto-search.js"></script>
|
| 85 |
-
<meta name="quarto:offset" content="./">
|
| 86 |
-
<link href="./001-reducegrow.html" rel="next">
|
| 87 |
-
<link href="./index.html" rel="prev">
|
| 88 |
-
<script src="site_libs/quarto-html/quarto.js"></script>
|
| 89 |
-
<script src="site_libs/quarto-html/popper.min.js"></script>
|
| 90 |
-
<script src="site_libs/quarto-html/tippy.umd.min.js"></script>
|
| 91 |
-
<script src="site_libs/quarto-html/anchor.min.js"></script>
|
| 92 |
-
<link href="site_libs/quarto-html/tippy.css" rel="stylesheet">
|
| 93 |
-
<link href="site_libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
|
| 94 |
-
<script src="site_libs/bootstrap/bootstrap.min.js"></script>
|
| 95 |
-
<link href="site_libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
|
| 96 |
-
<link href="site_libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">
|
| 97 |
-
<script id="quarto-search-options" type="application/json">{
|
| 98 |
-
"location": "sidebar",
|
| 99 |
-
"copy-button": false,
|
| 100 |
-
"collapse-after": 3,
|
| 101 |
-
"panel-placement": "start",
|
| 102 |
-
"type": "textbox",
|
| 103 |
-
"limit": 20,
|
| 104 |
-
"language": {
|
| 105 |
-
"search-no-results-text": "No results",
|
| 106 |
-
"search-matching-documents-text": "matching documents",
|
| 107 |
-
"search-copy-link-title": "Copy link to search",
|
| 108 |
-
"search-hide-matches-text": "Hide additional matches",
|
| 109 |
-
"search-more-match-text": "more match in this document",
|
| 110 |
-
"search-more-matches-text": "more matches in this document",
|
| 111 |
-
"search-clear-button-title": "Clear",
|
| 112 |
-
"search-detached-cancel-button-title": "Cancel",
|
| 113 |
-
"search-submit-button-title": "Submit",
|
| 114 |
-
"search-label": "Search"
|
| 115 |
-
}
|
| 116 |
-
}</script>
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
</head>
|
| 120 |
-
|
| 121 |
-
<body class="nav-sidebar floating">
|
| 122 |
-
|
| 123 |
-
<div id="quarto-search-results"></div>
|
| 124 |
-
<header id="quarto-header" class="headroom fixed-top">
|
| 125 |
-
<nav class="quarto-secondary-nav">
|
| 126 |
-
<div class="container-fluid d-flex">
|
| 127 |
-
<button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
|
| 128 |
-
<i class="bi bi-layout-text-sidebar-reverse"></i>
|
| 129 |
-
</button>
|
| 130 |
-
<nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="./intro.html">Introduction</a></li></ol></nav>
|
| 131 |
-
<a class="flex-grow-1" role="button" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
|
| 132 |
-
</a>
|
| 133 |
-
<button type="button" class="btn quarto-search-button" aria-label="" onclick="window.quartoOpenSearch();">
|
| 134 |
-
<i class="bi bi-search"></i>
|
| 135 |
-
</button>
|
| 136 |
-
</div>
|
| 137 |
-
</nav>
|
| 138 |
-
</header>
|
| 139 |
-
<!-- content -->
|
| 140 |
-
<div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article">
|
| 141 |
-
<!-- sidebar -->
|
| 142 |
-
<nav id="quarto-sidebar" class="sidebar collapse collapse-horizontal sidebar-navigation floating overflow-auto">
|
| 143 |
-
<div class="pt-lg-2 mt-2 text-left sidebar-header">
|
| 144 |
-
<div class="sidebar-title mb-0 py-0">
|
| 145 |
-
<a href="./">Codewars Using R and RStudio</a>
|
| 146 |
-
</div>
|
| 147 |
-
</div>
|
| 148 |
-
<div class="mt-2 flex-shrink-0 align-items-center">
|
| 149 |
-
<div class="sidebar-search">
|
| 150 |
-
<div id="quarto-search" class="" title="Search"></div>
|
| 151 |
-
</div>
|
| 152 |
-
</div>
|
| 153 |
-
<div class="sidebar-menu-container">
|
| 154 |
-
<ul class="list-unstyled mt-1">
|
| 155 |
-
<li class="sidebar-item">
|
| 156 |
-
<div class="sidebar-item-container">
|
| 157 |
-
<a href="./index.html" class="sidebar-item-text sidebar-link">
|
| 158 |
-
<span class="menu-text">Preface</span></a>
|
| 159 |
-
</div>
|
| 160 |
-
</li>
|
| 161 |
-
<li class="sidebar-item">
|
| 162 |
-
<div class="sidebar-item-container">
|
| 163 |
-
<a href="./intro.html" class="sidebar-item-text sidebar-link active">
|
| 164 |
-
<span class="menu-text">Introduction</span></a>
|
| 165 |
-
</div>
|
| 166 |
-
</li>
|
| 167 |
-
<li class="sidebar-item sidebar-item-section">
|
| 168 |
-
<div class="sidebar-item-container">
|
| 169 |
-
<a class="sidebar-item-text sidebar-link text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-1" aria-expanded="true">
|
| 170 |
-
<span class="menu-text">codewars2024.qmd</span></a>
|
| 171 |
-
<a class="sidebar-item-toggle text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-1" aria-expanded="true" aria-label="Toggle section">
|
| 172 |
-
<i class="bi bi-chevron-right ms-2"></i>
|
| 173 |
-
</a>
|
| 174 |
-
</div>
|
| 175 |
-
<ul id="quarto-sidebar-section-1" class="collapse list-unstyled sidebar-section depth1 show">
|
| 176 |
-
<li class="sidebar-item">
|
| 177 |
-
<div class="sidebar-item-container">
|
| 178 |
-
<a href="./001-reducegrow.html" class="sidebar-item-text sidebar-link">
|
| 179 |
-
<span class="menu-text"><span class="chapter-number">1</span> <span class="chapter-title">Beginner - Reduce but Grow</span></span></a>
|
| 180 |
-
</div>
|
| 181 |
-
</li>
|
| 182 |
-
</ul>
|
| 183 |
-
</li>
|
| 184 |
-
<li class="sidebar-item">
|
| 185 |
-
<div class="sidebar-item-container">
|
| 186 |
-
<a href="./references.html" class="sidebar-item-text sidebar-link">
|
| 187 |
-
<span class="menu-text">References</span></a>
|
| 188 |
-
</div>
|
| 189 |
-
</li>
|
| 190 |
-
</ul>
|
| 191 |
-
</div>
|
| 192 |
-
</nav>
|
| 193 |
-
<div id="quarto-sidebar-glass" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass"></div>
|
| 194 |
-
<!-- margin-sidebar -->
|
| 195 |
-
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
|
| 196 |
-
|
| 197 |
-
</div>
|
| 198 |
-
<!-- main -->
|
| 199 |
-
<main class="content" id="quarto-document-content">
|
| 200 |
-
|
| 201 |
-
<header id="title-block-header" class="quarto-title-block default">
|
| 202 |
-
<div class="quarto-title">
|
| 203 |
-
<h1 class="title">Introduction</h1>
|
| 204 |
-
</div>
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
<div class="quarto-title-meta">
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
</div>
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
</header>
|
| 217 |
-
|
| 218 |
-
<p>This is a book created from markdown and executable code.</p>
|
| 219 |
-
<p>See <span class="citation" data-cites="knuth84">Knuth (<a href="references.html#ref-knuth84" role="doc-biblioref">1984</a>)</span> for additional discussion of literate programming.</p>
|
| 220 |
-
<div class="cell">
|
| 221 |
-
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="dv">1</span> <span class="sc">+</span> <span class="dv">1</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 222 |
-
<div class="cell-output cell-output-stdout">
|
| 223 |
-
<pre><code>[1] 2</code></pre>
|
| 224 |
-
</div>
|
| 225 |
-
</div>
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
<div id="refs" class="references csl-bib-body hanging-indent" role="list" style="display: none">
|
| 229 |
-
<div id="ref-knuth84" class="csl-entry" role="listitem">
|
| 230 |
-
Knuth, Donald E. 1984. <span>“Literate Programming.”</span> <em>Comput. J.</em> 27 (2): 97–111. <a href="https://doi.org/10.1093/comjnl/27.2.97">https://doi.org/10.1093/comjnl/27.2.97</a>.
|
| 231 |
-
</div>
|
| 232 |
-
</div>
|
| 233 |
-
|
| 234 |
-
</main> <!-- /main -->
|
| 235 |
-
<script id="quarto-html-after-body" type="application/javascript">
|
| 236 |
-
window.document.addEventListener("DOMContentLoaded", function (event) {
|
| 237 |
-
const toggleBodyColorMode = (bsSheetEl) => {
|
| 238 |
-
const mode = bsSheetEl.getAttribute("data-mode");
|
| 239 |
-
const bodyEl = window.document.querySelector("body");
|
| 240 |
-
if (mode === "dark") {
|
| 241 |
-
bodyEl.classList.add("quarto-dark");
|
| 242 |
-
bodyEl.classList.remove("quarto-light");
|
| 243 |
-
} else {
|
| 244 |
-
bodyEl.classList.add("quarto-light");
|
| 245 |
-
bodyEl.classList.remove("quarto-dark");
|
| 246 |
-
}
|
| 247 |
-
}
|
| 248 |
-
const toggleBodyColorPrimary = () => {
|
| 249 |
-
const bsSheetEl = window.document.querySelector("link#quarto-bootstrap");
|
| 250 |
-
if (bsSheetEl) {
|
| 251 |
-
toggleBodyColorMode(bsSheetEl);
|
| 252 |
-
}
|
| 253 |
-
}
|
| 254 |
-
toggleBodyColorPrimary();
|
| 255 |
-
const icon = "";
|
| 256 |
-
const anchorJS = new window.AnchorJS();
|
| 257 |
-
anchorJS.options = {
|
| 258 |
-
placement: 'right',
|
| 259 |
-
icon: icon
|
| 260 |
-
};
|
| 261 |
-
anchorJS.add('.anchored');
|
| 262 |
-
const isCodeAnnotation = (el) => {
|
| 263 |
-
for (const clz of el.classList) {
|
| 264 |
-
if (clz.startsWith('code-annotation-')) {
|
| 265 |
-
return true;
|
| 266 |
-
}
|
| 267 |
-
}
|
| 268 |
-
return false;
|
| 269 |
-
}
|
| 270 |
-
const clipboard = new window.ClipboardJS('.code-copy-button', {
|
| 271 |
-
text: function(trigger) {
|
| 272 |
-
const codeEl = trigger.previousElementSibling.cloneNode(true);
|
| 273 |
-
for (const childEl of codeEl.children) {
|
| 274 |
-
if (isCodeAnnotation(childEl)) {
|
| 275 |
-
childEl.remove();
|
| 276 |
-
}
|
| 277 |
-
}
|
| 278 |
-
return codeEl.innerText;
|
| 279 |
-
}
|
| 280 |
-
});
|
| 281 |
-
clipboard.on('success', function(e) {
|
| 282 |
-
// button target
|
| 283 |
-
const button = e.trigger;
|
| 284 |
-
// don't keep focus
|
| 285 |
-
button.blur();
|
| 286 |
-
// flash "checked"
|
| 287 |
-
button.classList.add('code-copy-button-checked');
|
| 288 |
-
var currentTitle = button.getAttribute("title");
|
| 289 |
-
button.setAttribute("title", "Copied!");
|
| 290 |
-
let tooltip;
|
| 291 |
-
if (window.bootstrap) {
|
| 292 |
-
button.setAttribute("data-bs-toggle", "tooltip");
|
| 293 |
-
button.setAttribute("data-bs-placement", "left");
|
| 294 |
-
button.setAttribute("data-bs-title", "Copied!");
|
| 295 |
-
tooltip = new bootstrap.Tooltip(button,
|
| 296 |
-
{ trigger: "manual",
|
| 297 |
-
customClass: "code-copy-button-tooltip",
|
| 298 |
-
offset: [0, -8]});
|
| 299 |
-
tooltip.show();
|
| 300 |
-
}
|
| 301 |
-
setTimeout(function() {
|
| 302 |
-
if (tooltip) {
|
| 303 |
-
tooltip.hide();
|
| 304 |
-
button.removeAttribute("data-bs-title");
|
| 305 |
-
button.removeAttribute("data-bs-toggle");
|
| 306 |
-
button.removeAttribute("data-bs-placement");
|
| 307 |
-
}
|
| 308 |
-
button.setAttribute("title", currentTitle);
|
| 309 |
-
button.classList.remove('code-copy-button-checked');
|
| 310 |
-
}, 1000);
|
| 311 |
-
// clear code selection
|
| 312 |
-
e.clearSelection();
|
| 313 |
-
});
|
| 314 |
-
function tippyHover(el, contentFn) {
|
| 315 |
-
const config = {
|
| 316 |
-
allowHTML: true,
|
| 317 |
-
content: contentFn,
|
| 318 |
-
maxWidth: 500,
|
| 319 |
-
delay: 100,
|
| 320 |
-
arrow: false,
|
| 321 |
-
appendTo: function(el) {
|
| 322 |
-
return el.parentElement;
|
| 323 |
-
},
|
| 324 |
-
interactive: true,
|
| 325 |
-
interactiveBorder: 10,
|
| 326 |
-
theme: 'quarto',
|
| 327 |
-
placement: 'bottom-start'
|
| 328 |
-
};
|
| 329 |
-
window.tippy(el, config);
|
| 330 |
-
}
|
| 331 |
-
const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
|
| 332 |
-
for (var i=0; i<noterefs.length; i++) {
|
| 333 |
-
const ref = noterefs[i];
|
| 334 |
-
tippyHover(ref, function() {
|
| 335 |
-
// use id or data attribute instead here
|
| 336 |
-
let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
|
| 337 |
-
try { href = new URL(href).hash; } catch {}
|
| 338 |
-
const id = href.replace(/^#\/?/, "");
|
| 339 |
-
const note = window.document.getElementById(id);
|
| 340 |
-
return note.innerHTML;
|
| 341 |
-
});
|
| 342 |
-
}
|
| 343 |
-
let selectedAnnoteEl;
|
| 344 |
-
const selectorForAnnotation = ( cell, annotation) => {
|
| 345 |
-
let cellAttr = 'data-code-cell="' + cell + '"';
|
| 346 |
-
let lineAttr = 'data-code-annotation="' + annotation + '"';
|
| 347 |
-
const selector = 'span[' + cellAttr + '][' + lineAttr + ']';
|
| 348 |
-
return selector;
|
| 349 |
-
}
|
| 350 |
-
const selectCodeLines = (annoteEl) => {
|
| 351 |
-
const doc = window.document;
|
| 352 |
-
const targetCell = annoteEl.getAttribute("data-target-cell");
|
| 353 |
-
const targetAnnotation = annoteEl.getAttribute("data-target-annotation");
|
| 354 |
-
const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation));
|
| 355 |
-
const lines = annoteSpan.getAttribute("data-code-lines").split(",");
|
| 356 |
-
const lineIds = lines.map((line) => {
|
| 357 |
-
return targetCell + "-" + line;
|
| 358 |
-
})
|
| 359 |
-
let top = null;
|
| 360 |
-
let height = null;
|
| 361 |
-
let parent = null;
|
| 362 |
-
if (lineIds.length > 0) {
|
| 363 |
-
//compute the position of the single el (top and bottom and make a div)
|
| 364 |
-
const el = window.document.getElementById(lineIds[0]);
|
| 365 |
-
top = el.offsetTop;
|
| 366 |
-
height = el.offsetHeight;
|
| 367 |
-
parent = el.parentElement.parentElement;
|
| 368 |
-
if (lineIds.length > 1) {
|
| 369 |
-
const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]);
|
| 370 |
-
const bottom = lastEl.offsetTop + lastEl.offsetHeight;
|
| 371 |
-
height = bottom - top;
|
| 372 |
-
}
|
| 373 |
-
if (top !== null && height !== null && parent !== null) {
|
| 374 |
-
// cook up a div (if necessary) and position it
|
| 375 |
-
let div = window.document.getElementById("code-annotation-line-highlight");
|
| 376 |
-
if (div === null) {
|
| 377 |
-
div = window.document.createElement("div");
|
| 378 |
-
div.setAttribute("id", "code-annotation-line-highlight");
|
| 379 |
-
div.style.position = 'absolute';
|
| 380 |
-
parent.appendChild(div);
|
| 381 |
-
}
|
| 382 |
-
div.style.top = top - 2 + "px";
|
| 383 |
-
div.style.height = height + 4 + "px";
|
| 384 |
-
let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter");
|
| 385 |
-
if (gutterDiv === null) {
|
| 386 |
-
gutterDiv = window.document.createElement("div");
|
| 387 |
-
gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter");
|
| 388 |
-
gutterDiv.style.position = 'absolute';
|
| 389 |
-
const codeCell = window.document.getElementById(targetCell);
|
| 390 |
-
const gutter = codeCell.querySelector('.code-annotation-gutter');
|
| 391 |
-
gutter.appendChild(gutterDiv);
|
| 392 |
-
}
|
| 393 |
-
gutterDiv.style.top = top - 2 + "px";
|
| 394 |
-
gutterDiv.style.height = height + 4 + "px";
|
| 395 |
-
}
|
| 396 |
-
selectedAnnoteEl = annoteEl;
|
| 397 |
-
}
|
| 398 |
-
};
|
| 399 |
-
const unselectCodeLines = () => {
|
| 400 |
-
const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"];
|
| 401 |
-
elementsIds.forEach((elId) => {
|
| 402 |
-
const div = window.document.getElementById(elId);
|
| 403 |
-
if (div) {
|
| 404 |
-
div.remove();
|
| 405 |
-
}
|
| 406 |
-
});
|
| 407 |
-
selectedAnnoteEl = undefined;
|
| 408 |
-
};
|
| 409 |
-
// Attach click handler to the DT
|
| 410 |
-
const annoteDls = window.document.querySelectorAll('dt[data-target-cell]');
|
| 411 |
-
for (const annoteDlNode of annoteDls) {
|
| 412 |
-
annoteDlNode.addEventListener('click', (event) => {
|
| 413 |
-
const clickedEl = event.target;
|
| 414 |
-
if (clickedEl !== selectedAnnoteEl) {
|
| 415 |
-
unselectCodeLines();
|
| 416 |
-
const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active');
|
| 417 |
-
if (activeEl) {
|
| 418 |
-
activeEl.classList.remove('code-annotation-active');
|
| 419 |
-
}
|
| 420 |
-
selectCodeLines(clickedEl);
|
| 421 |
-
clickedEl.classList.add('code-annotation-active');
|
| 422 |
-
} else {
|
| 423 |
-
// Unselect the line
|
| 424 |
-
unselectCodeLines();
|
| 425 |
-
clickedEl.classList.remove('code-annotation-active');
|
| 426 |
-
}
|
| 427 |
-
});
|
| 428 |
-
}
|
| 429 |
-
const findCites = (el) => {
|
| 430 |
-
const parentEl = el.parentElement;
|
| 431 |
-
if (parentEl) {
|
| 432 |
-
const cites = parentEl.dataset.cites;
|
| 433 |
-
if (cites) {
|
| 434 |
-
return {
|
| 435 |
-
el,
|
| 436 |
-
cites: cites.split(' ')
|
| 437 |
-
};
|
| 438 |
-
} else {
|
| 439 |
-
return findCites(el.parentElement)
|
| 440 |
-
}
|
| 441 |
-
} else {
|
| 442 |
-
return undefined;
|
| 443 |
-
}
|
| 444 |
-
};
|
| 445 |
-
var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
|
| 446 |
-
for (var i=0; i<bibliorefs.length; i++) {
|
| 447 |
-
const ref = bibliorefs[i];
|
| 448 |
-
const citeInfo = findCites(ref);
|
| 449 |
-
if (citeInfo) {
|
| 450 |
-
tippyHover(citeInfo.el, function() {
|
| 451 |
-
var popup = window.document.createElement('div');
|
| 452 |
-
citeInfo.cites.forEach(function(cite) {
|
| 453 |
-
var citeDiv = window.document.createElement('div');
|
| 454 |
-
citeDiv.classList.add('hanging-indent');
|
| 455 |
-
citeDiv.classList.add('csl-entry');
|
| 456 |
-
var biblioDiv = window.document.getElementById('ref-' + cite);
|
| 457 |
-
if (biblioDiv) {
|
| 458 |
-
citeDiv.innerHTML = biblioDiv.innerHTML;
|
| 459 |
-
}
|
| 460 |
-
popup.appendChild(citeDiv);
|
| 461 |
-
});
|
| 462 |
-
return popup.innerHTML;
|
| 463 |
-
});
|
| 464 |
-
}
|
| 465 |
-
}
|
| 466 |
-
});
|
| 467 |
-
</script>
|
| 468 |
-
<nav class="page-navigation">
|
| 469 |
-
<div class="nav-page nav-page-previous">
|
| 470 |
-
<a href="./index.html" class="pagination-link">
|
| 471 |
-
<i class="bi bi-arrow-left-short"></i> <span class="nav-page-text">Preface</span>
|
| 472 |
-
</a>
|
| 473 |
-
</div>
|
| 474 |
-
<div class="nav-page nav-page-next">
|
| 475 |
-
<a href="./001-reducegrow.html" class="pagination-link">
|
| 476 |
-
<span class="nav-page-text"><span class="chapter-number">1</span> <span class="chapter-title">Beginner - Reduce but Grow</span></span> <i class="bi bi-arrow-right-short"></i>
|
| 477 |
-
</a>
|
| 478 |
-
</div>
|
| 479 |
-
</nav>
|
| 480 |
-
</div> <!-- /content -->
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
</body></html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
make_negative.html
DELETED
|
@@ -1,532 +0,0 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
|
| 3 |
-
|
| 4 |
-
<meta charset="utf-8">
|
| 5 |
-
<meta name="generator" content="quarto-1.3.433">
|
| 6 |
-
|
| 7 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
<title>Codewars Challenge 2024 Menggunakan R dan RStudio - 5 Return Negative</title>
|
| 11 |
-
<style>
|
| 12 |
-
code{white-space: pre-wrap;}
|
| 13 |
-
span.smallcaps{font-variant: small-caps;}
|
| 14 |
-
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
| 15 |
-
div.column{flex: auto; overflow-x: auto;}
|
| 16 |
-
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
| 17 |
-
ul.task-list{list-style: none;}
|
| 18 |
-
ul.task-list li input[type="checkbox"] {
|
| 19 |
-
width: 0.8em;
|
| 20 |
-
margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
|
| 21 |
-
vertical-align: middle;
|
| 22 |
-
}
|
| 23 |
-
/* CSS for syntax highlighting */
|
| 24 |
-
pre > code.sourceCode { white-space: pre; position: relative; }
|
| 25 |
-
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
|
| 26 |
-
pre > code.sourceCode > span:empty { height: 1.2em; }
|
| 27 |
-
.sourceCode { overflow: visible; }
|
| 28 |
-
code.sourceCode > span { color: inherit; text-decoration: inherit; }
|
| 29 |
-
div.sourceCode { margin: 1em 0; }
|
| 30 |
-
pre.sourceCode { margin: 0; }
|
| 31 |
-
@media screen {
|
| 32 |
-
div.sourceCode { overflow: auto; }
|
| 33 |
-
}
|
| 34 |
-
@media print {
|
| 35 |
-
pre > code.sourceCode { white-space: pre-wrap; }
|
| 36 |
-
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
|
| 37 |
-
}
|
| 38 |
-
pre.numberSource code
|
| 39 |
-
{ counter-reset: source-line 0; }
|
| 40 |
-
pre.numberSource code > span
|
| 41 |
-
{ position: relative; left: -4em; counter-increment: source-line; }
|
| 42 |
-
pre.numberSource code > span > a:first-child::before
|
| 43 |
-
{ content: counter(source-line);
|
| 44 |
-
position: relative; left: -1em; text-align: right; vertical-align: baseline;
|
| 45 |
-
border: none; display: inline-block;
|
| 46 |
-
-webkit-touch-callout: none; -webkit-user-select: none;
|
| 47 |
-
-khtml-user-select: none; -moz-user-select: none;
|
| 48 |
-
-ms-user-select: none; user-select: none;
|
| 49 |
-
padding: 0 4px; width: 4em;
|
| 50 |
-
}
|
| 51 |
-
pre.numberSource { margin-left: 3em; padding-left: 4px; }
|
| 52 |
-
div.sourceCode
|
| 53 |
-
{ }
|
| 54 |
-
@media screen {
|
| 55 |
-
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
|
| 56 |
-
}
|
| 57 |
-
</style>
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
<script src="site_libs/quarto-nav/quarto-nav.js"></script>
|
| 61 |
-
<script src="site_libs/quarto-nav/headroom.min.js"></script>
|
| 62 |
-
<script src="site_libs/clipboard/clipboard.min.js"></script>
|
| 63 |
-
<script src="site_libs/quarto-search/autocomplete.umd.js"></script>
|
| 64 |
-
<script src="site_libs/quarto-search/fuse.min.js"></script>
|
| 65 |
-
<script src="site_libs/quarto-search/quarto-search.js"></script>
|
| 66 |
-
<meta name="quarto:offset" content="./">
|
| 67 |
-
<link href="./positive_sum.html" rel="next">
|
| 68 |
-
<link href="./reducegrow.html" rel="prev">
|
| 69 |
-
<script src="site_libs/quarto-html/quarto.js"></script>
|
| 70 |
-
<script src="site_libs/quarto-html/popper.min.js"></script>
|
| 71 |
-
<script src="site_libs/quarto-html/tippy.umd.min.js"></script>
|
| 72 |
-
<script src="site_libs/quarto-html/anchor.min.js"></script>
|
| 73 |
-
<link href="site_libs/quarto-html/tippy.css" rel="stylesheet">
|
| 74 |
-
<link href="site_libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
|
| 75 |
-
<script src="site_libs/bootstrap/bootstrap.min.js"></script>
|
| 76 |
-
<link href="site_libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
|
| 77 |
-
<link href="site_libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">
|
| 78 |
-
<link href="site_libs/quarto-contrib/badge/badge.css" rel="stylesheet">
|
| 79 |
-
<script id="quarto-search-options" type="application/json">{
|
| 80 |
-
"location": "sidebar",
|
| 81 |
-
"copy-button": false,
|
| 82 |
-
"collapse-after": 3,
|
| 83 |
-
"panel-placement": "start",
|
| 84 |
-
"type": "textbox",
|
| 85 |
-
"limit": 20,
|
| 86 |
-
"language": {
|
| 87 |
-
"search-no-results-text": "No results",
|
| 88 |
-
"search-matching-documents-text": "matching documents",
|
| 89 |
-
"search-copy-link-title": "Copy link to search",
|
| 90 |
-
"search-hide-matches-text": "Hide additional matches",
|
| 91 |
-
"search-more-match-text": "more match in this document",
|
| 92 |
-
"search-more-matches-text": "more matches in this document",
|
| 93 |
-
"search-clear-button-title": "Clear",
|
| 94 |
-
"search-detached-cancel-button-title": "Cancel",
|
| 95 |
-
"search-submit-button-title": "Submit",
|
| 96 |
-
"search-label": "Search"
|
| 97 |
-
}
|
| 98 |
-
}</script>
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
</head>
|
| 102 |
-
|
| 103 |
-
<body class="nav-sidebar floating">
|
| 104 |
-
|
| 105 |
-
<div id="quarto-search-results"></div>
|
| 106 |
-
<header id="quarto-header" class="headroom fixed-top">
|
| 107 |
-
<nav class="quarto-secondary-nav">
|
| 108 |
-
<div class="container-fluid d-flex">
|
| 109 |
-
<button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
|
| 110 |
-
<i class="bi bi-layout-text-sidebar-reverse"></i>
|
| 111 |
-
</button>
|
| 112 |
-
<nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="./make_negative.html"><span class="chapter-number">5</span> <span class="chapter-title">Return Negative</span></a></li></ol></nav>
|
| 113 |
-
<a class="flex-grow-1" role="button" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
|
| 114 |
-
</a>
|
| 115 |
-
<button type="button" class="btn quarto-search-button" aria-label="" onclick="window.quartoOpenSearch();">
|
| 116 |
-
<i class="bi bi-search"></i>
|
| 117 |
-
</button>
|
| 118 |
-
</div>
|
| 119 |
-
</nav>
|
| 120 |
-
</header>
|
| 121 |
-
<!-- content -->
|
| 122 |
-
<div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article">
|
| 123 |
-
<!-- sidebar -->
|
| 124 |
-
<nav id="quarto-sidebar" class="sidebar collapse collapse-horizontal sidebar-navigation floating overflow-auto">
|
| 125 |
-
<div class="pt-lg-2 mt-2 text-left sidebar-header">
|
| 126 |
-
<div class="sidebar-title mb-0 py-0">
|
| 127 |
-
<a href="./">Codewars Challenge 2024 Menggunakan R dan RStudio</a>
|
| 128 |
-
</div>
|
| 129 |
-
</div>
|
| 130 |
-
<div class="mt-2 flex-shrink-0 align-items-center">
|
| 131 |
-
<div class="sidebar-search">
|
| 132 |
-
<div id="quarto-search" class="" title="Search"></div>
|
| 133 |
-
</div>
|
| 134 |
-
</div>
|
| 135 |
-
<div class="sidebar-menu-container">
|
| 136 |
-
<ul class="list-unstyled mt-1">
|
| 137 |
-
<li class="sidebar-item">
|
| 138 |
-
<div class="sidebar-item-container">
|
| 139 |
-
<a href="./index.html" class="sidebar-item-text sidebar-link">
|
| 140 |
-
<span class="menu-text">Pengantar</span></a>
|
| 141 |
-
</div>
|
| 142 |
-
</li>
|
| 143 |
-
<li class="sidebar-item">
|
| 144 |
-
<div class="sidebar-item-container">
|
| 145 |
-
<a href="./evenodd.html" class="sidebar-item-text sidebar-link">
|
| 146 |
-
<span class="menu-text"><span class="chapter-number">1</span> <span class="chapter-title">Even or Odd</span></span></a>
|
| 147 |
-
</div>
|
| 148 |
-
</li>
|
| 149 |
-
<li class="sidebar-item">
|
| 150 |
-
<div class="sidebar-item-container">
|
| 151 |
-
<a href="./multiply.html" class="sidebar-item-text sidebar-link">
|
| 152 |
-
<span class="menu-text"><span class="chapter-number">2</span> <span class="chapter-title">Multiply</span></span></a>
|
| 153 |
-
</div>
|
| 154 |
-
</li>
|
| 155 |
-
<li class="sidebar-item">
|
| 156 |
-
<div class="sidebar-item-container">
|
| 157 |
-
<a href="./countsheep.html" class="sidebar-item-text sidebar-link">
|
| 158 |
-
<span class="menu-text"><span class="chapter-number">3</span> <span class="chapter-title">If you can’t sleep, just count sheep!!</span></span></a>
|
| 159 |
-
</div>
|
| 160 |
-
</li>
|
| 161 |
-
<li class="sidebar-item">
|
| 162 |
-
<div class="sidebar-item-container">
|
| 163 |
-
<a href="./reducegrow.html" class="sidebar-item-text sidebar-link">
|
| 164 |
-
<span class="menu-text"><span class="chapter-number">4</span> <span class="chapter-title">Beginner - Reduce but Grow</span></span></a>
|
| 165 |
-
</div>
|
| 166 |
-
</li>
|
| 167 |
-
<li class="sidebar-item">
|
| 168 |
-
<div class="sidebar-item-container">
|
| 169 |
-
<a href="./make_negative.html" class="sidebar-item-text sidebar-link active">
|
| 170 |
-
<span class="menu-text"><span class="chapter-number">5</span> <span class="chapter-title">Return Negative</span></span></a>
|
| 171 |
-
</div>
|
| 172 |
-
</li>
|
| 173 |
-
<li class="sidebar-item">
|
| 174 |
-
<div class="sidebar-item-container">
|
| 175 |
-
<a href="./positive_sum.html" class="sidebar-item-text sidebar-link">
|
| 176 |
-
<span class="menu-text"><span class="chapter-number">6</span> <span class="chapter-title">Sum of positive</span></span></a>
|
| 177 |
-
</div>
|
| 178 |
-
</li>
|
| 179 |
-
<li class="sidebar-item">
|
| 180 |
-
<div class="sidebar-item-container">
|
| 181 |
-
<a href="./references.html" class="sidebar-item-text sidebar-link">
|
| 182 |
-
<span class="menu-text">References</span></a>
|
| 183 |
-
</div>
|
| 184 |
-
</li>
|
| 185 |
-
</ul>
|
| 186 |
-
</div>
|
| 187 |
-
</nav>
|
| 188 |
-
<div id="quarto-sidebar-glass" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass"></div>
|
| 189 |
-
<!-- margin-sidebar -->
|
| 190 |
-
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
|
| 191 |
-
<nav id="TOC" role="doc-toc" class="toc-active">
|
| 192 |
-
<h2 id="toc-title">Table of contents</h2>
|
| 193 |
-
|
| 194 |
-
<ul>
|
| 195 |
-
<li><a href="#instruction" id="toc-instruction" class="nav-link active" data-scroll-target="#instruction"><span class="header-section-number">5.1</span> Instruction</a></li>
|
| 196 |
-
<li><a href="#youtube-video" id="toc-youtube-video" class="nav-link" data-scroll-target="#youtube-video"><span class="header-section-number">5.2</span> YouTube Video</a></li>
|
| 197 |
-
<li><a href="#solution-code" id="toc-solution-code" class="nav-link" data-scroll-target="#solution-code"><span class="header-section-number">5.3</span> Solution Code</a></li>
|
| 198 |
-
<li><a href="#test" id="toc-test" class="nav-link" data-scroll-target="#test"><span class="header-section-number">5.4</span> Test</a></li>
|
| 199 |
-
<li><a href="#supported-by" id="toc-supported-by" class="nav-link" data-scroll-target="#supported-by"><span class="header-section-number">5.5</span> Supported by</a></li>
|
| 200 |
-
</ul>
|
| 201 |
-
</nav>
|
| 202 |
-
</div>
|
| 203 |
-
<!-- main -->
|
| 204 |
-
<main class="content" id="quarto-document-content">
|
| 205 |
-
|
| 206 |
-
<header id="title-block-header" class="quarto-title-block default">
|
| 207 |
-
<div class="quarto-title">
|
| 208 |
-
<h1 class="title"><span class="chapter-number">5</span> <span class="chapter-title">Return Negative</span></h1>
|
| 209 |
-
</div>
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
<div class="quarto-title-meta">
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
</div>
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
</header>
|
| 222 |
-
|
| 223 |
-
<p>Tantangan #5/366 - 18 Feb 2024</p>
|
| 224 |
-
<p><a href="https://www.codewars.com/kata/55685cd7ad70877c23000102/train/r" class="uri">https://www.codewars.com/kata/55685cd7ad70877c23000102/train/r</a></p>
|
| 225 |
-
<p><span class="badge rounded-pill quarto-badge " style="background-color: grey;">8kyu</span> Return Negative</p>
|
| 226 |
-
<section id="instruction" class="level2" data-number="5.1">
|
| 227 |
-
<h2 data-number="5.1" class="anchored" data-anchor-id="instruction"><span class="header-section-number">5.1</span> Instruction</h2>
|
| 228 |
-
<p>In this simple assignment you are given a number and have to make it negative. But maybe the number is already negative?</p>
|
| 229 |
-
<p>Examples</p>
|
| 230 |
-
<pre><code>make_negative(1); # return -1
|
| 231 |
-
make_negative(-5); # return -5
|
| 232 |
-
make_negative(0); # return 0</code></pre>
|
| 233 |
-
<p><strong>Notes</strong><br>
|
| 234 |
-
The number can be negative already, in which case no change is required. Zero (0) is not checked for any specific sign. Negative zeros make no mathematical sense.</p>
|
| 235 |
-
</section>
|
| 236 |
-
<section id="youtube-video" class="level2" data-number="5.2">
|
| 237 |
-
<h2 data-number="5.2" class="anchored" data-anchor-id="youtube-video"><span class="header-section-number">5.2</span> YouTube Video</h2>
|
| 238 |
-
<div class="quarto-video ratio ratio-16x9"><iframe data-external="1" src="https://www.youtube.com/embed/L8aczEhqymk?si=DSx84acpNvbkucrK" title="" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe></div>
|
| 239 |
-
</section>
|
| 240 |
-
<section id="solution-code" class="level2" data-number="5.3">
|
| 241 |
-
<h2 data-number="5.3" class="anchored" data-anchor-id="solution-code"><span class="header-section-number">5.3</span> Solution Code</h2>
|
| 242 |
-
<p>Solusi bar-bar</p>
|
| 243 |
-
<div class="cell">
|
| 244 |
-
<div class="sourceCode cell-code" id="cb2"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>make_negative <span class="ot"><-</span> <span class="cf">function</span>(num){</span>
|
| 245 |
-
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">ifelse</span>(num <span class="sc"><=</span> <span class="dv">0</span>, num, <span class="sc">-</span><span class="dv">1</span><span class="sc">*</span>num)</span>
|
| 246 |
-
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 247 |
-
</div>
|
| 248 |
-
<p>Solusi simple</p>
|
| 249 |
-
<div class="cell">
|
| 250 |
-
<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a>make_negative <span class="ot"><-</span> <span class="cf">function</span>(num)<span class="sc">-</span><span class="fu">abs</span>(num)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 251 |
-
</div>
|
| 252 |
-
</section>
|
| 253 |
-
<section id="test" class="level2" data-number="5.4">
|
| 254 |
-
<h2 data-number="5.4" class="anchored" data-anchor-id="test"><span class="header-section-number">5.4</span> Test</h2>
|
| 255 |
-
<div class="cell">
|
| 256 |
-
<div class="sourceCode cell-code" id="cb4"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(testthat)</span>
|
| 257 |
-
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a></span>
|
| 258 |
-
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a><span class="fu">test_that</span>(<span class="st">'Basic tests'</span>, {</span>
|
| 259 |
-
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">expect_equal</span>(<span class="fu">make_negative</span>(<span class="dv">42</span>), <span class="sc">-</span><span class="dv">42</span>)</span>
|
| 260 |
-
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">expect_equal</span>(<span class="fu">make_negative</span>(<span class="sc">-</span><span class="dv">9</span>), <span class="sc">-</span><span class="dv">9</span>)</span>
|
| 261 |
-
<span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">expect_equal</span>(<span class="fu">make_negative</span>(<span class="dv">0</span>), <span class="dv">0</span>)</span>
|
| 262 |
-
<span id="cb4-7"><a href="#cb4-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">expect_equal</span>(<span class="fu">make_negative</span>(<span class="dv">1</span>), <span class="sc">-</span><span class="dv">1</span>)</span>
|
| 263 |
-
<span id="cb4-8"><a href="#cb4-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">expect_equal</span>(<span class="fu">make_negative</span>(<span class="sc">-</span><span class="dv">1</span>), <span class="sc">-</span><span class="dv">1</span>)</span>
|
| 264 |
-
<span id="cb4-9"><a href="#cb4-9" aria-hidden="true" tabindex="-1"></a>})</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 265 |
-
<div class="cell-output cell-output-stdout">
|
| 266 |
-
<pre><code>Test passed 😀</code></pre>
|
| 267 |
-
</div>
|
| 268 |
-
</div>
|
| 269 |
-
</section>
|
| 270 |
-
<section id="supported-by" class="level2" data-number="5.5">
|
| 271 |
-
<h2 data-number="5.5" class="anchored" data-anchor-id="supported-by"><span class="header-section-number">5.5</span> Supported by</h2>
|
| 272 |
-
<div class="quarto-figure quarto-figure-center">
|
| 273 |
-
<figure class="figure">
|
| 274 |
-
<p><a href="https://www.starcore.co"><img src="new_starcore_logo.png" class="img-fluid figure-img"></a></p>
|
| 275 |
-
<figcaption class="figure-caption">StarCore Analytics</figcaption>
|
| 276 |
-
</figure>
|
| 277 |
-
</div>
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
</section>
|
| 281 |
-
|
| 282 |
-
</main> <!-- /main -->
|
| 283 |
-
<script id="quarto-html-after-body" type="application/javascript">
|
| 284 |
-
window.document.addEventListener("DOMContentLoaded", function (event) {
|
| 285 |
-
const toggleBodyColorMode = (bsSheetEl) => {
|
| 286 |
-
const mode = bsSheetEl.getAttribute("data-mode");
|
| 287 |
-
const bodyEl = window.document.querySelector("body");
|
| 288 |
-
if (mode === "dark") {
|
| 289 |
-
bodyEl.classList.add("quarto-dark");
|
| 290 |
-
bodyEl.classList.remove("quarto-light");
|
| 291 |
-
} else {
|
| 292 |
-
bodyEl.classList.add("quarto-light");
|
| 293 |
-
bodyEl.classList.remove("quarto-dark");
|
| 294 |
-
}
|
| 295 |
-
}
|
| 296 |
-
const toggleBodyColorPrimary = () => {
|
| 297 |
-
const bsSheetEl = window.document.querySelector("link#quarto-bootstrap");
|
| 298 |
-
if (bsSheetEl) {
|
| 299 |
-
toggleBodyColorMode(bsSheetEl);
|
| 300 |
-
}
|
| 301 |
-
}
|
| 302 |
-
toggleBodyColorPrimary();
|
| 303 |
-
const icon = "";
|
| 304 |
-
const anchorJS = new window.AnchorJS();
|
| 305 |
-
anchorJS.options = {
|
| 306 |
-
placement: 'right',
|
| 307 |
-
icon: icon
|
| 308 |
-
};
|
| 309 |
-
anchorJS.add('.anchored');
|
| 310 |
-
const isCodeAnnotation = (el) => {
|
| 311 |
-
for (const clz of el.classList) {
|
| 312 |
-
if (clz.startsWith('code-annotation-')) {
|
| 313 |
-
return true;
|
| 314 |
-
}
|
| 315 |
-
}
|
| 316 |
-
return false;
|
| 317 |
-
}
|
| 318 |
-
const clipboard = new window.ClipboardJS('.code-copy-button', {
|
| 319 |
-
text: function(trigger) {
|
| 320 |
-
const codeEl = trigger.previousElementSibling.cloneNode(true);
|
| 321 |
-
for (const childEl of codeEl.children) {
|
| 322 |
-
if (isCodeAnnotation(childEl)) {
|
| 323 |
-
childEl.remove();
|
| 324 |
-
}
|
| 325 |
-
}
|
| 326 |
-
return codeEl.innerText;
|
| 327 |
-
}
|
| 328 |
-
});
|
| 329 |
-
clipboard.on('success', function(e) {
|
| 330 |
-
// button target
|
| 331 |
-
const button = e.trigger;
|
| 332 |
-
// don't keep focus
|
| 333 |
-
button.blur();
|
| 334 |
-
// flash "checked"
|
| 335 |
-
button.classList.add('code-copy-button-checked');
|
| 336 |
-
var currentTitle = button.getAttribute("title");
|
| 337 |
-
button.setAttribute("title", "Copied!");
|
| 338 |
-
let tooltip;
|
| 339 |
-
if (window.bootstrap) {
|
| 340 |
-
button.setAttribute("data-bs-toggle", "tooltip");
|
| 341 |
-
button.setAttribute("data-bs-placement", "left");
|
| 342 |
-
button.setAttribute("data-bs-title", "Copied!");
|
| 343 |
-
tooltip = new bootstrap.Tooltip(button,
|
| 344 |
-
{ trigger: "manual",
|
| 345 |
-
customClass: "code-copy-button-tooltip",
|
| 346 |
-
offset: [0, -8]});
|
| 347 |
-
tooltip.show();
|
| 348 |
-
}
|
| 349 |
-
setTimeout(function() {
|
| 350 |
-
if (tooltip) {
|
| 351 |
-
tooltip.hide();
|
| 352 |
-
button.removeAttribute("data-bs-title");
|
| 353 |
-
button.removeAttribute("data-bs-toggle");
|
| 354 |
-
button.removeAttribute("data-bs-placement");
|
| 355 |
-
}
|
| 356 |
-
button.setAttribute("title", currentTitle);
|
| 357 |
-
button.classList.remove('code-copy-button-checked');
|
| 358 |
-
}, 1000);
|
| 359 |
-
// clear code selection
|
| 360 |
-
e.clearSelection();
|
| 361 |
-
});
|
| 362 |
-
function tippyHover(el, contentFn) {
|
| 363 |
-
const config = {
|
| 364 |
-
allowHTML: true,
|
| 365 |
-
content: contentFn,
|
| 366 |
-
maxWidth: 500,
|
| 367 |
-
delay: 100,
|
| 368 |
-
arrow: false,
|
| 369 |
-
appendTo: function(el) {
|
| 370 |
-
return el.parentElement;
|
| 371 |
-
},
|
| 372 |
-
interactive: true,
|
| 373 |
-
interactiveBorder: 10,
|
| 374 |
-
theme: 'quarto',
|
| 375 |
-
placement: 'bottom-start'
|
| 376 |
-
};
|
| 377 |
-
window.tippy(el, config);
|
| 378 |
-
}
|
| 379 |
-
const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
|
| 380 |
-
for (var i=0; i<noterefs.length; i++) {
|
| 381 |
-
const ref = noterefs[i];
|
| 382 |
-
tippyHover(ref, function() {
|
| 383 |
-
// use id or data attribute instead here
|
| 384 |
-
let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
|
| 385 |
-
try { href = new URL(href).hash; } catch {}
|
| 386 |
-
const id = href.replace(/^#\/?/, "");
|
| 387 |
-
const note = window.document.getElementById(id);
|
| 388 |
-
return note.innerHTML;
|
| 389 |
-
});
|
| 390 |
-
}
|
| 391 |
-
let selectedAnnoteEl;
|
| 392 |
-
const selectorForAnnotation = ( cell, annotation) => {
|
| 393 |
-
let cellAttr = 'data-code-cell="' + cell + '"';
|
| 394 |
-
let lineAttr = 'data-code-annotation="' + annotation + '"';
|
| 395 |
-
const selector = 'span[' + cellAttr + '][' + lineAttr + ']';
|
| 396 |
-
return selector;
|
| 397 |
-
}
|
| 398 |
-
const selectCodeLines = (annoteEl) => {
|
| 399 |
-
const doc = window.document;
|
| 400 |
-
const targetCell = annoteEl.getAttribute("data-target-cell");
|
| 401 |
-
const targetAnnotation = annoteEl.getAttribute("data-target-annotation");
|
| 402 |
-
const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation));
|
| 403 |
-
const lines = annoteSpan.getAttribute("data-code-lines").split(",");
|
| 404 |
-
const lineIds = lines.map((line) => {
|
| 405 |
-
return targetCell + "-" + line;
|
| 406 |
-
})
|
| 407 |
-
let top = null;
|
| 408 |
-
let height = null;
|
| 409 |
-
let parent = null;
|
| 410 |
-
if (lineIds.length > 0) {
|
| 411 |
-
//compute the position of the single el (top and bottom and make a div)
|
| 412 |
-
const el = window.document.getElementById(lineIds[0]);
|
| 413 |
-
top = el.offsetTop;
|
| 414 |
-
height = el.offsetHeight;
|
| 415 |
-
parent = el.parentElement.parentElement;
|
| 416 |
-
if (lineIds.length > 1) {
|
| 417 |
-
const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]);
|
| 418 |
-
const bottom = lastEl.offsetTop + lastEl.offsetHeight;
|
| 419 |
-
height = bottom - top;
|
| 420 |
-
}
|
| 421 |
-
if (top !== null && height !== null && parent !== null) {
|
| 422 |
-
// cook up a div (if necessary) and position it
|
| 423 |
-
let div = window.document.getElementById("code-annotation-line-highlight");
|
| 424 |
-
if (div === null) {
|
| 425 |
-
div = window.document.createElement("div");
|
| 426 |
-
div.setAttribute("id", "code-annotation-line-highlight");
|
| 427 |
-
div.style.position = 'absolute';
|
| 428 |
-
parent.appendChild(div);
|
| 429 |
-
}
|
| 430 |
-
div.style.top = top - 2 + "px";
|
| 431 |
-
div.style.height = height + 4 + "px";
|
| 432 |
-
let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter");
|
| 433 |
-
if (gutterDiv === null) {
|
| 434 |
-
gutterDiv = window.document.createElement("div");
|
| 435 |
-
gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter");
|
| 436 |
-
gutterDiv.style.position = 'absolute';
|
| 437 |
-
const codeCell = window.document.getElementById(targetCell);
|
| 438 |
-
const gutter = codeCell.querySelector('.code-annotation-gutter');
|
| 439 |
-
gutter.appendChild(gutterDiv);
|
| 440 |
-
}
|
| 441 |
-
gutterDiv.style.top = top - 2 + "px";
|
| 442 |
-
gutterDiv.style.height = height + 4 + "px";
|
| 443 |
-
}
|
| 444 |
-
selectedAnnoteEl = annoteEl;
|
| 445 |
-
}
|
| 446 |
-
};
|
| 447 |
-
const unselectCodeLines = () => {
|
| 448 |
-
const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"];
|
| 449 |
-
elementsIds.forEach((elId) => {
|
| 450 |
-
const div = window.document.getElementById(elId);
|
| 451 |
-
if (div) {
|
| 452 |
-
div.remove();
|
| 453 |
-
}
|
| 454 |
-
});
|
| 455 |
-
selectedAnnoteEl = undefined;
|
| 456 |
-
};
|
| 457 |
-
// Attach click handler to the DT
|
| 458 |
-
const annoteDls = window.document.querySelectorAll('dt[data-target-cell]');
|
| 459 |
-
for (const annoteDlNode of annoteDls) {
|
| 460 |
-
annoteDlNode.addEventListener('click', (event) => {
|
| 461 |
-
const clickedEl = event.target;
|
| 462 |
-
if (clickedEl !== selectedAnnoteEl) {
|
| 463 |
-
unselectCodeLines();
|
| 464 |
-
const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active');
|
| 465 |
-
if (activeEl) {
|
| 466 |
-
activeEl.classList.remove('code-annotation-active');
|
| 467 |
-
}
|
| 468 |
-
selectCodeLines(clickedEl);
|
| 469 |
-
clickedEl.classList.add('code-annotation-active');
|
| 470 |
-
} else {
|
| 471 |
-
// Unselect the line
|
| 472 |
-
unselectCodeLines();
|
| 473 |
-
clickedEl.classList.remove('code-annotation-active');
|
| 474 |
-
}
|
| 475 |
-
});
|
| 476 |
-
}
|
| 477 |
-
const findCites = (el) => {
|
| 478 |
-
const parentEl = el.parentElement;
|
| 479 |
-
if (parentEl) {
|
| 480 |
-
const cites = parentEl.dataset.cites;
|
| 481 |
-
if (cites) {
|
| 482 |
-
return {
|
| 483 |
-
el,
|
| 484 |
-
cites: cites.split(' ')
|
| 485 |
-
};
|
| 486 |
-
} else {
|
| 487 |
-
return findCites(el.parentElement)
|
| 488 |
-
}
|
| 489 |
-
} else {
|
| 490 |
-
return undefined;
|
| 491 |
-
}
|
| 492 |
-
};
|
| 493 |
-
var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
|
| 494 |
-
for (var i=0; i<bibliorefs.length; i++) {
|
| 495 |
-
const ref = bibliorefs[i];
|
| 496 |
-
const citeInfo = findCites(ref);
|
| 497 |
-
if (citeInfo) {
|
| 498 |
-
tippyHover(citeInfo.el, function() {
|
| 499 |
-
var popup = window.document.createElement('div');
|
| 500 |
-
citeInfo.cites.forEach(function(cite) {
|
| 501 |
-
var citeDiv = window.document.createElement('div');
|
| 502 |
-
citeDiv.classList.add('hanging-indent');
|
| 503 |
-
citeDiv.classList.add('csl-entry');
|
| 504 |
-
var biblioDiv = window.document.getElementById('ref-' + cite);
|
| 505 |
-
if (biblioDiv) {
|
| 506 |
-
citeDiv.innerHTML = biblioDiv.innerHTML;
|
| 507 |
-
}
|
| 508 |
-
popup.appendChild(citeDiv);
|
| 509 |
-
});
|
| 510 |
-
return popup.innerHTML;
|
| 511 |
-
});
|
| 512 |
-
}
|
| 513 |
-
}
|
| 514 |
-
});
|
| 515 |
-
</script>
|
| 516 |
-
<nav class="page-navigation">
|
| 517 |
-
<div class="nav-page nav-page-previous">
|
| 518 |
-
<a href="./reducegrow.html" class="pagination-link">
|
| 519 |
-
<i class="bi bi-arrow-left-short"></i> <span class="nav-page-text"><span class="chapter-number">4</span> <span class="chapter-title">Beginner - Reduce but Grow</span></span>
|
| 520 |
-
</a>
|
| 521 |
-
</div>
|
| 522 |
-
<div class="nav-page nav-page-next">
|
| 523 |
-
<a href="./positive_sum.html" class="pagination-link">
|
| 524 |
-
<span class="nav-page-text"><span class="chapter-number">6</span> <span class="chapter-title">Sum of positive</span></span> <i class="bi bi-arrow-right-short"></i>
|
| 525 |
-
</a>
|
| 526 |
-
</div>
|
| 527 |
-
</nav>
|
| 528 |
-
</div> <!-- /content -->
|
| 529 |
-
|
| 530 |
-
|
| 531 |
-
|
| 532 |
-
</body></html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
multiply.html
DELETED
|
@@ -1,532 +0,0 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
|
| 3 |
-
|
| 4 |
-
<meta charset="utf-8">
|
| 5 |
-
<meta name="generator" content="quarto-1.3.433">
|
| 6 |
-
|
| 7 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
<title>Codewars Challenge 2024 Menggunakan R dan RStudio - 2 Multiply</title>
|
| 11 |
-
<style>
|
| 12 |
-
code{white-space: pre-wrap;}
|
| 13 |
-
span.smallcaps{font-variant: small-caps;}
|
| 14 |
-
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
| 15 |
-
div.column{flex: auto; overflow-x: auto;}
|
| 16 |
-
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
| 17 |
-
ul.task-list{list-style: none;}
|
| 18 |
-
ul.task-list li input[type="checkbox"] {
|
| 19 |
-
width: 0.8em;
|
| 20 |
-
margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
|
| 21 |
-
vertical-align: middle;
|
| 22 |
-
}
|
| 23 |
-
/* CSS for syntax highlighting */
|
| 24 |
-
pre > code.sourceCode { white-space: pre; position: relative; }
|
| 25 |
-
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
|
| 26 |
-
pre > code.sourceCode > span:empty { height: 1.2em; }
|
| 27 |
-
.sourceCode { overflow: visible; }
|
| 28 |
-
code.sourceCode > span { color: inherit; text-decoration: inherit; }
|
| 29 |
-
div.sourceCode { margin: 1em 0; }
|
| 30 |
-
pre.sourceCode { margin: 0; }
|
| 31 |
-
@media screen {
|
| 32 |
-
div.sourceCode { overflow: auto; }
|
| 33 |
-
}
|
| 34 |
-
@media print {
|
| 35 |
-
pre > code.sourceCode { white-space: pre-wrap; }
|
| 36 |
-
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
|
| 37 |
-
}
|
| 38 |
-
pre.numberSource code
|
| 39 |
-
{ counter-reset: source-line 0; }
|
| 40 |
-
pre.numberSource code > span
|
| 41 |
-
{ position: relative; left: -4em; counter-increment: source-line; }
|
| 42 |
-
pre.numberSource code > span > a:first-child::before
|
| 43 |
-
{ content: counter(source-line);
|
| 44 |
-
position: relative; left: -1em; text-align: right; vertical-align: baseline;
|
| 45 |
-
border: none; display: inline-block;
|
| 46 |
-
-webkit-touch-callout: none; -webkit-user-select: none;
|
| 47 |
-
-khtml-user-select: none; -moz-user-select: none;
|
| 48 |
-
-ms-user-select: none; user-select: none;
|
| 49 |
-
padding: 0 4px; width: 4em;
|
| 50 |
-
}
|
| 51 |
-
pre.numberSource { margin-left: 3em; padding-left: 4px; }
|
| 52 |
-
div.sourceCode
|
| 53 |
-
{ }
|
| 54 |
-
@media screen {
|
| 55 |
-
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
|
| 56 |
-
}
|
| 57 |
-
</style>
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
<script src="site_libs/quarto-nav/quarto-nav.js"></script>
|
| 61 |
-
<script src="site_libs/quarto-nav/headroom.min.js"></script>
|
| 62 |
-
<script src="site_libs/clipboard/clipboard.min.js"></script>
|
| 63 |
-
<script src="site_libs/quarto-search/autocomplete.umd.js"></script>
|
| 64 |
-
<script src="site_libs/quarto-search/fuse.min.js"></script>
|
| 65 |
-
<script src="site_libs/quarto-search/quarto-search.js"></script>
|
| 66 |
-
<meta name="quarto:offset" content="./">
|
| 67 |
-
<link href="./countsheep.html" rel="next">
|
| 68 |
-
<link href="./evenodd.html" rel="prev">
|
| 69 |
-
<script src="site_libs/quarto-html/quarto.js"></script>
|
| 70 |
-
<script src="site_libs/quarto-html/popper.min.js"></script>
|
| 71 |
-
<script src="site_libs/quarto-html/tippy.umd.min.js"></script>
|
| 72 |
-
<script src="site_libs/quarto-html/anchor.min.js"></script>
|
| 73 |
-
<link href="site_libs/quarto-html/tippy.css" rel="stylesheet">
|
| 74 |
-
<link href="site_libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
|
| 75 |
-
<script src="site_libs/bootstrap/bootstrap.min.js"></script>
|
| 76 |
-
<link href="site_libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
|
| 77 |
-
<link href="site_libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">
|
| 78 |
-
<link href="site_libs/quarto-contrib/badge/badge.css" rel="stylesheet">
|
| 79 |
-
<script id="quarto-search-options" type="application/json">{
|
| 80 |
-
"location": "sidebar",
|
| 81 |
-
"copy-button": false,
|
| 82 |
-
"collapse-after": 3,
|
| 83 |
-
"panel-placement": "start",
|
| 84 |
-
"type": "textbox",
|
| 85 |
-
"limit": 20,
|
| 86 |
-
"language": {
|
| 87 |
-
"search-no-results-text": "No results",
|
| 88 |
-
"search-matching-documents-text": "matching documents",
|
| 89 |
-
"search-copy-link-title": "Copy link to search",
|
| 90 |
-
"search-hide-matches-text": "Hide additional matches",
|
| 91 |
-
"search-more-match-text": "more match in this document",
|
| 92 |
-
"search-more-matches-text": "more matches in this document",
|
| 93 |
-
"search-clear-button-title": "Clear",
|
| 94 |
-
"search-detached-cancel-button-title": "Cancel",
|
| 95 |
-
"search-submit-button-title": "Submit",
|
| 96 |
-
"search-label": "Search"
|
| 97 |
-
}
|
| 98 |
-
}</script>
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
</head>
|
| 102 |
-
|
| 103 |
-
<body class="nav-sidebar floating">
|
| 104 |
-
|
| 105 |
-
<div id="quarto-search-results"></div>
|
| 106 |
-
<header id="quarto-header" class="headroom fixed-top">
|
| 107 |
-
<nav class="quarto-secondary-nav">
|
| 108 |
-
<div class="container-fluid d-flex">
|
| 109 |
-
<button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
|
| 110 |
-
<i class="bi bi-layout-text-sidebar-reverse"></i>
|
| 111 |
-
</button>
|
| 112 |
-
<nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="./multiply.html"><span class="chapter-number">2</span> <span class="chapter-title">Multiply</span></a></li></ol></nav>
|
| 113 |
-
<a class="flex-grow-1" role="button" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
|
| 114 |
-
</a>
|
| 115 |
-
<button type="button" class="btn quarto-search-button" aria-label="" onclick="window.quartoOpenSearch();">
|
| 116 |
-
<i class="bi bi-search"></i>
|
| 117 |
-
</button>
|
| 118 |
-
</div>
|
| 119 |
-
</nav>
|
| 120 |
-
</header>
|
| 121 |
-
<!-- content -->
|
| 122 |
-
<div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article">
|
| 123 |
-
<!-- sidebar -->
|
| 124 |
-
<nav id="quarto-sidebar" class="sidebar collapse collapse-horizontal sidebar-navigation floating overflow-auto">
|
| 125 |
-
<div class="pt-lg-2 mt-2 text-left sidebar-header">
|
| 126 |
-
<div class="sidebar-title mb-0 py-0">
|
| 127 |
-
<a href="./">Codewars Challenge 2024 Menggunakan R dan RStudio</a>
|
| 128 |
-
</div>
|
| 129 |
-
</div>
|
| 130 |
-
<div class="mt-2 flex-shrink-0 align-items-center">
|
| 131 |
-
<div class="sidebar-search">
|
| 132 |
-
<div id="quarto-search" class="" title="Search"></div>
|
| 133 |
-
</div>
|
| 134 |
-
</div>
|
| 135 |
-
<div class="sidebar-menu-container">
|
| 136 |
-
<ul class="list-unstyled mt-1">
|
| 137 |
-
<li class="sidebar-item">
|
| 138 |
-
<div class="sidebar-item-container">
|
| 139 |
-
<a href="./index.html" class="sidebar-item-text sidebar-link">
|
| 140 |
-
<span class="menu-text">Pengantar</span></a>
|
| 141 |
-
</div>
|
| 142 |
-
</li>
|
| 143 |
-
<li class="sidebar-item">
|
| 144 |
-
<div class="sidebar-item-container">
|
| 145 |
-
<a href="./evenodd.html" class="sidebar-item-text sidebar-link">
|
| 146 |
-
<span class="menu-text"><span class="chapter-number">1</span> <span class="chapter-title">Even or Odd</span></span></a>
|
| 147 |
-
</div>
|
| 148 |
-
</li>
|
| 149 |
-
<li class="sidebar-item">
|
| 150 |
-
<div class="sidebar-item-container">
|
| 151 |
-
<a href="./multiply.html" class="sidebar-item-text sidebar-link active">
|
| 152 |
-
<span class="menu-text"><span class="chapter-number">2</span> <span class="chapter-title">Multiply</span></span></a>
|
| 153 |
-
</div>
|
| 154 |
-
</li>
|
| 155 |
-
<li class="sidebar-item">
|
| 156 |
-
<div class="sidebar-item-container">
|
| 157 |
-
<a href="./countsheep.html" class="sidebar-item-text sidebar-link">
|
| 158 |
-
<span class="menu-text"><span class="chapter-number">3</span> <span class="chapter-title">If you can’t sleep, just count sheep!!</span></span></a>
|
| 159 |
-
</div>
|
| 160 |
-
</li>
|
| 161 |
-
<li class="sidebar-item">
|
| 162 |
-
<div class="sidebar-item-container">
|
| 163 |
-
<a href="./reducegrow.html" class="sidebar-item-text sidebar-link">
|
| 164 |
-
<span class="menu-text"><span class="chapter-number">4</span> <span class="chapter-title">Beginner - Reduce but Grow</span></span></a>
|
| 165 |
-
</div>
|
| 166 |
-
</li>
|
| 167 |
-
<li class="sidebar-item">
|
| 168 |
-
<div class="sidebar-item-container">
|
| 169 |
-
<a href="./make_negative.html" class="sidebar-item-text sidebar-link">
|
| 170 |
-
<span class="menu-text"><span class="chapter-number">5</span> <span class="chapter-title">Return Negative</span></span></a>
|
| 171 |
-
</div>
|
| 172 |
-
</li>
|
| 173 |
-
<li class="sidebar-item">
|
| 174 |
-
<div class="sidebar-item-container">
|
| 175 |
-
<a href="./positive_sum.html" class="sidebar-item-text sidebar-link">
|
| 176 |
-
<span class="menu-text"><span class="chapter-number">6</span> <span class="chapter-title">Sum of positive</span></span></a>
|
| 177 |
-
</div>
|
| 178 |
-
</li>
|
| 179 |
-
<li class="sidebar-item">
|
| 180 |
-
<div class="sidebar-item-container">
|
| 181 |
-
<a href="./references.html" class="sidebar-item-text sidebar-link">
|
| 182 |
-
<span class="menu-text">References</span></a>
|
| 183 |
-
</div>
|
| 184 |
-
</li>
|
| 185 |
-
</ul>
|
| 186 |
-
</div>
|
| 187 |
-
</nav>
|
| 188 |
-
<div id="quarto-sidebar-glass" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass"></div>
|
| 189 |
-
<!-- margin-sidebar -->
|
| 190 |
-
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
|
| 191 |
-
<nav id="TOC" role="doc-toc" class="toc-active">
|
| 192 |
-
<h2 id="toc-title">Table of contents</h2>
|
| 193 |
-
|
| 194 |
-
<ul>
|
| 195 |
-
<li><a href="#instruction" id="toc-instruction" class="nav-link active" data-scroll-target="#instruction"><span class="header-section-number">2.1</span> Instruction</a></li>
|
| 196 |
-
<li><a href="#youtube-video" id="toc-youtube-video" class="nav-link" data-scroll-target="#youtube-video"><span class="header-section-number">2.2</span> YouTube Video</a></li>
|
| 197 |
-
<li><a href="#solution-code" id="toc-solution-code" class="nav-link" data-scroll-target="#solution-code"><span class="header-section-number">2.3</span> Solution Code</a></li>
|
| 198 |
-
<li><a href="#test" id="toc-test" class="nav-link" data-scroll-target="#test"><span class="header-section-number">2.4</span> Test</a></li>
|
| 199 |
-
<li><a href="#supported-by" id="toc-supported-by" class="nav-link" data-scroll-target="#supported-by"><span class="header-section-number">2.5</span> Supported by</a></li>
|
| 200 |
-
</ul>
|
| 201 |
-
</nav>
|
| 202 |
-
</div>
|
| 203 |
-
<!-- main -->
|
| 204 |
-
<main class="content" id="quarto-document-content">
|
| 205 |
-
|
| 206 |
-
<header id="title-block-header" class="quarto-title-block default">
|
| 207 |
-
<div class="quarto-title">
|
| 208 |
-
<h1 class="title"><span id="multiply" class="quarto-section-identifier"><span class="chapter-number">2</span> <span class="chapter-title">Multiply</span></span></h1>
|
| 209 |
-
</div>
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
<div class="quarto-title-meta">
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
</div>
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
</header>
|
| 222 |
-
|
| 223 |
-
<p>Tantangan #2/366 - 16 Feb 2024</p>
|
| 224 |
-
<p><a href="https://www.codewars.com/kata/50654ddff44f800200000004/train/r" class="uri">https://www.codewars.com/kata/50654ddff44f800200000004/train/r</a></p>
|
| 225 |
-
<p><span class="badge rounded-pill quarto-badge " style="background-color: grey;">8kyu</span> Multiply</p>
|
| 226 |
-
<section id="instruction" class="level2" data-number="2.1">
|
| 227 |
-
<h2 data-number="2.1" class="anchored" data-anchor-id="instruction"><span class="header-section-number">2.1</span> Instruction</h2>
|
| 228 |
-
<p>This code does not execute properly. Try to figure out why.</p>
|
| 229 |
-
<pre><code>mul <- function(a, b) {
|
| 230 |
-
a * c # try to figure out why it doesn't work!
|
| 231 |
-
}</code></pre>
|
| 232 |
-
</section>
|
| 233 |
-
<section id="youtube-video" class="level2" data-number="2.2">
|
| 234 |
-
<h2 data-number="2.2" class="anchored" data-anchor-id="youtube-video"><span class="header-section-number">2.2</span> YouTube Video</h2>
|
| 235 |
-
<div class="quarto-video ratio ratio-16x9"><iframe data-external="1" src="https://www.youtube.com/embed/L8aczEhqymk?si=DSx84acpNvbkucrK" title="" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe></div>
|
| 236 |
-
</section>
|
| 237 |
-
<section id="solution-code" class="level2" data-number="2.3">
|
| 238 |
-
<h2 data-number="2.3" class="anchored" data-anchor-id="solution-code"><span class="header-section-number">2.3</span> Solution Code</h2>
|
| 239 |
-
<p>Karena argumen dari function <code>mul()</code> adalah <code>a</code> dan <code>b</code> sedangkan operasi perkalian di dalamnya menggunakan <code>c</code> yang belum diketahui dan tidak ada objek tersebut.</p>
|
| 240 |
-
<div class="cell">
|
| 241 |
-
<div class="sourceCode cell-code" id="cb2"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>mul <span class="ot"><-</span> <span class="cf">function</span>(a, b) {</span>
|
| 242 |
-
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> a <span class="sc">*</span> c <span class="co"># try to figure out why it doesn't work!</span></span>
|
| 243 |
-
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 244 |
-
</div>
|
| 245 |
-
<p>Solusi: ganti objek <code>c</code> di dalam function <code>mul()</code> dengan <code>b</code> dari argumen function tersebut.</p>
|
| 246 |
-
<div class="cell">
|
| 247 |
-
<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a>mul <span class="ot"><-</span> <span class="cf">function</span>(a, b) {</span>
|
| 248 |
-
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a> a <span class="sc">*</span> b </span>
|
| 249 |
-
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 250 |
-
</div>
|
| 251 |
-
</section>
|
| 252 |
-
<section id="test" class="level2" data-number="2.4">
|
| 253 |
-
<h2 data-number="2.4" class="anchored" data-anchor-id="test"><span class="header-section-number">2.4</span> Test</h2>
|
| 254 |
-
<div class="cell">
|
| 255 |
-
<div class="sourceCode cell-code" id="cb4"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(testthat)</span>
|
| 256 |
-
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a></span>
|
| 257 |
-
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a><span class="fu">test_that</span>(<span class="st">"test for associativity of multiplication"</span>, {</span>
|
| 258 |
-
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a> a <span class="ot"><-</span> <span class="fu">runif</span>(<span class="dv">1</span>, <span class="dv">0</span>, <span class="dv">10000</span>)</span>
|
| 259 |
-
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a> b <span class="ot"><-</span> <span class="fu">runif</span>(<span class="dv">1</span>, <span class="dv">0</span>, <span class="dv">10000</span>)</span>
|
| 260 |
-
<span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a> c <span class="ot"><-</span> <span class="fu">runif</span>(<span class="dv">1</span>, <span class="dv">0</span>, <span class="dv">10000</span>)</span>
|
| 261 |
-
<span id="cb4-7"><a href="#cb4-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">expect_equal</span>(<span class="fu">mul</span>(a, b), a <span class="sc">*</span> b)</span>
|
| 262 |
-
<span id="cb4-8"><a href="#cb4-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">expect_equal</span>(<span class="fu">mul</span>(<span class="fu">mul</span>(a, b), c), a <span class="sc">*</span> b <span class="sc">*</span> c)</span>
|
| 263 |
-
<span id="cb4-9"><a href="#cb4-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">expect_equal</span>(<span class="fu">mul</span>(a, <span class="fu">mul</span>(b, c)), a <span class="sc">*</span> b <span class="sc">*</span> c)</span>
|
| 264 |
-
<span id="cb4-10"><a href="#cb4-10" aria-hidden="true" tabindex="-1"></a>})</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 265 |
-
<div class="cell-output cell-output-stdout">
|
| 266 |
-
<pre><code>Test passed 😀</code></pre>
|
| 267 |
-
</div>
|
| 268 |
-
</div>
|
| 269 |
-
</section>
|
| 270 |
-
<section id="supported-by" class="level2" data-number="2.5">
|
| 271 |
-
<h2 data-number="2.5" class="anchored" data-anchor-id="supported-by"><span class="header-section-number">2.5</span> Supported by</h2>
|
| 272 |
-
<div class="quarto-figure quarto-figure-center">
|
| 273 |
-
<figure class="figure">
|
| 274 |
-
<p><a href="https://www.starcore.co"><img src="new_starcore_logo.png" class="img-fluid figure-img"></a></p>
|
| 275 |
-
<figcaption class="figure-caption">StarCore Analytics</figcaption>
|
| 276 |
-
</figure>
|
| 277 |
-
</div>
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
</section>
|
| 281 |
-
|
| 282 |
-
</main> <!-- /main -->
|
| 283 |
-
<script id="quarto-html-after-body" type="application/javascript">
|
| 284 |
-
window.document.addEventListener("DOMContentLoaded", function (event) {
|
| 285 |
-
const toggleBodyColorMode = (bsSheetEl) => {
|
| 286 |
-
const mode = bsSheetEl.getAttribute("data-mode");
|
| 287 |
-
const bodyEl = window.document.querySelector("body");
|
| 288 |
-
if (mode === "dark") {
|
| 289 |
-
bodyEl.classList.add("quarto-dark");
|
| 290 |
-
bodyEl.classList.remove("quarto-light");
|
| 291 |
-
} else {
|
| 292 |
-
bodyEl.classList.add("quarto-light");
|
| 293 |
-
bodyEl.classList.remove("quarto-dark");
|
| 294 |
-
}
|
| 295 |
-
}
|
| 296 |
-
const toggleBodyColorPrimary = () => {
|
| 297 |
-
const bsSheetEl = window.document.querySelector("link#quarto-bootstrap");
|
| 298 |
-
if (bsSheetEl) {
|
| 299 |
-
toggleBodyColorMode(bsSheetEl);
|
| 300 |
-
}
|
| 301 |
-
}
|
| 302 |
-
toggleBodyColorPrimary();
|
| 303 |
-
const icon = "";
|
| 304 |
-
const anchorJS = new window.AnchorJS();
|
| 305 |
-
anchorJS.options = {
|
| 306 |
-
placement: 'right',
|
| 307 |
-
icon: icon
|
| 308 |
-
};
|
| 309 |
-
anchorJS.add('.anchored');
|
| 310 |
-
const isCodeAnnotation = (el) => {
|
| 311 |
-
for (const clz of el.classList) {
|
| 312 |
-
if (clz.startsWith('code-annotation-')) {
|
| 313 |
-
return true;
|
| 314 |
-
}
|
| 315 |
-
}
|
| 316 |
-
return false;
|
| 317 |
-
}
|
| 318 |
-
const clipboard = new window.ClipboardJS('.code-copy-button', {
|
| 319 |
-
text: function(trigger) {
|
| 320 |
-
const codeEl = trigger.previousElementSibling.cloneNode(true);
|
| 321 |
-
for (const childEl of codeEl.children) {
|
| 322 |
-
if (isCodeAnnotation(childEl)) {
|
| 323 |
-
childEl.remove();
|
| 324 |
-
}
|
| 325 |
-
}
|
| 326 |
-
return codeEl.innerText;
|
| 327 |
-
}
|
| 328 |
-
});
|
| 329 |
-
clipboard.on('success', function(e) {
|
| 330 |
-
// button target
|
| 331 |
-
const button = e.trigger;
|
| 332 |
-
// don't keep focus
|
| 333 |
-
button.blur();
|
| 334 |
-
// flash "checked"
|
| 335 |
-
button.classList.add('code-copy-button-checked');
|
| 336 |
-
var currentTitle = button.getAttribute("title");
|
| 337 |
-
button.setAttribute("title", "Copied!");
|
| 338 |
-
let tooltip;
|
| 339 |
-
if (window.bootstrap) {
|
| 340 |
-
button.setAttribute("data-bs-toggle", "tooltip");
|
| 341 |
-
button.setAttribute("data-bs-placement", "left");
|
| 342 |
-
button.setAttribute("data-bs-title", "Copied!");
|
| 343 |
-
tooltip = new bootstrap.Tooltip(button,
|
| 344 |
-
{ trigger: "manual",
|
| 345 |
-
customClass: "code-copy-button-tooltip",
|
| 346 |
-
offset: [0, -8]});
|
| 347 |
-
tooltip.show();
|
| 348 |
-
}
|
| 349 |
-
setTimeout(function() {
|
| 350 |
-
if (tooltip) {
|
| 351 |
-
tooltip.hide();
|
| 352 |
-
button.removeAttribute("data-bs-title");
|
| 353 |
-
button.removeAttribute("data-bs-toggle");
|
| 354 |
-
button.removeAttribute("data-bs-placement");
|
| 355 |
-
}
|
| 356 |
-
button.setAttribute("title", currentTitle);
|
| 357 |
-
button.classList.remove('code-copy-button-checked');
|
| 358 |
-
}, 1000);
|
| 359 |
-
// clear code selection
|
| 360 |
-
e.clearSelection();
|
| 361 |
-
});
|
| 362 |
-
function tippyHover(el, contentFn) {
|
| 363 |
-
const config = {
|
| 364 |
-
allowHTML: true,
|
| 365 |
-
content: contentFn,
|
| 366 |
-
maxWidth: 500,
|
| 367 |
-
delay: 100,
|
| 368 |
-
arrow: false,
|
| 369 |
-
appendTo: function(el) {
|
| 370 |
-
return el.parentElement;
|
| 371 |
-
},
|
| 372 |
-
interactive: true,
|
| 373 |
-
interactiveBorder: 10,
|
| 374 |
-
theme: 'quarto',
|
| 375 |
-
placement: 'bottom-start'
|
| 376 |
-
};
|
| 377 |
-
window.tippy(el, config);
|
| 378 |
-
}
|
| 379 |
-
const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
|
| 380 |
-
for (var i=0; i<noterefs.length; i++) {
|
| 381 |
-
const ref = noterefs[i];
|
| 382 |
-
tippyHover(ref, function() {
|
| 383 |
-
// use id or data attribute instead here
|
| 384 |
-
let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
|
| 385 |
-
try { href = new URL(href).hash; } catch {}
|
| 386 |
-
const id = href.replace(/^#\/?/, "");
|
| 387 |
-
const note = window.document.getElementById(id);
|
| 388 |
-
return note.innerHTML;
|
| 389 |
-
});
|
| 390 |
-
}
|
| 391 |
-
let selectedAnnoteEl;
|
| 392 |
-
const selectorForAnnotation = ( cell, annotation) => {
|
| 393 |
-
let cellAttr = 'data-code-cell="' + cell + '"';
|
| 394 |
-
let lineAttr = 'data-code-annotation="' + annotation + '"';
|
| 395 |
-
const selector = 'span[' + cellAttr + '][' + lineAttr + ']';
|
| 396 |
-
return selector;
|
| 397 |
-
}
|
| 398 |
-
const selectCodeLines = (annoteEl) => {
|
| 399 |
-
const doc = window.document;
|
| 400 |
-
const targetCell = annoteEl.getAttribute("data-target-cell");
|
| 401 |
-
const targetAnnotation = annoteEl.getAttribute("data-target-annotation");
|
| 402 |
-
const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation));
|
| 403 |
-
const lines = annoteSpan.getAttribute("data-code-lines").split(",");
|
| 404 |
-
const lineIds = lines.map((line) => {
|
| 405 |
-
return targetCell + "-" + line;
|
| 406 |
-
})
|
| 407 |
-
let top = null;
|
| 408 |
-
let height = null;
|
| 409 |
-
let parent = null;
|
| 410 |
-
if (lineIds.length > 0) {
|
| 411 |
-
//compute the position of the single el (top and bottom and make a div)
|
| 412 |
-
const el = window.document.getElementById(lineIds[0]);
|
| 413 |
-
top = el.offsetTop;
|
| 414 |
-
height = el.offsetHeight;
|
| 415 |
-
parent = el.parentElement.parentElement;
|
| 416 |
-
if (lineIds.length > 1) {
|
| 417 |
-
const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]);
|
| 418 |
-
const bottom = lastEl.offsetTop + lastEl.offsetHeight;
|
| 419 |
-
height = bottom - top;
|
| 420 |
-
}
|
| 421 |
-
if (top !== null && height !== null && parent !== null) {
|
| 422 |
-
// cook up a div (if necessary) and position it
|
| 423 |
-
let div = window.document.getElementById("code-annotation-line-highlight");
|
| 424 |
-
if (div === null) {
|
| 425 |
-
div = window.document.createElement("div");
|
| 426 |
-
div.setAttribute("id", "code-annotation-line-highlight");
|
| 427 |
-
div.style.position = 'absolute';
|
| 428 |
-
parent.appendChild(div);
|
| 429 |
-
}
|
| 430 |
-
div.style.top = top - 2 + "px";
|
| 431 |
-
div.style.height = height + 4 + "px";
|
| 432 |
-
let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter");
|
| 433 |
-
if (gutterDiv === null) {
|
| 434 |
-
gutterDiv = window.document.createElement("div");
|
| 435 |
-
gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter");
|
| 436 |
-
gutterDiv.style.position = 'absolute';
|
| 437 |
-
const codeCell = window.document.getElementById(targetCell);
|
| 438 |
-
const gutter = codeCell.querySelector('.code-annotation-gutter');
|
| 439 |
-
gutter.appendChild(gutterDiv);
|
| 440 |
-
}
|
| 441 |
-
gutterDiv.style.top = top - 2 + "px";
|
| 442 |
-
gutterDiv.style.height = height + 4 + "px";
|
| 443 |
-
}
|
| 444 |
-
selectedAnnoteEl = annoteEl;
|
| 445 |
-
}
|
| 446 |
-
};
|
| 447 |
-
const unselectCodeLines = () => {
|
| 448 |
-
const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"];
|
| 449 |
-
elementsIds.forEach((elId) => {
|
| 450 |
-
const div = window.document.getElementById(elId);
|
| 451 |
-
if (div) {
|
| 452 |
-
div.remove();
|
| 453 |
-
}
|
| 454 |
-
});
|
| 455 |
-
selectedAnnoteEl = undefined;
|
| 456 |
-
};
|
| 457 |
-
// Attach click handler to the DT
|
| 458 |
-
const annoteDls = window.document.querySelectorAll('dt[data-target-cell]');
|
| 459 |
-
for (const annoteDlNode of annoteDls) {
|
| 460 |
-
annoteDlNode.addEventListener('click', (event) => {
|
| 461 |
-
const clickedEl = event.target;
|
| 462 |
-
if (clickedEl !== selectedAnnoteEl) {
|
| 463 |
-
unselectCodeLines();
|
| 464 |
-
const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active');
|
| 465 |
-
if (activeEl) {
|
| 466 |
-
activeEl.classList.remove('code-annotation-active');
|
| 467 |
-
}
|
| 468 |
-
selectCodeLines(clickedEl);
|
| 469 |
-
clickedEl.classList.add('code-annotation-active');
|
| 470 |
-
} else {
|
| 471 |
-
// Unselect the line
|
| 472 |
-
unselectCodeLines();
|
| 473 |
-
clickedEl.classList.remove('code-annotation-active');
|
| 474 |
-
}
|
| 475 |
-
});
|
| 476 |
-
}
|
| 477 |
-
const findCites = (el) => {
|
| 478 |
-
const parentEl = el.parentElement;
|
| 479 |
-
if (parentEl) {
|
| 480 |
-
const cites = parentEl.dataset.cites;
|
| 481 |
-
if (cites) {
|
| 482 |
-
return {
|
| 483 |
-
el,
|
| 484 |
-
cites: cites.split(' ')
|
| 485 |
-
};
|
| 486 |
-
} else {
|
| 487 |
-
return findCites(el.parentElement)
|
| 488 |
-
}
|
| 489 |
-
} else {
|
| 490 |
-
return undefined;
|
| 491 |
-
}
|
| 492 |
-
};
|
| 493 |
-
var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
|
| 494 |
-
for (var i=0; i<bibliorefs.length; i++) {
|
| 495 |
-
const ref = bibliorefs[i];
|
| 496 |
-
const citeInfo = findCites(ref);
|
| 497 |
-
if (citeInfo) {
|
| 498 |
-
tippyHover(citeInfo.el, function() {
|
| 499 |
-
var popup = window.document.createElement('div');
|
| 500 |
-
citeInfo.cites.forEach(function(cite) {
|
| 501 |
-
var citeDiv = window.document.createElement('div');
|
| 502 |
-
citeDiv.classList.add('hanging-indent');
|
| 503 |
-
citeDiv.classList.add('csl-entry');
|
| 504 |
-
var biblioDiv = window.document.getElementById('ref-' + cite);
|
| 505 |
-
if (biblioDiv) {
|
| 506 |
-
citeDiv.innerHTML = biblioDiv.innerHTML;
|
| 507 |
-
}
|
| 508 |
-
popup.appendChild(citeDiv);
|
| 509 |
-
});
|
| 510 |
-
return popup.innerHTML;
|
| 511 |
-
});
|
| 512 |
-
}
|
| 513 |
-
}
|
| 514 |
-
});
|
| 515 |
-
</script>
|
| 516 |
-
<nav class="page-navigation">
|
| 517 |
-
<div class="nav-page nav-page-previous">
|
| 518 |
-
<a href="./evenodd.html" class="pagination-link">
|
| 519 |
-
<i class="bi bi-arrow-left-short"></i> <span class="nav-page-text"><span class="chapter-number">1</span> <span class="chapter-title">Even or Odd</span></span>
|
| 520 |
-
</a>
|
| 521 |
-
</div>
|
| 522 |
-
<div class="nav-page nav-page-next">
|
| 523 |
-
<a href="./countsheep.html" class="pagination-link">
|
| 524 |
-
<span class="nav-page-text"><span class="chapter-number">3</span> <span class="chapter-title">If you can’t sleep, just count sheep!!</span></span> <i class="bi bi-arrow-right-short"></i>
|
| 525 |
-
</a>
|
| 526 |
-
</div>
|
| 527 |
-
</nav>
|
| 528 |
-
</div> <!-- /content -->
|
| 529 |
-
|
| 530 |
-
|
| 531 |
-
|
| 532 |
-
</body></html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
<title>Codewars Challenge 2024 Menggunakan R dan RStudio - 6 Sum of positive</title>
|
| 11 |
-
<style>
|
| 12 |
-
code{white-space: pre-wrap;}
|
| 13 |
-
span.smallcaps{font-variant: small-caps;}
|
| 14 |
-
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
| 15 |
-
div.column{flex: auto; overflow-x: auto;}
|
| 16 |
-
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
| 17 |
-
ul.task-list{list-style: none;}
|
| 18 |
-
ul.task-list li input[type="checkbox"] {
|
| 19 |
-
width: 0.8em;
|
| 20 |
-
margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
|
| 21 |
-
vertical-align: middle;
|
| 22 |
-
}
|
| 23 |
-
/* CSS for syntax highlighting */
|
| 24 |
-
pre > code.sourceCode { white-space: pre; position: relative; }
|
| 25 |
-
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
|
| 26 |
-
pre > code.sourceCode > span:empty { height: 1.2em; }
|
| 27 |
-
.sourceCode { overflow: visible; }
|
| 28 |
-
code.sourceCode > span { color: inherit; text-decoration: inherit; }
|
| 29 |
-
div.sourceCode { margin: 1em 0; }
|
| 30 |
-
pre.sourceCode { margin: 0; }
|
| 31 |
-
@media screen {
|
| 32 |
-
div.sourceCode { overflow: auto; }
|
| 33 |
-
}
|
| 34 |
-
@media print {
|
| 35 |
-
pre > code.sourceCode { white-space: pre-wrap; }
|
| 36 |
-
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
|
| 37 |
-
}
|
| 38 |
-
pre.numberSource code
|
| 39 |
-
{ counter-reset: source-line 0; }
|
| 40 |
-
pre.numberSource code > span
|
| 41 |
-
{ position: relative; left: -4em; counter-increment: source-line; }
|
| 42 |
-
pre.numberSource code > span > a:first-child::before
|
| 43 |
-
{ content: counter(source-line);
|
| 44 |
-
position: relative; left: -1em; text-align: right; vertical-align: baseline;
|
| 45 |
-
border: none; display: inline-block;
|
| 46 |
-
-webkit-touch-callout: none; -webkit-user-select: none;
|
| 47 |
-
-khtml-user-select: none; -moz-user-select: none;
|
| 48 |
-
-ms-user-select: none; user-select: none;
|
| 49 |
-
padding: 0 4px; width: 4em;
|
| 50 |
-
}
|
| 51 |
-
pre.numberSource { margin-left: 3em; padding-left: 4px; }
|
| 52 |
-
div.sourceCode
|
| 53 |
-
{ }
|
| 54 |
-
@media screen {
|
| 55 |
-
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
|
| 56 |
-
}
|
| 57 |
-
</style>
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
<script src="site_libs/quarto-nav/quarto-nav.js"></script>
|
| 61 |
-
<script src="site_libs/quarto-nav/headroom.min.js"></script>
|
| 62 |
-
<script src="site_libs/clipboard/clipboard.min.js"></script>
|
| 63 |
-
<script src="site_libs/quarto-search/autocomplete.umd.js"></script>
|
| 64 |
-
<script src="site_libs/quarto-search/fuse.min.js"></script>
|
| 65 |
-
<script src="site_libs/quarto-search/quarto-search.js"></script>
|
| 66 |
-
<meta name="quarto:offset" content="./">
|
| 67 |
-
<link href="./references.html" rel="next">
|
| 68 |
-
<link href="./make_negative.html" rel="prev">
|
| 69 |
-
<script src="site_libs/quarto-html/quarto.js"></script>
|
| 70 |
-
<script src="site_libs/quarto-html/popper.min.js"></script>
|
| 71 |
-
<script src="site_libs/quarto-html/tippy.umd.min.js"></script>
|
| 72 |
-
<script src="site_libs/quarto-html/anchor.min.js"></script>
|
| 73 |
-
<link href="site_libs/quarto-html/tippy.css" rel="stylesheet">
|
| 74 |
-
<link href="site_libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
|
| 75 |
-
<script src="site_libs/bootstrap/bootstrap.min.js"></script>
|
| 76 |
-
<link href="site_libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
|
| 77 |
-
<link href="site_libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">
|
| 78 |
-
<link href="site_libs/quarto-contrib/badge/badge.css" rel="stylesheet">
|
| 79 |
-
<script id="quarto-search-options" type="application/json">{
|
| 80 |
-
"location": "sidebar",
|
| 81 |
-
"copy-button": false,
|
| 82 |
-
"collapse-after": 3,
|
| 83 |
-
"panel-placement": "start",
|
| 84 |
-
"type": "textbox",
|
| 85 |
-
"limit": 20,
|
| 86 |
-
"language": {
|
| 87 |
-
"search-no-results-text": "No results",
|
| 88 |
-
"search-matching-documents-text": "matching documents",
|
| 89 |
-
"search-copy-link-title": "Copy link to search",
|
| 90 |
-
"search-hide-matches-text": "Hide additional matches",
|
| 91 |
-
"search-more-match-text": "more match in this document",
|
| 92 |
-
"search-more-matches-text": "more matches in this document",
|
| 93 |
-
"search-clear-button-title": "Clear",
|
| 94 |
-
"search-detached-cancel-button-title": "Cancel",
|
| 95 |
-
"search-submit-button-title": "Submit",
|
| 96 |
-
"search-label": "Search"
|
| 97 |
-
}
|
| 98 |
-
}</script>
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
</head>
|
| 102 |
-
|
| 103 |
-
<body class="nav-sidebar floating">
|
| 104 |
-
|
| 105 |
-
<div id="quarto-search-results"></div>
|
| 106 |
-
<header id="quarto-header" class="headroom fixed-top">
|
| 107 |
-
<nav class="quarto-secondary-nav">
|
| 108 |
-
<div class="container-fluid d-flex">
|
| 109 |
-
<button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
|
| 110 |
-
<i class="bi bi-layout-text-sidebar-reverse"></i>
|
| 111 |
-
</button>
|
| 112 |
-
<nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="./positive_sum.html"><span class="chapter-number">6</span> <span class="chapter-title">Sum of positive</span></a></li></ol></nav>
|
| 113 |
-
<a class="flex-grow-1" role="button" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
|
| 114 |
-
</a>
|
| 115 |
-
<button type="button" class="btn quarto-search-button" aria-label="" onclick="window.quartoOpenSearch();">
|
| 116 |
-
<i class="bi bi-search"></i>
|
| 117 |
-
</button>
|
| 118 |
-
</div>
|
| 119 |
-
</nav>
|
| 120 |
-
</header>
|
| 121 |
-
<!-- content -->
|
| 122 |
-
<div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article">
|
| 123 |
-
<!-- sidebar -->
|
| 124 |
-
<nav id="quarto-sidebar" class="sidebar collapse collapse-horizontal sidebar-navigation floating overflow-auto">
|
| 125 |
-
<div class="pt-lg-2 mt-2 text-left sidebar-header">
|
| 126 |
-
<div class="sidebar-title mb-0 py-0">
|
| 127 |
-
<a href="./">Codewars Challenge 2024 Menggunakan R dan RStudio</a>
|
| 128 |
-
</div>
|
| 129 |
-
</div>
|
| 130 |
-
<div class="mt-2 flex-shrink-0 align-items-center">
|
| 131 |
-
<div class="sidebar-search">
|
| 132 |
-
<div id="quarto-search" class="" title="Search"></div>
|
| 133 |
-
</div>
|
| 134 |
-
</div>
|
| 135 |
-
<div class="sidebar-menu-container">
|
| 136 |
-
<ul class="list-unstyled mt-1">
|
| 137 |
-
<li class="sidebar-item">
|
| 138 |
-
<div class="sidebar-item-container">
|
| 139 |
-
<a href="./index.html" class="sidebar-item-text sidebar-link">
|
| 140 |
-
<span class="menu-text">Pengantar</span></a>
|
| 141 |
-
</div>
|
| 142 |
-
</li>
|
| 143 |
-
<li class="sidebar-item">
|
| 144 |
-
<div class="sidebar-item-container">
|
| 145 |
-
<a href="./evenodd.html" class="sidebar-item-text sidebar-link">
|
| 146 |
-
<span class="menu-text"><span class="chapter-number">1</span> <span class="chapter-title">Even or Odd</span></span></a>
|
| 147 |
-
</div>
|
| 148 |
-
</li>
|
| 149 |
-
<li class="sidebar-item">
|
| 150 |
-
<div class="sidebar-item-container">
|
| 151 |
-
<a href="./multiply.html" class="sidebar-item-text sidebar-link">
|
| 152 |
-
<span class="menu-text"><span class="chapter-number">2</span> <span class="chapter-title">Multiply</span></span></a>
|
| 153 |
-
</div>
|
| 154 |
-
</li>
|
| 155 |
-
<li class="sidebar-item">
|
| 156 |
-
<div class="sidebar-item-container">
|
| 157 |
-
<a href="./countsheep.html" class="sidebar-item-text sidebar-link">
|
| 158 |
-
<span class="menu-text"><span class="chapter-number">3</span> <span class="chapter-title">If you can’t sleep, just count sheep!!</span></span></a>
|
| 159 |
-
</div>
|
| 160 |
-
</li>
|
| 161 |
-
<li class="sidebar-item">
|
| 162 |
-
<div class="sidebar-item-container">
|
| 163 |
-
<a href="./reducegrow.html" class="sidebar-item-text sidebar-link">
|
| 164 |
-
<span class="menu-text"><span class="chapter-number">4</span> <span class="chapter-title">Beginner - Reduce but Grow</span></span></a>
|
| 165 |
-
</div>
|
| 166 |
-
</li>
|
| 167 |
-
<li class="sidebar-item">
|
| 168 |
-
<div class="sidebar-item-container">
|
| 169 |
-
<a href="./make_negative.html" class="sidebar-item-text sidebar-link">
|
| 170 |
-
<span class="menu-text"><span class="chapter-number">5</span> <span class="chapter-title">Return Negative</span></span></a>
|
| 171 |
-
</div>
|
| 172 |
-
</li>
|
| 173 |
-
<li class="sidebar-item">
|
| 174 |
-
<div class="sidebar-item-container">
|
| 175 |
-
<a href="./positive_sum.html" class="sidebar-item-text sidebar-link active">
|
| 176 |
-
<span class="menu-text"><span class="chapter-number">6</span> <span class="chapter-title">Sum of positive</span></span></a>
|
| 177 |
-
</div>
|
| 178 |
-
</li>
|
| 179 |
-
<li class="sidebar-item">
|
| 180 |
-
<div class="sidebar-item-container">
|
| 181 |
-
<a href="./references.html" class="sidebar-item-text sidebar-link">
|
| 182 |
-
<span class="menu-text">References</span></a>
|
| 183 |
-
</div>
|
| 184 |
-
</li>
|
| 185 |
-
</ul>
|
| 186 |
-
</div>
|
| 187 |
-
</nav>
|
| 188 |
-
<div id="quarto-sidebar-glass" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass"></div>
|
| 189 |
-
<!-- margin-sidebar -->
|
| 190 |
-
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
|
| 191 |
-
<nav id="TOC" role="doc-toc" class="toc-active">
|
| 192 |
-
<h2 id="toc-title">Table of contents</h2>
|
| 193 |
-
|
| 194 |
-
<ul>
|
| 195 |
-
<li><a href="#instruction" id="toc-instruction" class="nav-link active" data-scroll-target="#instruction"><span class="header-section-number">6.1</span> Instruction</a></li>
|
| 196 |
-
<li><a href="#youtube-video" id="toc-youtube-video" class="nav-link" data-scroll-target="#youtube-video"><span class="header-section-number">6.2</span> YouTube Video</a></li>
|
| 197 |
-
<li><a href="#solution-code" id="toc-solution-code" class="nav-link" data-scroll-target="#solution-code"><span class="header-section-number">6.3</span> Solution Code</a></li>
|
| 198 |
-
<li><a href="#test" id="toc-test" class="nav-link" data-scroll-target="#test"><span class="header-section-number">6.4</span> Test</a></li>
|
| 199 |
-
<li><a href="#supported-by" id="toc-supported-by" class="nav-link" data-scroll-target="#supported-by"><span class="header-section-number">6.5</span> Supported by</a></li>
|
| 200 |
-
</ul>
|
| 201 |
-
</nav>
|
| 202 |
-
</div>
|
| 203 |
-
<!-- main -->
|
| 204 |
-
<main class="content" id="quarto-document-content">
|
| 205 |
-
|
| 206 |
-
<header id="title-block-header" class="quarto-title-block default">
|
| 207 |
-
<div class="quarto-title">
|
| 208 |
-
<h1 class="title"><span class="chapter-number">6</span> <span class="chapter-title">Sum of positive</span></h1>
|
| 209 |
-
</div>
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
<div class="quarto-title-meta">
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
</div>
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
</header>
|
| 222 |
-
|
| 223 |
-
<p>Tantangan #6/366 - 19 Feb 2024</p>
|
| 224 |
-
<p><a href="https://www.codewars.com/kata/5715eaedb436cf5606000381/train/r" class="uri">https://www.codewars.com/kata/5715eaedb436cf5606000381/train/r</a></p>
|
| 225 |
-
<p><span class="badge rounded-pill quarto-badge " style="background-color: grey;">8kyu</span> Sum of positive</p>
|
| 226 |
-
<section id="instruction" class="level2" data-number="6.1">
|
| 227 |
-
<h2 data-number="6.1" class="anchored" data-anchor-id="instruction"><span class="header-section-number">6.1</span> Instruction</h2>
|
| 228 |
-
<p>You get an array of numbers, return the sum of all of the positives ones.</p>
|
| 229 |
-
<p>Example <code>[1,-4,7,12]</code> => <code>1 + 7 + 12 = 20</code></p>
|
| 230 |
-
<p>Note: if there is nothing to sum, the sum is default to 0.</p>
|
| 231 |
-
</section>
|
| 232 |
-
<section id="youtube-video" class="level2" data-number="6.2">
|
| 233 |
-
<h2 data-number="6.2" class="anchored" data-anchor-id="youtube-video"><span class="header-section-number">6.2</span> YouTube Video</h2>
|
| 234 |
-
<div class="quarto-video ratio ratio-16x9"><iframe data-external="1" src="https://www.youtube.com/embed/xCvHwR52p4k?si=yoLfpHfcIBYk0j9c" title="" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe></div>
|
| 235 |
-
</section>
|
| 236 |
-
<section id="solution-code" class="level2" data-number="6.3">
|
| 237 |
-
<h2 data-number="6.3" class="anchored" data-anchor-id="solution-code"><span class="header-section-number">6.3</span> Solution Code</h2>
|
| 238 |
-
<p>Solusi bar-bar</p>
|
| 239 |
-
<div class="cell">
|
| 240 |
-
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a>positive_sum <span class="ot"><-</span> <span class="cf">function</span>(vec){</span>
|
| 241 |
-
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a> pos_vec <span class="ot"><-</span> <span class="fu">c</span>()</span>
|
| 242 |
-
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a> <span class="cf">for</span>(i <span class="cf">in</span> vec){</span>
|
| 243 |
-
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span>(i <span class="sc">></span> <span class="dv">0</span>){</span>
|
| 244 |
-
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a> pos_vec <span class="ot"><-</span> <span class="fu">c</span>(pos_vec, i)</span>
|
| 245 |
-
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a> } <span class="cf">else</span> {</span>
|
| 246 |
-
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a> pos_vec <span class="ot"><-</span> <span class="fu">c</span>(pos_vec, <span class="dv">0</span>)</span>
|
| 247 |
-
<span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a> } </span>
|
| 248 |
-
<span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a> }</span>
|
| 249 |
-
<span id="cb1-10"><a href="#cb1-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">return</span>(<span class="fu">sum</span>(pos_vec))</span>
|
| 250 |
-
<span id="cb1-11"><a href="#cb1-11" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 251 |
-
</div>
|
| 252 |
-
<p>Solusi simple</p>
|
| 253 |
-
<div class="cell">
|
| 254 |
-
<div class="sourceCode cell-code" id="cb2"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>positive_sum <span class="ot"><-</span> <span class="cf">function</span>(vec){</span>
|
| 255 |
-
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> vec[vec <span class="sc"><</span> <span class="dv">0</span>] <span class="ot"><-</span> <span class="dv">0</span></span>
|
| 256 |
-
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">sum</span>(vec)</span>
|
| 257 |
-
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 258 |
-
</div>
|
| 259 |
-
<div class="cell">
|
| 260 |
-
<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a>positive_sum <span class="ot"><-</span> <span class="cf">function</span>(vec)<span class="fu">sum</span>(vec[vec<span class="sc">></span><span class="dv">0</span>])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 261 |
-
</div>
|
| 262 |
-
</section>
|
| 263 |
-
<section id="test" class="level2" data-number="6.4">
|
| 264 |
-
<h2 data-number="6.4" class="anchored" data-anchor-id="test"><span class="header-section-number">6.4</span> Test</h2>
|
| 265 |
-
<div class="cell">
|
| 266 |
-
<div class="sourceCode cell-code" id="cb4"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(testthat)</span>
|
| 267 |
-
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a></span>
|
| 268 |
-
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a><span class="fu">test_that</span>(<span class="st">'Basic tests'</span>, {</span>
|
| 269 |
-
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">expect_equal</span>(<span class="fu">positive_sum</span>(<span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">2</span>,<span class="dv">3</span>,<span class="dv">4</span>,<span class="dv">5</span>)),<span class="dv">15</span>)</span>
|
| 270 |
-
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">expect_equal</span>(<span class="fu">positive_sum</span>(<span class="fu">c</span>(<span class="dv">1</span>,<span class="sc">-</span><span class="dv">2</span>,<span class="dv">3</span>,<span class="dv">4</span>,<span class="dv">5</span>)),<span class="dv">13</span>)</span>
|
| 271 |
-
<span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">expect_equal</span>(<span class="fu">positive_sum</span>(<span class="fu">c</span>(<span class="sc">-</span><span class="dv">1</span>,<span class="dv">2</span>,<span class="dv">3</span>,<span class="dv">4</span>,<span class="sc">-</span><span class="dv">5</span>)),<span class="dv">9</span>)</span>
|
| 272 |
-
<span id="cb4-7"><a href="#cb4-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">expect_equal</span>(<span class="fu">positive_sum</span>(<span class="fu">c</span>()),<span class="dv">0</span>)</span>
|
| 273 |
-
<span id="cb4-8"><a href="#cb4-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">expect_equal</span>(<span class="fu">positive_sum</span>(<span class="fu">c</span>(<span class="sc">-</span><span class="dv">1</span>,<span class="sc">-</span><span class="dv">2</span>,<span class="sc">-</span><span class="dv">3</span>,<span class="sc">-</span><span class="dv">4</span>,<span class="sc">-</span><span class="dv">5</span>)),<span class="dv">0</span>)</span>
|
| 274 |
-
<span id="cb4-9"><a href="#cb4-9" aria-hidden="true" tabindex="-1"></a>})</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 275 |
-
<div class="cell-output cell-output-stdout">
|
| 276 |
-
<pre><code>Test passed 😸</code></pre>
|
| 277 |
-
</div>
|
| 278 |
-
</div>
|
| 279 |
-
</section>
|
| 280 |
-
<section id="supported-by" class="level2" data-number="6.5">
|
| 281 |
-
<h2 data-number="6.5" class="anchored" data-anchor-id="supported-by"><span class="header-section-number">6.5</span> Supported by</h2>
|
| 282 |
-
<div class="quarto-figure quarto-figure-center">
|
| 283 |
-
<figure class="figure">
|
| 284 |
-
<p><a href="https://www.starcore.co"><img src="new_starcore_logo.png" class="img-fluid figure-img"></a></p>
|
| 285 |
-
<figcaption class="figure-caption">StarCore Analytics</figcaption>
|
| 286 |
-
</figure>
|
| 287 |
-
</div>
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
</section>
|
| 291 |
-
|
| 292 |
-
</main> <!-- /main -->
|
| 293 |
-
<script id="quarto-html-after-body" type="application/javascript">
|
| 294 |
-
window.document.addEventListener("DOMContentLoaded", function (event) {
|
| 295 |
-
const toggleBodyColorMode = (bsSheetEl) => {
|
| 296 |
-
const mode = bsSheetEl.getAttribute("data-mode");
|
| 297 |
-
const bodyEl = window.document.querySelector("body");
|
| 298 |
-
if (mode === "dark") {
|
| 299 |
-
bodyEl.classList.add("quarto-dark");
|
| 300 |
-
bodyEl.classList.remove("quarto-light");
|
| 301 |
-
} else {
|
| 302 |
-
bodyEl.classList.add("quarto-light");
|
| 303 |
-
bodyEl.classList.remove("quarto-dark");
|
| 304 |
-
}
|
| 305 |
-
}
|
| 306 |
-
const toggleBodyColorPrimary = () => {
|
| 307 |
-
const bsSheetEl = window.document.querySelector("link#quarto-bootstrap");
|
| 308 |
-
if (bsSheetEl) {
|
| 309 |
-
toggleBodyColorMode(bsSheetEl);
|
| 310 |
-
}
|
| 311 |
-
}
|
| 312 |
-
toggleBodyColorPrimary();
|
| 313 |
-
const icon = "";
|
| 314 |
-
const anchorJS = new window.AnchorJS();
|
| 315 |
-
anchorJS.options = {
|
| 316 |
-
placement: 'right',
|
| 317 |
-
icon: icon
|
| 318 |
-
};
|
| 319 |
-
anchorJS.add('.anchored');
|
| 320 |
-
const isCodeAnnotation = (el) => {
|
| 321 |
-
for (const clz of el.classList) {
|
| 322 |
-
if (clz.startsWith('code-annotation-')) {
|
| 323 |
-
return true;
|
| 324 |
-
}
|
| 325 |
-
}
|
| 326 |
-
return false;
|
| 327 |
-
}
|
| 328 |
-
const clipboard = new window.ClipboardJS('.code-copy-button', {
|
| 329 |
-
text: function(trigger) {
|
| 330 |
-
const codeEl = trigger.previousElementSibling.cloneNode(true);
|
| 331 |
-
for (const childEl of codeEl.children) {
|
| 332 |
-
if (isCodeAnnotation(childEl)) {
|
| 333 |
-
childEl.remove();
|
| 334 |
-
}
|
| 335 |
-
}
|
| 336 |
-
return codeEl.innerText;
|
| 337 |
-
}
|
| 338 |
-
});
|
| 339 |
-
clipboard.on('success', function(e) {
|
| 340 |
-
// button target
|
| 341 |
-
const button = e.trigger;
|
| 342 |
-
// don't keep focus
|
| 343 |
-
button.blur();
|
| 344 |
-
// flash "checked"
|
| 345 |
-
button.classList.add('code-copy-button-checked');
|
| 346 |
-
var currentTitle = button.getAttribute("title");
|
| 347 |
-
button.setAttribute("title", "Copied!");
|
| 348 |
-
let tooltip;
|
| 349 |
-
if (window.bootstrap) {
|
| 350 |
-
button.setAttribute("data-bs-toggle", "tooltip");
|
| 351 |
-
button.setAttribute("data-bs-placement", "left");
|
| 352 |
-
button.setAttribute("data-bs-title", "Copied!");
|
| 353 |
-
tooltip = new bootstrap.Tooltip(button,
|
| 354 |
-
{ trigger: "manual",
|
| 355 |
-
customClass: "code-copy-button-tooltip",
|
| 356 |
-
offset: [0, -8]});
|
| 357 |
-
tooltip.show();
|
| 358 |
-
}
|
| 359 |
-
setTimeout(function() {
|
| 360 |
-
if (tooltip) {
|
| 361 |
-
tooltip.hide();
|
| 362 |
-
button.removeAttribute("data-bs-title");
|
| 363 |
-
button.removeAttribute("data-bs-toggle");
|
| 364 |
-
button.removeAttribute("data-bs-placement");
|
| 365 |
-
}
|
| 366 |
-
button.setAttribute("title", currentTitle);
|
| 367 |
-
button.classList.remove('code-copy-button-checked');
|
| 368 |
-
}, 1000);
|
| 369 |
-
// clear code selection
|
| 370 |
-
e.clearSelection();
|
| 371 |
-
});
|
| 372 |
-
function tippyHover(el, contentFn) {
|
| 373 |
-
const config = {
|
| 374 |
-
allowHTML: true,
|
| 375 |
-
content: contentFn,
|
| 376 |
-
maxWidth: 500,
|
| 377 |
-
delay: 100,
|
| 378 |
-
arrow: false,
|
| 379 |
-
appendTo: function(el) {
|
| 380 |
-
return el.parentElement;
|
| 381 |
-
},
|
| 382 |
-
interactive: true,
|
| 383 |
-
interactiveBorder: 10,
|
| 384 |
-
theme: 'quarto',
|
| 385 |
-
placement: 'bottom-start'
|
| 386 |
-
};
|
| 387 |
-
window.tippy(el, config);
|
| 388 |
-
}
|
| 389 |
-
const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
|
| 390 |
-
for (var i=0; i<noterefs.length; i++) {
|
| 391 |
-
const ref = noterefs[i];
|
| 392 |
-
tippyHover(ref, function() {
|
| 393 |
-
// use id or data attribute instead here
|
| 394 |
-
let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
|
| 395 |
-
try { href = new URL(href).hash; } catch {}
|
| 396 |
-
const id = href.replace(/^#\/?/, "");
|
| 397 |
-
const note = window.document.getElementById(id);
|
| 398 |
-
return note.innerHTML;
|
| 399 |
-
});
|
| 400 |
-
}
|
| 401 |
-
let selectedAnnoteEl;
|
| 402 |
-
const selectorForAnnotation = ( cell, annotation) => {
|
| 403 |
-
let cellAttr = 'data-code-cell="' + cell + '"';
|
| 404 |
-
let lineAttr = 'data-code-annotation="' + annotation + '"';
|
| 405 |
-
const selector = 'span[' + cellAttr + '][' + lineAttr + ']';
|
| 406 |
-
return selector;
|
| 407 |
-
}
|
| 408 |
-
const selectCodeLines = (annoteEl) => {
|
| 409 |
-
const doc = window.document;
|
| 410 |
-
const targetCell = annoteEl.getAttribute("data-target-cell");
|
| 411 |
-
const targetAnnotation = annoteEl.getAttribute("data-target-annotation");
|
| 412 |
-
const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation));
|
| 413 |
-
const lines = annoteSpan.getAttribute("data-code-lines").split(",");
|
| 414 |
-
const lineIds = lines.map((line) => {
|
| 415 |
-
return targetCell + "-" + line;
|
| 416 |
-
})
|
| 417 |
-
let top = null;
|
| 418 |
-
let height = null;
|
| 419 |
-
let parent = null;
|
| 420 |
-
if (lineIds.length > 0) {
|
| 421 |
-
//compute the position of the single el (top and bottom and make a div)
|
| 422 |
-
const el = window.document.getElementById(lineIds[0]);
|
| 423 |
-
top = el.offsetTop;
|
| 424 |
-
height = el.offsetHeight;
|
| 425 |
-
parent = el.parentElement.parentElement;
|
| 426 |
-
if (lineIds.length > 1) {
|
| 427 |
-
const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]);
|
| 428 |
-
const bottom = lastEl.offsetTop + lastEl.offsetHeight;
|
| 429 |
-
height = bottom - top;
|
| 430 |
-
}
|
| 431 |
-
if (top !== null && height !== null && parent !== null) {
|
| 432 |
-
// cook up a div (if necessary) and position it
|
| 433 |
-
let div = window.document.getElementById("code-annotation-line-highlight");
|
| 434 |
-
if (div === null) {
|
| 435 |
-
div = window.document.createElement("div");
|
| 436 |
-
div.setAttribute("id", "code-annotation-line-highlight");
|
| 437 |
-
div.style.position = 'absolute';
|
| 438 |
-
parent.appendChild(div);
|
| 439 |
-
}
|
| 440 |
-
div.style.top = top - 2 + "px";
|
| 441 |
-
div.style.height = height + 4 + "px";
|
| 442 |
-
let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter");
|
| 443 |
-
if (gutterDiv === null) {
|
| 444 |
-
gutterDiv = window.document.createElement("div");
|
| 445 |
-
gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter");
|
| 446 |
-
gutterDiv.style.position = 'absolute';
|
| 447 |
-
const codeCell = window.document.getElementById(targetCell);
|
| 448 |
-
const gutter = codeCell.querySelector('.code-annotation-gutter');
|
| 449 |
-
gutter.appendChild(gutterDiv);
|
| 450 |
-
}
|
| 451 |
-
gutterDiv.style.top = top - 2 + "px";
|
| 452 |
-
gutterDiv.style.height = height + 4 + "px";
|
| 453 |
-
}
|
| 454 |
-
selectedAnnoteEl = annoteEl;
|
| 455 |
-
}
|
| 456 |
-
};
|
| 457 |
-
const unselectCodeLines = () => {
|
| 458 |
-
const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"];
|
| 459 |
-
elementsIds.forEach((elId) => {
|
| 460 |
-
const div = window.document.getElementById(elId);
|
| 461 |
-
if (div) {
|
| 462 |
-
div.remove();
|
| 463 |
-
}
|
| 464 |
-
});
|
| 465 |
-
selectedAnnoteEl = undefined;
|
| 466 |
-
};
|
| 467 |
-
// Attach click handler to the DT
|
| 468 |
-
const annoteDls = window.document.querySelectorAll('dt[data-target-cell]');
|
| 469 |
-
for (const annoteDlNode of annoteDls) {
|
| 470 |
-
annoteDlNode.addEventListener('click', (event) => {
|
| 471 |
-
const clickedEl = event.target;
|
| 472 |
-
if (clickedEl !== selectedAnnoteEl) {
|
| 473 |
-
unselectCodeLines();
|
| 474 |
-
const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active');
|
| 475 |
-
if (activeEl) {
|
| 476 |
-
activeEl.classList.remove('code-annotation-active');
|
| 477 |
-
}
|
| 478 |
-
selectCodeLines(clickedEl);
|
| 479 |
-
clickedEl.classList.add('code-annotation-active');
|
| 480 |
-
} else {
|
| 481 |
-
// Unselect the line
|
| 482 |
-
unselectCodeLines();
|
| 483 |
-
clickedEl.classList.remove('code-annotation-active');
|
| 484 |
-
}
|
| 485 |
-
});
|
| 486 |
-
}
|
| 487 |
-
const findCites = (el) => {
|
| 488 |
-
const parentEl = el.parentElement;
|
| 489 |
-
if (parentEl) {
|
| 490 |
-
const cites = parentEl.dataset.cites;
|
| 491 |
-
if (cites) {
|
| 492 |
-
return {
|
| 493 |
-
el,
|
| 494 |
-
cites: cites.split(' ')
|
| 495 |
-
};
|
| 496 |
-
} else {
|
| 497 |
-
return findCites(el.parentElement)
|
| 498 |
-
}
|
| 499 |
-
} else {
|
| 500 |
-
return undefined;
|
| 501 |
-
}
|
| 502 |
-
};
|
| 503 |
-
var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
|
| 504 |
-
for (var i=0; i<bibliorefs.length; i++) {
|
| 505 |
-
const ref = bibliorefs[i];
|
| 506 |
-
const citeInfo = findCites(ref);
|
| 507 |
-
if (citeInfo) {
|
| 508 |
-
tippyHover(citeInfo.el, function() {
|
| 509 |
-
var popup = window.document.createElement('div');
|
| 510 |
-
citeInfo.cites.forEach(function(cite) {
|
| 511 |
-
var citeDiv = window.document.createElement('div');
|
| 512 |
-
citeDiv.classList.add('hanging-indent');
|
| 513 |
-
citeDiv.classList.add('csl-entry');
|
| 514 |
-
var biblioDiv = window.document.getElementById('ref-' + cite);
|
| 515 |
-
if (biblioDiv) {
|
| 516 |
-
citeDiv.innerHTML = biblioDiv.innerHTML;
|
| 517 |
-
}
|
| 518 |
-
popup.appendChild(citeDiv);
|
| 519 |
-
});
|
| 520 |
-
return popup.innerHTML;
|
| 521 |
-
});
|
| 522 |
-
}
|
| 523 |
-
}
|
| 524 |
-
});
|
| 525 |
-
</script>
|
| 526 |
-
<nav class="page-navigation">
|
| 527 |
-
<div class="nav-page nav-page-previous">
|
| 528 |
-
<a href="./make_negative.html" class="pagination-link">
|
| 529 |
-
<i class="bi bi-arrow-left-short"></i> <span class="nav-page-text"><span class="chapter-number">5</span> <span class="chapter-title">Return Negative</span></span>
|
| 530 |
-
</a>
|
| 531 |
-
</div>
|
| 532 |
-
<div class="nav-page nav-page-next">
|
| 533 |
-
<a href="./references.html" class="pagination-link">
|
| 534 |
-
<span class="nav-page-text">References</span> <i class="bi bi-arrow-right-short"></i>
|
| 535 |
-
</a>
|
| 536 |
-
</div>
|
| 537 |
-
</nav>
|
| 538 |
-
</div> <!-- /content -->
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
|
| 542 |
-
</body></html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reducegrow.html
DELETED
|
@@ -1,529 +0,0 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
|
| 3 |
-
|
| 4 |
-
<meta charset="utf-8">
|
| 5 |
-
<meta name="generator" content="quarto-1.3.433">
|
| 6 |
-
|
| 7 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
<title>Codewars Challenge 2024 Menggunakan R dan RStudio - 4 Beginner - Reduce but Grow</title>
|
| 11 |
-
<style>
|
| 12 |
-
code{white-space: pre-wrap;}
|
| 13 |
-
span.smallcaps{font-variant: small-caps;}
|
| 14 |
-
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
| 15 |
-
div.column{flex: auto; overflow-x: auto;}
|
| 16 |
-
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
| 17 |
-
ul.task-list{list-style: none;}
|
| 18 |
-
ul.task-list li input[type="checkbox"] {
|
| 19 |
-
width: 0.8em;
|
| 20 |
-
margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
|
| 21 |
-
vertical-align: middle;
|
| 22 |
-
}
|
| 23 |
-
/* CSS for syntax highlighting */
|
| 24 |
-
pre > code.sourceCode { white-space: pre; position: relative; }
|
| 25 |
-
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
|
| 26 |
-
pre > code.sourceCode > span:empty { height: 1.2em; }
|
| 27 |
-
.sourceCode { overflow: visible; }
|
| 28 |
-
code.sourceCode > span { color: inherit; text-decoration: inherit; }
|
| 29 |
-
div.sourceCode { margin: 1em 0; }
|
| 30 |
-
pre.sourceCode { margin: 0; }
|
| 31 |
-
@media screen {
|
| 32 |
-
div.sourceCode { overflow: auto; }
|
| 33 |
-
}
|
| 34 |
-
@media print {
|
| 35 |
-
pre > code.sourceCode { white-space: pre-wrap; }
|
| 36 |
-
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
|
| 37 |
-
}
|
| 38 |
-
pre.numberSource code
|
| 39 |
-
{ counter-reset: source-line 0; }
|
| 40 |
-
pre.numberSource code > span
|
| 41 |
-
{ position: relative; left: -4em; counter-increment: source-line; }
|
| 42 |
-
pre.numberSource code > span > a:first-child::before
|
| 43 |
-
{ content: counter(source-line);
|
| 44 |
-
position: relative; left: -1em; text-align: right; vertical-align: baseline;
|
| 45 |
-
border: none; display: inline-block;
|
| 46 |
-
-webkit-touch-callout: none; -webkit-user-select: none;
|
| 47 |
-
-khtml-user-select: none; -moz-user-select: none;
|
| 48 |
-
-ms-user-select: none; user-select: none;
|
| 49 |
-
padding: 0 4px; width: 4em;
|
| 50 |
-
}
|
| 51 |
-
pre.numberSource { margin-left: 3em; padding-left: 4px; }
|
| 52 |
-
div.sourceCode
|
| 53 |
-
{ }
|
| 54 |
-
@media screen {
|
| 55 |
-
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
|
| 56 |
-
}
|
| 57 |
-
</style>
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
<script src="site_libs/quarto-nav/quarto-nav.js"></script>
|
| 61 |
-
<script src="site_libs/quarto-nav/headroom.min.js"></script>
|
| 62 |
-
<script src="site_libs/clipboard/clipboard.min.js"></script>
|
| 63 |
-
<script src="site_libs/quarto-search/autocomplete.umd.js"></script>
|
| 64 |
-
<script src="site_libs/quarto-search/fuse.min.js"></script>
|
| 65 |
-
<script src="site_libs/quarto-search/quarto-search.js"></script>
|
| 66 |
-
<meta name="quarto:offset" content="./">
|
| 67 |
-
<link href="./make_negative.html" rel="next">
|
| 68 |
-
<link href="./countsheep.html" rel="prev">
|
| 69 |
-
<script src="site_libs/quarto-html/quarto.js"></script>
|
| 70 |
-
<script src="site_libs/quarto-html/popper.min.js"></script>
|
| 71 |
-
<script src="site_libs/quarto-html/tippy.umd.min.js"></script>
|
| 72 |
-
<script src="site_libs/quarto-html/anchor.min.js"></script>
|
| 73 |
-
<link href="site_libs/quarto-html/tippy.css" rel="stylesheet">
|
| 74 |
-
<link href="site_libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
|
| 75 |
-
<script src="site_libs/bootstrap/bootstrap.min.js"></script>
|
| 76 |
-
<link href="site_libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
|
| 77 |
-
<link href="site_libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">
|
| 78 |
-
<link href="site_libs/quarto-contrib/badge/badge.css" rel="stylesheet">
|
| 79 |
-
<script id="quarto-search-options" type="application/json">{
|
| 80 |
-
"location": "sidebar",
|
| 81 |
-
"copy-button": false,
|
| 82 |
-
"collapse-after": 3,
|
| 83 |
-
"panel-placement": "start",
|
| 84 |
-
"type": "textbox",
|
| 85 |
-
"limit": 20,
|
| 86 |
-
"language": {
|
| 87 |
-
"search-no-results-text": "No results",
|
| 88 |
-
"search-matching-documents-text": "matching documents",
|
| 89 |
-
"search-copy-link-title": "Copy link to search",
|
| 90 |
-
"search-hide-matches-text": "Hide additional matches",
|
| 91 |
-
"search-more-match-text": "more match in this document",
|
| 92 |
-
"search-more-matches-text": "more matches in this document",
|
| 93 |
-
"search-clear-button-title": "Clear",
|
| 94 |
-
"search-detached-cancel-button-title": "Cancel",
|
| 95 |
-
"search-submit-button-title": "Submit",
|
| 96 |
-
"search-label": "Search"
|
| 97 |
-
}
|
| 98 |
-
}</script>
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
</head>
|
| 102 |
-
|
| 103 |
-
<body class="nav-sidebar floating">
|
| 104 |
-
|
| 105 |
-
<div id="quarto-search-results"></div>
|
| 106 |
-
<header id="quarto-header" class="headroom fixed-top">
|
| 107 |
-
<nav class="quarto-secondary-nav">
|
| 108 |
-
<div class="container-fluid d-flex">
|
| 109 |
-
<button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
|
| 110 |
-
<i class="bi bi-layout-text-sidebar-reverse"></i>
|
| 111 |
-
</button>
|
| 112 |
-
<nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="./reducegrow.html"><span class="chapter-number">4</span> <span class="chapter-title">Beginner - Reduce but Grow</span></a></li></ol></nav>
|
| 113 |
-
<a class="flex-grow-1" role="button" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
|
| 114 |
-
</a>
|
| 115 |
-
<button type="button" class="btn quarto-search-button" aria-label="" onclick="window.quartoOpenSearch();">
|
| 116 |
-
<i class="bi bi-search"></i>
|
| 117 |
-
</button>
|
| 118 |
-
</div>
|
| 119 |
-
</nav>
|
| 120 |
-
</header>
|
| 121 |
-
<!-- content -->
|
| 122 |
-
<div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article">
|
| 123 |
-
<!-- sidebar -->
|
| 124 |
-
<nav id="quarto-sidebar" class="sidebar collapse collapse-horizontal sidebar-navigation floating overflow-auto">
|
| 125 |
-
<div class="pt-lg-2 mt-2 text-left sidebar-header">
|
| 126 |
-
<div class="sidebar-title mb-0 py-0">
|
| 127 |
-
<a href="./">Codewars Challenge 2024 Menggunakan R dan RStudio</a>
|
| 128 |
-
</div>
|
| 129 |
-
</div>
|
| 130 |
-
<div class="mt-2 flex-shrink-0 align-items-center">
|
| 131 |
-
<div class="sidebar-search">
|
| 132 |
-
<div id="quarto-search" class="" title="Search"></div>
|
| 133 |
-
</div>
|
| 134 |
-
</div>
|
| 135 |
-
<div class="sidebar-menu-container">
|
| 136 |
-
<ul class="list-unstyled mt-1">
|
| 137 |
-
<li class="sidebar-item">
|
| 138 |
-
<div class="sidebar-item-container">
|
| 139 |
-
<a href="./index.html" class="sidebar-item-text sidebar-link">
|
| 140 |
-
<span class="menu-text">Pengantar</span></a>
|
| 141 |
-
</div>
|
| 142 |
-
</li>
|
| 143 |
-
<li class="sidebar-item">
|
| 144 |
-
<div class="sidebar-item-container">
|
| 145 |
-
<a href="./evenodd.html" class="sidebar-item-text sidebar-link">
|
| 146 |
-
<span class="menu-text"><span class="chapter-number">1</span> <span class="chapter-title">Even or Odd</span></span></a>
|
| 147 |
-
</div>
|
| 148 |
-
</li>
|
| 149 |
-
<li class="sidebar-item">
|
| 150 |
-
<div class="sidebar-item-container">
|
| 151 |
-
<a href="./multiply.html" class="sidebar-item-text sidebar-link">
|
| 152 |
-
<span class="menu-text"><span class="chapter-number">2</span> <span class="chapter-title">Multiply</span></span></a>
|
| 153 |
-
</div>
|
| 154 |
-
</li>
|
| 155 |
-
<li class="sidebar-item">
|
| 156 |
-
<div class="sidebar-item-container">
|
| 157 |
-
<a href="./countsheep.html" class="sidebar-item-text sidebar-link">
|
| 158 |
-
<span class="menu-text"><span class="chapter-number">3</span> <span class="chapter-title">If you can’t sleep, just count sheep!!</span></span></a>
|
| 159 |
-
</div>
|
| 160 |
-
</li>
|
| 161 |
-
<li class="sidebar-item">
|
| 162 |
-
<div class="sidebar-item-container">
|
| 163 |
-
<a href="./reducegrow.html" class="sidebar-item-text sidebar-link active">
|
| 164 |
-
<span class="menu-text"><span class="chapter-number">4</span> <span class="chapter-title">Beginner - Reduce but Grow</span></span></a>
|
| 165 |
-
</div>
|
| 166 |
-
</li>
|
| 167 |
-
<li class="sidebar-item">
|
| 168 |
-
<div class="sidebar-item-container">
|
| 169 |
-
<a href="./make_negative.html" class="sidebar-item-text sidebar-link">
|
| 170 |
-
<span class="menu-text"><span class="chapter-number">5</span> <span class="chapter-title">Return Negative</span></span></a>
|
| 171 |
-
</div>
|
| 172 |
-
</li>
|
| 173 |
-
<li class="sidebar-item">
|
| 174 |
-
<div class="sidebar-item-container">
|
| 175 |
-
<a href="./positive_sum.html" class="sidebar-item-text sidebar-link">
|
| 176 |
-
<span class="menu-text"><span class="chapter-number">6</span> <span class="chapter-title">Sum of positive</span></span></a>
|
| 177 |
-
</div>
|
| 178 |
-
</li>
|
| 179 |
-
<li class="sidebar-item">
|
| 180 |
-
<div class="sidebar-item-container">
|
| 181 |
-
<a href="./references.html" class="sidebar-item-text sidebar-link">
|
| 182 |
-
<span class="menu-text">References</span></a>
|
| 183 |
-
</div>
|
| 184 |
-
</li>
|
| 185 |
-
</ul>
|
| 186 |
-
</div>
|
| 187 |
-
</nav>
|
| 188 |
-
<div id="quarto-sidebar-glass" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass"></div>
|
| 189 |
-
<!-- margin-sidebar -->
|
| 190 |
-
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
|
| 191 |
-
<nav id="TOC" role="doc-toc" class="toc-active">
|
| 192 |
-
<h2 id="toc-title">Table of contents</h2>
|
| 193 |
-
|
| 194 |
-
<ul>
|
| 195 |
-
<li><a href="#instruction" id="toc-instruction" class="nav-link active" data-scroll-target="#instruction"><span class="header-section-number">4.1</span> Instruction</a></li>
|
| 196 |
-
<li><a href="#youtube-video" id="toc-youtube-video" class="nav-link" data-scroll-target="#youtube-video"><span class="header-section-number">4.2</span> YouTube Video</a></li>
|
| 197 |
-
<li><a href="#solution-code" id="toc-solution-code" class="nav-link" data-scroll-target="#solution-code"><span class="header-section-number">4.3</span> Solution Code</a></li>
|
| 198 |
-
<li><a href="#test" id="toc-test" class="nav-link" data-scroll-target="#test"><span class="header-section-number">4.4</span> Test</a></li>
|
| 199 |
-
<li><a href="#supported-by" id="toc-supported-by" class="nav-link" data-scroll-target="#supported-by"><span class="header-section-number">4.5</span> Supported by</a></li>
|
| 200 |
-
</ul>
|
| 201 |
-
</nav>
|
| 202 |
-
</div>
|
| 203 |
-
<!-- main -->
|
| 204 |
-
<main class="content" id="quarto-document-content">
|
| 205 |
-
|
| 206 |
-
<header id="title-block-header" class="quarto-title-block default">
|
| 207 |
-
<div class="quarto-title">
|
| 208 |
-
<h1 class="title"><span id="reducegrow" class="quarto-section-identifier"><span class="chapter-number">4</span> <span class="chapter-title">Beginner - Reduce but Grow</span></span></h1>
|
| 209 |
-
</div>
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
<div class="quarto-title-meta">
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
</div>
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
</header>
|
| 222 |
-
|
| 223 |
-
<p>Tantangan #4/366 - 15 Feb 2024</p>
|
| 224 |
-
<p><a href="https://www.codewars.com/kata/57f780909f7e8e3183000078/train/r" class="uri">https://www.codewars.com/kata/57f780909f7e8e3183000078/train/r</a></p>
|
| 225 |
-
<p><span class="badge rounded-pill quarto-badge " style="background-color: grey;">8kyu</span> Beginner - Reduce but Grow</p>
|
| 226 |
-
<section id="instruction" class="level2" data-number="4.1">
|
| 227 |
-
<h2 data-number="4.1" class="anchored" data-anchor-id="instruction"><span class="header-section-number">4.1</span> Instruction</h2>
|
| 228 |
-
<p>Given a non-empty array of integers, return the result of multiplying the values together in order. Example:</p>
|
| 229 |
-
<pre><code>[1, 2, 3, 4] => 1 * 2 * 3 * 4 = 24</code></pre>
|
| 230 |
-
</section>
|
| 231 |
-
<section id="youtube-video" class="level2" data-number="4.2">
|
| 232 |
-
<h2 data-number="4.2" class="anchored" data-anchor-id="youtube-video"><span class="header-section-number">4.2</span> YouTube Video</h2>
|
| 233 |
-
<div class="quarto-video ratio ratio-16x9"><iframe data-external="1" src="https://www.youtube.com/embed/xCvHwR52p4k?si=yoLfpHfcIBYk0j9c" title="" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe></div>
|
| 234 |
-
</section>
|
| 235 |
-
<section id="solution-code" class="level2" data-number="4.3">
|
| 236 |
-
<h2 data-number="4.3" class="anchored" data-anchor-id="solution-code"><span class="header-section-number">4.3</span> Solution Code</h2>
|
| 237 |
-
<p>Solusi bar-bar</p>
|
| 238 |
-
<div class="cell">
|
| 239 |
-
<div class="sourceCode cell-code" id="cb2"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>grow <span class="ot"><-</span> <span class="cf">function</span>(arr) {</span>
|
| 240 |
-
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> result <span class="ot"><-</span> <span class="dv">1</span></span>
|
| 241 |
-
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a> <span class="cf">for</span>(i <span class="cf">in</span> arr){</span>
|
| 242 |
-
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a> result <span class="ot"><-</span> result <span class="sc">*</span> i</span>
|
| 243 |
-
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a> }</span>
|
| 244 |
-
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">return</span>(result)</span>
|
| 245 |
-
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 246 |
-
</div>
|
| 247 |
-
<p>Solusi simple</p>
|
| 248 |
-
<div class="cell">
|
| 249 |
-
<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="co"># grow <- function(arr) prod(arr)</span></span>
|
| 250 |
-
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a>grow <span class="ot"><-</span> prod</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 251 |
-
</div>
|
| 252 |
-
</section>
|
| 253 |
-
<section id="test" class="level2" data-number="4.4">
|
| 254 |
-
<h2 data-number="4.4" class="anchored" data-anchor-id="test"><span class="header-section-number">4.4</span> Test</h2>
|
| 255 |
-
<div class="cell">
|
| 256 |
-
<div class="sourceCode cell-code" id="cb4"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(testthat)</span>
|
| 257 |
-
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="fu">test_that</span>(<span class="st">"basic tests"</span>, {</span>
|
| 258 |
-
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">expect_equal</span>(<span class="fu">grow</span>(<span class="fu">c</span>(<span class="dv">1</span>, <span class="dv">2</span>, <span class="dv">3</span>)), <span class="dv">6</span>)</span>
|
| 259 |
-
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">expect_equal</span>(<span class="fu">grow</span>(<span class="fu">c</span>(<span class="dv">4</span>, <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">4</span>)), <span class="dv">16</span>)</span>
|
| 260 |
-
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">expect_equal</span>(<span class="fu">grow</span>(<span class="fu">c</span>(<span class="dv">2</span>, <span class="dv">2</span>, <span class="dv">2</span>, <span class="dv">2</span>, <span class="dv">2</span>, <span class="dv">2</span>)), <span class="dv">64</span>)</span>
|
| 261 |
-
<span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a>})</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 262 |
-
<div class="cell-output cell-output-stdout">
|
| 263 |
-
<pre><code>Test passed 🎉</code></pre>
|
| 264 |
-
</div>
|
| 265 |
-
</div>
|
| 266 |
-
</section>
|
| 267 |
-
<section id="supported-by" class="level2" data-number="4.5">
|
| 268 |
-
<h2 data-number="4.5" class="anchored" data-anchor-id="supported-by"><span class="header-section-number">4.5</span> Supported by</h2>
|
| 269 |
-
<div class="quarto-figure quarto-figure-center">
|
| 270 |
-
<figure class="figure">
|
| 271 |
-
<p><a href="https://www.starcore.co"><img src="new_starcore_logo.png" class="img-fluid figure-img"></a></p>
|
| 272 |
-
<figcaption class="figure-caption">StarCore Analytics</figcaption>
|
| 273 |
-
</figure>
|
| 274 |
-
</div>
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
</section>
|
| 278 |
-
|
| 279 |
-
</main> <!-- /main -->
|
| 280 |
-
<script id="quarto-html-after-body" type="application/javascript">
|
| 281 |
-
window.document.addEventListener("DOMContentLoaded", function (event) {
|
| 282 |
-
const toggleBodyColorMode = (bsSheetEl) => {
|
| 283 |
-
const mode = bsSheetEl.getAttribute("data-mode");
|
| 284 |
-
const bodyEl = window.document.querySelector("body");
|
| 285 |
-
if (mode === "dark") {
|
| 286 |
-
bodyEl.classList.add("quarto-dark");
|
| 287 |
-
bodyEl.classList.remove("quarto-light");
|
| 288 |
-
} else {
|
| 289 |
-
bodyEl.classList.add("quarto-light");
|
| 290 |
-
bodyEl.classList.remove("quarto-dark");
|
| 291 |
-
}
|
| 292 |
-
}
|
| 293 |
-
const toggleBodyColorPrimary = () => {
|
| 294 |
-
const bsSheetEl = window.document.querySelector("link#quarto-bootstrap");
|
| 295 |
-
if (bsSheetEl) {
|
| 296 |
-
toggleBodyColorMode(bsSheetEl);
|
| 297 |
-
}
|
| 298 |
-
}
|
| 299 |
-
toggleBodyColorPrimary();
|
| 300 |
-
const icon = "";
|
| 301 |
-
const anchorJS = new window.AnchorJS();
|
| 302 |
-
anchorJS.options = {
|
| 303 |
-
placement: 'right',
|
| 304 |
-
icon: icon
|
| 305 |
-
};
|
| 306 |
-
anchorJS.add('.anchored');
|
| 307 |
-
const isCodeAnnotation = (el) => {
|
| 308 |
-
for (const clz of el.classList) {
|
| 309 |
-
if (clz.startsWith('code-annotation-')) {
|
| 310 |
-
return true;
|
| 311 |
-
}
|
| 312 |
-
}
|
| 313 |
-
return false;
|
| 314 |
-
}
|
| 315 |
-
const clipboard = new window.ClipboardJS('.code-copy-button', {
|
| 316 |
-
text: function(trigger) {
|
| 317 |
-
const codeEl = trigger.previousElementSibling.cloneNode(true);
|
| 318 |
-
for (const childEl of codeEl.children) {
|
| 319 |
-
if (isCodeAnnotation(childEl)) {
|
| 320 |
-
childEl.remove();
|
| 321 |
-
}
|
| 322 |
-
}
|
| 323 |
-
return codeEl.innerText;
|
| 324 |
-
}
|
| 325 |
-
});
|
| 326 |
-
clipboard.on('success', function(e) {
|
| 327 |
-
// button target
|
| 328 |
-
const button = e.trigger;
|
| 329 |
-
// don't keep focus
|
| 330 |
-
button.blur();
|
| 331 |
-
// flash "checked"
|
| 332 |
-
button.classList.add('code-copy-button-checked');
|
| 333 |
-
var currentTitle = button.getAttribute("title");
|
| 334 |
-
button.setAttribute("title", "Copied!");
|
| 335 |
-
let tooltip;
|
| 336 |
-
if (window.bootstrap) {
|
| 337 |
-
button.setAttribute("data-bs-toggle", "tooltip");
|
| 338 |
-
button.setAttribute("data-bs-placement", "left");
|
| 339 |
-
button.setAttribute("data-bs-title", "Copied!");
|
| 340 |
-
tooltip = new bootstrap.Tooltip(button,
|
| 341 |
-
{ trigger: "manual",
|
| 342 |
-
customClass: "code-copy-button-tooltip",
|
| 343 |
-
offset: [0, -8]});
|
| 344 |
-
tooltip.show();
|
| 345 |
-
}
|
| 346 |
-
setTimeout(function() {
|
| 347 |
-
if (tooltip) {
|
| 348 |
-
tooltip.hide();
|
| 349 |
-
button.removeAttribute("data-bs-title");
|
| 350 |
-
button.removeAttribute("data-bs-toggle");
|
| 351 |
-
button.removeAttribute("data-bs-placement");
|
| 352 |
-
}
|
| 353 |
-
button.setAttribute("title", currentTitle);
|
| 354 |
-
button.classList.remove('code-copy-button-checked');
|
| 355 |
-
}, 1000);
|
| 356 |
-
// clear code selection
|
| 357 |
-
e.clearSelection();
|
| 358 |
-
});
|
| 359 |
-
function tippyHover(el, contentFn) {
|
| 360 |
-
const config = {
|
| 361 |
-
allowHTML: true,
|
| 362 |
-
content: contentFn,
|
| 363 |
-
maxWidth: 500,
|
| 364 |
-
delay: 100,
|
| 365 |
-
arrow: false,
|
| 366 |
-
appendTo: function(el) {
|
| 367 |
-
return el.parentElement;
|
| 368 |
-
},
|
| 369 |
-
interactive: true,
|
| 370 |
-
interactiveBorder: 10,
|
| 371 |
-
theme: 'quarto',
|
| 372 |
-
placement: 'bottom-start'
|
| 373 |
-
};
|
| 374 |
-
window.tippy(el, config);
|
| 375 |
-
}
|
| 376 |
-
const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
|
| 377 |
-
for (var i=0; i<noterefs.length; i++) {
|
| 378 |
-
const ref = noterefs[i];
|
| 379 |
-
tippyHover(ref, function() {
|
| 380 |
-
// use id or data attribute instead here
|
| 381 |
-
let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
|
| 382 |
-
try { href = new URL(href).hash; } catch {}
|
| 383 |
-
const id = href.replace(/^#\/?/, "");
|
| 384 |
-
const note = window.document.getElementById(id);
|
| 385 |
-
return note.innerHTML;
|
| 386 |
-
});
|
| 387 |
-
}
|
| 388 |
-
let selectedAnnoteEl;
|
| 389 |
-
const selectorForAnnotation = ( cell, annotation) => {
|
| 390 |
-
let cellAttr = 'data-code-cell="' + cell + '"';
|
| 391 |
-
let lineAttr = 'data-code-annotation="' + annotation + '"';
|
| 392 |
-
const selector = 'span[' + cellAttr + '][' + lineAttr + ']';
|
| 393 |
-
return selector;
|
| 394 |
-
}
|
| 395 |
-
const selectCodeLines = (annoteEl) => {
|
| 396 |
-
const doc = window.document;
|
| 397 |
-
const targetCell = annoteEl.getAttribute("data-target-cell");
|
| 398 |
-
const targetAnnotation = annoteEl.getAttribute("data-target-annotation");
|
| 399 |
-
const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation));
|
| 400 |
-
const lines = annoteSpan.getAttribute("data-code-lines").split(",");
|
| 401 |
-
const lineIds = lines.map((line) => {
|
| 402 |
-
return targetCell + "-" + line;
|
| 403 |
-
})
|
| 404 |
-
let top = null;
|
| 405 |
-
let height = null;
|
| 406 |
-
let parent = null;
|
| 407 |
-
if (lineIds.length > 0) {
|
| 408 |
-
//compute the position of the single el (top and bottom and make a div)
|
| 409 |
-
const el = window.document.getElementById(lineIds[0]);
|
| 410 |
-
top = el.offsetTop;
|
| 411 |
-
height = el.offsetHeight;
|
| 412 |
-
parent = el.parentElement.parentElement;
|
| 413 |
-
if (lineIds.length > 1) {
|
| 414 |
-
const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]);
|
| 415 |
-
const bottom = lastEl.offsetTop + lastEl.offsetHeight;
|
| 416 |
-
height = bottom - top;
|
| 417 |
-
}
|
| 418 |
-
if (top !== null && height !== null && parent !== null) {
|
| 419 |
-
// cook up a div (if necessary) and position it
|
| 420 |
-
let div = window.document.getElementById("code-annotation-line-highlight");
|
| 421 |
-
if (div === null) {
|
| 422 |
-
div = window.document.createElement("div");
|
| 423 |
-
div.setAttribute("id", "code-annotation-line-highlight");
|
| 424 |
-
div.style.position = 'absolute';
|
| 425 |
-
parent.appendChild(div);
|
| 426 |
-
}
|
| 427 |
-
div.style.top = top - 2 + "px";
|
| 428 |
-
div.style.height = height + 4 + "px";
|
| 429 |
-
let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter");
|
| 430 |
-
if (gutterDiv === null) {
|
| 431 |
-
gutterDiv = window.document.createElement("div");
|
| 432 |
-
gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter");
|
| 433 |
-
gutterDiv.style.position = 'absolute';
|
| 434 |
-
const codeCell = window.document.getElementById(targetCell);
|
| 435 |
-
const gutter = codeCell.querySelector('.code-annotation-gutter');
|
| 436 |
-
gutter.appendChild(gutterDiv);
|
| 437 |
-
}
|
| 438 |
-
gutterDiv.style.top = top - 2 + "px";
|
| 439 |
-
gutterDiv.style.height = height + 4 + "px";
|
| 440 |
-
}
|
| 441 |
-
selectedAnnoteEl = annoteEl;
|
| 442 |
-
}
|
| 443 |
-
};
|
| 444 |
-
const unselectCodeLines = () => {
|
| 445 |
-
const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"];
|
| 446 |
-
elementsIds.forEach((elId) => {
|
| 447 |
-
const div = window.document.getElementById(elId);
|
| 448 |
-
if (div) {
|
| 449 |
-
div.remove();
|
| 450 |
-
}
|
| 451 |
-
});
|
| 452 |
-
selectedAnnoteEl = undefined;
|
| 453 |
-
};
|
| 454 |
-
// Attach click handler to the DT
|
| 455 |
-
const annoteDls = window.document.querySelectorAll('dt[data-target-cell]');
|
| 456 |
-
for (const annoteDlNode of annoteDls) {
|
| 457 |
-
annoteDlNode.addEventListener('click', (event) => {
|
| 458 |
-
const clickedEl = event.target;
|
| 459 |
-
if (clickedEl !== selectedAnnoteEl) {
|
| 460 |
-
unselectCodeLines();
|
| 461 |
-
const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active');
|
| 462 |
-
if (activeEl) {
|
| 463 |
-
activeEl.classList.remove('code-annotation-active');
|
| 464 |
-
}
|
| 465 |
-
selectCodeLines(clickedEl);
|
| 466 |
-
clickedEl.classList.add('code-annotation-active');
|
| 467 |
-
} else {
|
| 468 |
-
// Unselect the line
|
| 469 |
-
unselectCodeLines();
|
| 470 |
-
clickedEl.classList.remove('code-annotation-active');
|
| 471 |
-
}
|
| 472 |
-
});
|
| 473 |
-
}
|
| 474 |
-
const findCites = (el) => {
|
| 475 |
-
const parentEl = el.parentElement;
|
| 476 |
-
if (parentEl) {
|
| 477 |
-
const cites = parentEl.dataset.cites;
|
| 478 |
-
if (cites) {
|
| 479 |
-
return {
|
| 480 |
-
el,
|
| 481 |
-
cites: cites.split(' ')
|
| 482 |
-
};
|
| 483 |
-
} else {
|
| 484 |
-
return findCites(el.parentElement)
|
| 485 |
-
}
|
| 486 |
-
} else {
|
| 487 |
-
return undefined;
|
| 488 |
-
}
|
| 489 |
-
};
|
| 490 |
-
var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
|
| 491 |
-
for (var i=0; i<bibliorefs.length; i++) {
|
| 492 |
-
const ref = bibliorefs[i];
|
| 493 |
-
const citeInfo = findCites(ref);
|
| 494 |
-
if (citeInfo) {
|
| 495 |
-
tippyHover(citeInfo.el, function() {
|
| 496 |
-
var popup = window.document.createElement('div');
|
| 497 |
-
citeInfo.cites.forEach(function(cite) {
|
| 498 |
-
var citeDiv = window.document.createElement('div');
|
| 499 |
-
citeDiv.classList.add('hanging-indent');
|
| 500 |
-
citeDiv.classList.add('csl-entry');
|
| 501 |
-
var biblioDiv = window.document.getElementById('ref-' + cite);
|
| 502 |
-
if (biblioDiv) {
|
| 503 |
-
citeDiv.innerHTML = biblioDiv.innerHTML;
|
| 504 |
-
}
|
| 505 |
-
popup.appendChild(citeDiv);
|
| 506 |
-
});
|
| 507 |
-
return popup.innerHTML;
|
| 508 |
-
});
|
| 509 |
-
}
|
| 510 |
-
}
|
| 511 |
-
});
|
| 512 |
-
</script>
|
| 513 |
-
<nav class="page-navigation">
|
| 514 |
-
<div class="nav-page nav-page-previous">
|
| 515 |
-
<a href="./countsheep.html" class="pagination-link">
|
| 516 |
-
<i class="bi bi-arrow-left-short"></i> <span class="nav-page-text"><span class="chapter-number">3</span> <span class="chapter-title">If you can’t sleep, just count sheep!!</span></span>
|
| 517 |
-
</a>
|
| 518 |
-
</div>
|
| 519 |
-
<div class="nav-page nav-page-next">
|
| 520 |
-
<a href="./make_negative.html" class="pagination-link">
|
| 521 |
-
<span class="nav-page-text"><span class="chapter-number">5</span> <span class="chapter-title">Return Negative</span></span> <i class="b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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
references.html
DELETED
|
@@ -1,449 +0,0 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
|
| 3 |
-
|
| 4 |
-
<meta charset="utf-8">
|
| 5 |
-
<meta name="generator" content="quarto-1.3.433">
|
| 6 |
-
|
| 7 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
<title>Codewars Challenge 2024 Menggunakan R dan RStudio - References</title>
|
| 11 |
-
<style>
|
| 12 |
-
code{white-space: pre-wrap;}
|
| 13 |
-
span.smallcaps{font-variant: small-caps;}
|
| 14 |
-
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
| 15 |
-
div.column{flex: auto; overflow-x: auto;}
|
| 16 |
-
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
| 17 |
-
ul.task-list{list-style: none;}
|
| 18 |
-
ul.task-list li input[type="checkbox"] {
|
| 19 |
-
width: 0.8em;
|
| 20 |
-
margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
|
| 21 |
-
vertical-align: middle;
|
| 22 |
-
}
|
| 23 |
-
/* CSS for citations */
|
| 24 |
-
div.csl-bib-body { }
|
| 25 |
-
div.csl-entry {
|
| 26 |
-
clear: both;
|
| 27 |
-
}
|
| 28 |
-
.hanging-indent div.csl-entry {
|
| 29 |
-
margin-left:2em;
|
| 30 |
-
text-indent:-2em;
|
| 31 |
-
}
|
| 32 |
-
div.csl-left-margin {
|
| 33 |
-
min-width:2em;
|
| 34 |
-
float:left;
|
| 35 |
-
}
|
| 36 |
-
div.csl-right-inline {
|
| 37 |
-
margin-left:2em;
|
| 38 |
-
padding-left:1em;
|
| 39 |
-
}
|
| 40 |
-
div.csl-indent {
|
| 41 |
-
margin-left: 2em;
|
| 42 |
-
}</style>
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
<script src="site_libs/quarto-nav/quarto-nav.js"></script>
|
| 46 |
-
<script src="site_libs/quarto-nav/headroom.min.js"></script>
|
| 47 |
-
<script src="site_libs/clipboard/clipboard.min.js"></script>
|
| 48 |
-
<script src="site_libs/quarto-search/autocomplete.umd.js"></script>
|
| 49 |
-
<script src="site_libs/quarto-search/fuse.min.js"></script>
|
| 50 |
-
<script src="site_libs/quarto-search/quarto-search.js"></script>
|
| 51 |
-
<meta name="quarto:offset" content="./">
|
| 52 |
-
<link href="./positive_sum.html" rel="prev">
|
| 53 |
-
<script src="site_libs/quarto-html/quarto.js"></script>
|
| 54 |
-
<script src="site_libs/quarto-html/popper.min.js"></script>
|
| 55 |
-
<script src="site_libs/quarto-html/tippy.umd.min.js"></script>
|
| 56 |
-
<script src="site_libs/quarto-html/anchor.min.js"></script>
|
| 57 |
-
<link href="site_libs/quarto-html/tippy.css" rel="stylesheet">
|
| 58 |
-
<link href="site_libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
|
| 59 |
-
<script src="site_libs/bootstrap/bootstrap.min.js"></script>
|
| 60 |
-
<link href="site_libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
|
| 61 |
-
<link href="site_libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">
|
| 62 |
-
<script id="quarto-search-options" type="application/json">{
|
| 63 |
-
"location": "sidebar",
|
| 64 |
-
"copy-button": false,
|
| 65 |
-
"collapse-after": 3,
|
| 66 |
-
"panel-placement": "start",
|
| 67 |
-
"type": "textbox",
|
| 68 |
-
"limit": 20,
|
| 69 |
-
"language": {
|
| 70 |
-
"search-no-results-text": "No results",
|
| 71 |
-
"search-matching-documents-text": "matching documents",
|
| 72 |
-
"search-copy-link-title": "Copy link to search",
|
| 73 |
-
"search-hide-matches-text": "Hide additional matches",
|
| 74 |
-
"search-more-match-text": "more match in this document",
|
| 75 |
-
"search-more-matches-text": "more matches in this document",
|
| 76 |
-
"search-clear-button-title": "Clear",
|
| 77 |
-
"search-detached-cancel-button-title": "Cancel",
|
| 78 |
-
"search-submit-button-title": "Submit",
|
| 79 |
-
"search-label": "Search"
|
| 80 |
-
}
|
| 81 |
-
}</script>
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
</head>
|
| 85 |
-
|
| 86 |
-
<body class="nav-sidebar floating">
|
| 87 |
-
|
| 88 |
-
<div id="quarto-search-results"></div>
|
| 89 |
-
<header id="quarto-header" class="headroom fixed-top">
|
| 90 |
-
<nav class="quarto-secondary-nav">
|
| 91 |
-
<div class="container-fluid d-flex">
|
| 92 |
-
<button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
|
| 93 |
-
<i class="bi bi-layout-text-sidebar-reverse"></i>
|
| 94 |
-
</button>
|
| 95 |
-
<nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="./references.html">References</a></li></ol></nav>
|
| 96 |
-
<a class="flex-grow-1" role="button" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
|
| 97 |
-
</a>
|
| 98 |
-
<button type="button" class="btn quarto-search-button" aria-label="" onclick="window.quartoOpenSearch();">
|
| 99 |
-
<i class="bi bi-search"></i>
|
| 100 |
-
</button>
|
| 101 |
-
</div>
|
| 102 |
-
</nav>
|
| 103 |
-
</header>
|
| 104 |
-
<!-- content -->
|
| 105 |
-
<div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article">
|
| 106 |
-
<!-- sidebar -->
|
| 107 |
-
<nav id="quarto-sidebar" class="sidebar collapse collapse-horizontal sidebar-navigation floating overflow-auto">
|
| 108 |
-
<div class="pt-lg-2 mt-2 text-left sidebar-header">
|
| 109 |
-
<div class="sidebar-title mb-0 py-0">
|
| 110 |
-
<a href="./">Codewars Challenge 2024 Menggunakan R dan RStudio</a>
|
| 111 |
-
</div>
|
| 112 |
-
</div>
|
| 113 |
-
<div class="mt-2 flex-shrink-0 align-items-center">
|
| 114 |
-
<div class="sidebar-search">
|
| 115 |
-
<div id="quarto-search" class="" title="Search"></div>
|
| 116 |
-
</div>
|
| 117 |
-
</div>
|
| 118 |
-
<div class="sidebar-menu-container">
|
| 119 |
-
<ul class="list-unstyled mt-1">
|
| 120 |
-
<li class="sidebar-item">
|
| 121 |
-
<div class="sidebar-item-container">
|
| 122 |
-
<a href="./index.html" class="sidebar-item-text sidebar-link">
|
| 123 |
-
<span class="menu-text">Pengantar</span></a>
|
| 124 |
-
</div>
|
| 125 |
-
</li>
|
| 126 |
-
<li class="sidebar-item">
|
| 127 |
-
<div class="sidebar-item-container">
|
| 128 |
-
<a href="./evenodd.html" class="sidebar-item-text sidebar-link">
|
| 129 |
-
<span class="menu-text"><span class="chapter-number">1</span> <span class="chapter-title">Even or Odd</span></span></a>
|
| 130 |
-
</div>
|
| 131 |
-
</li>
|
| 132 |
-
<li class="sidebar-item">
|
| 133 |
-
<div class="sidebar-item-container">
|
| 134 |
-
<a href="./multiply.html" class="sidebar-item-text sidebar-link">
|
| 135 |
-
<span class="menu-text"><span class="chapter-number">2</span> <span class="chapter-title">Multiply</span></span></a>
|
| 136 |
-
</div>
|
| 137 |
-
</li>
|
| 138 |
-
<li class="sidebar-item">
|
| 139 |
-
<div class="sidebar-item-container">
|
| 140 |
-
<a href="./countsheep.html" class="sidebar-item-text sidebar-link">
|
| 141 |
-
<span class="menu-text"><span class="chapter-number">3</span> <span class="chapter-title">If you can’t sleep, just count sheep!!</span></span></a>
|
| 142 |
-
</div>
|
| 143 |
-
</li>
|
| 144 |
-
<li class="sidebar-item">
|
| 145 |
-
<div class="sidebar-item-container">
|
| 146 |
-
<a href="./reducegrow.html" class="sidebar-item-text sidebar-link">
|
| 147 |
-
<span class="menu-text"><span class="chapter-number">4</span> <span class="chapter-title">Beginner - Reduce but Grow</span></span></a>
|
| 148 |
-
</div>
|
| 149 |
-
</li>
|
| 150 |
-
<li class="sidebar-item">
|
| 151 |
-
<div class="sidebar-item-container">
|
| 152 |
-
<a href="./make_negative.html" class="sidebar-item-text sidebar-link">
|
| 153 |
-
<span class="menu-text"><span class="chapter-number">5</span> <span class="chapter-title">Return Negative</span></span></a>
|
| 154 |
-
</div>
|
| 155 |
-
</li>
|
| 156 |
-
<li class="sidebar-item">
|
| 157 |
-
<div class="sidebar-item-container">
|
| 158 |
-
<a href="./positive_sum.html" class="sidebar-item-text sidebar-link">
|
| 159 |
-
<span class="menu-text"><span class="chapter-number">6</span> <span class="chapter-title">Sum of positive</span></span></a>
|
| 160 |
-
</div>
|
| 161 |
-
</li>
|
| 162 |
-
<li class="sidebar-item">
|
| 163 |
-
<div class="sidebar-item-container">
|
| 164 |
-
<a href="./references.html" class="sidebar-item-text sidebar-link active">
|
| 165 |
-
<span class="menu-text">References</span></a>
|
| 166 |
-
</div>
|
| 167 |
-
</li>
|
| 168 |
-
</ul>
|
| 169 |
-
</div>
|
| 170 |
-
</nav>
|
| 171 |
-
<div id="quarto-sidebar-glass" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass"></div>
|
| 172 |
-
<!-- margin-sidebar -->
|
| 173 |
-
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
|
| 174 |
-
|
| 175 |
-
</div>
|
| 176 |
-
<!-- main -->
|
| 177 |
-
<main class="content" id="quarto-document-content">
|
| 178 |
-
|
| 179 |
-
<header id="title-block-header" class="quarto-title-block default">
|
| 180 |
-
<div class="quarto-title">
|
| 181 |
-
<h1 class="title">References</h1>
|
| 182 |
-
</div>
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
<div class="quarto-title-meta">
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
</div>
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
</header>
|
| 195 |
-
|
| 196 |
-
<div id="refs" role="list" style="display: none">
|
| 197 |
-
|
| 198 |
-
</div>
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
</main> <!-- /main -->
|
| 203 |
-
<script id="quarto-html-after-body" type="application/javascript">
|
| 204 |
-
window.document.addEventListener("DOMContentLoaded", function (event) {
|
| 205 |
-
const toggleBodyColorMode = (bsSheetEl) => {
|
| 206 |
-
const mode = bsSheetEl.getAttribute("data-mode");
|
| 207 |
-
const bodyEl = window.document.querySelector("body");
|
| 208 |
-
if (mode === "dark") {
|
| 209 |
-
bodyEl.classList.add("quarto-dark");
|
| 210 |
-
bodyEl.classList.remove("quarto-light");
|
| 211 |
-
} else {
|
| 212 |
-
bodyEl.classList.add("quarto-light");
|
| 213 |
-
bodyEl.classList.remove("quarto-dark");
|
| 214 |
-
}
|
| 215 |
-
}
|
| 216 |
-
const toggleBodyColorPrimary = () => {
|
| 217 |
-
const bsSheetEl = window.document.querySelector("link#quarto-bootstrap");
|
| 218 |
-
if (bsSheetEl) {
|
| 219 |
-
toggleBodyColorMode(bsSheetEl);
|
| 220 |
-
}
|
| 221 |
-
}
|
| 222 |
-
toggleBodyColorPrimary();
|
| 223 |
-
const icon = "";
|
| 224 |
-
const anchorJS = new window.AnchorJS();
|
| 225 |
-
anchorJS.options = {
|
| 226 |
-
placement: 'right',
|
| 227 |
-
icon: icon
|
| 228 |
-
};
|
| 229 |
-
anchorJS.add('.anchored');
|
| 230 |
-
const isCodeAnnotation = (el) => {
|
| 231 |
-
for (const clz of el.classList) {
|
| 232 |
-
if (clz.startsWith('code-annotation-')) {
|
| 233 |
-
return true;
|
| 234 |
-
}
|
| 235 |
-
}
|
| 236 |
-
return false;
|
| 237 |
-
}
|
| 238 |
-
const clipboard = new window.ClipboardJS('.code-copy-button', {
|
| 239 |
-
text: function(trigger) {
|
| 240 |
-
const codeEl = trigger.previousElementSibling.cloneNode(true);
|
| 241 |
-
for (const childEl of codeEl.children) {
|
| 242 |
-
if (isCodeAnnotation(childEl)) {
|
| 243 |
-
childEl.remove();
|
| 244 |
-
}
|
| 245 |
-
}
|
| 246 |
-
return codeEl.innerText;
|
| 247 |
-
}
|
| 248 |
-
});
|
| 249 |
-
clipboard.on('success', function(e) {
|
| 250 |
-
// button target
|
| 251 |
-
const button = e.trigger;
|
| 252 |
-
// don't keep focus
|
| 253 |
-
button.blur();
|
| 254 |
-
// flash "checked"
|
| 255 |
-
button.classList.add('code-copy-button-checked');
|
| 256 |
-
var currentTitle = button.getAttribute("title");
|
| 257 |
-
button.setAttribute("title", "Copied!");
|
| 258 |
-
let tooltip;
|
| 259 |
-
if (window.bootstrap) {
|
| 260 |
-
button.setAttribute("data-bs-toggle", "tooltip");
|
| 261 |
-
button.setAttribute("data-bs-placement", "left");
|
| 262 |
-
button.setAttribute("data-bs-title", "Copied!");
|
| 263 |
-
tooltip = new bootstrap.Tooltip(button,
|
| 264 |
-
{ trigger: "manual",
|
| 265 |
-
customClass: "code-copy-button-tooltip",
|
| 266 |
-
offset: [0, -8]});
|
| 267 |
-
tooltip.show();
|
| 268 |
-
}
|
| 269 |
-
setTimeout(function() {
|
| 270 |
-
if (tooltip) {
|
| 271 |
-
tooltip.hide();
|
| 272 |
-
button.removeAttribute("data-bs-title");
|
| 273 |
-
button.removeAttribute("data-bs-toggle");
|
| 274 |
-
button.removeAttribute("data-bs-placement");
|
| 275 |
-
}
|
| 276 |
-
button.setAttribute("title", currentTitle);
|
| 277 |
-
button.classList.remove('code-copy-button-checked');
|
| 278 |
-
}, 1000);
|
| 279 |
-
// clear code selection
|
| 280 |
-
e.clearSelection();
|
| 281 |
-
});
|
| 282 |
-
function tippyHover(el, contentFn) {
|
| 283 |
-
const config = {
|
| 284 |
-
allowHTML: true,
|
| 285 |
-
content: contentFn,
|
| 286 |
-
maxWidth: 500,
|
| 287 |
-
delay: 100,
|
| 288 |
-
arrow: false,
|
| 289 |
-
appendTo: function(el) {
|
| 290 |
-
return el.parentElement;
|
| 291 |
-
},
|
| 292 |
-
interactive: true,
|
| 293 |
-
interactiveBorder: 10,
|
| 294 |
-
theme: 'quarto',
|
| 295 |
-
placement: 'bottom-start'
|
| 296 |
-
};
|
| 297 |
-
window.tippy(el, config);
|
| 298 |
-
}
|
| 299 |
-
const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
|
| 300 |
-
for (var i=0; i<noterefs.length; i++) {
|
| 301 |
-
const ref = noterefs[i];
|
| 302 |
-
tippyHover(ref, function() {
|
| 303 |
-
// use id or data attribute instead here
|
| 304 |
-
let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
|
| 305 |
-
try { href = new URL(href).hash; } catch {}
|
| 306 |
-
const id = href.replace(/^#\/?/, "");
|
| 307 |
-
const note = window.document.getElementById(id);
|
| 308 |
-
return note.innerHTML;
|
| 309 |
-
});
|
| 310 |
-
}
|
| 311 |
-
let selectedAnnoteEl;
|
| 312 |
-
const selectorForAnnotation = ( cell, annotation) => {
|
| 313 |
-
let cellAttr = 'data-code-cell="' + cell + '"';
|
| 314 |
-
let lineAttr = 'data-code-annotation="' + annotation + '"';
|
| 315 |
-
const selector = 'span[' + cellAttr + '][' + lineAttr + ']';
|
| 316 |
-
return selector;
|
| 317 |
-
}
|
| 318 |
-
const selectCodeLines = (annoteEl) => {
|
| 319 |
-
const doc = window.document;
|
| 320 |
-
const targetCell = annoteEl.getAttribute("data-target-cell");
|
| 321 |
-
const targetAnnotation = annoteEl.getAttribute("data-target-annotation");
|
| 322 |
-
const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation));
|
| 323 |
-
const lines = annoteSpan.getAttribute("data-code-lines").split(",");
|
| 324 |
-
const lineIds = lines.map((line) => {
|
| 325 |
-
return targetCell + "-" + line;
|
| 326 |
-
})
|
| 327 |
-
let top = null;
|
| 328 |
-
let height = null;
|
| 329 |
-
let parent = null;
|
| 330 |
-
if (lineIds.length > 0) {
|
| 331 |
-
//compute the position of the single el (top and bottom and make a div)
|
| 332 |
-
const el = window.document.getElementById(lineIds[0]);
|
| 333 |
-
top = el.offsetTop;
|
| 334 |
-
height = el.offsetHeight;
|
| 335 |
-
parent = el.parentElement.parentElement;
|
| 336 |
-
if (lineIds.length > 1) {
|
| 337 |
-
const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]);
|
| 338 |
-
const bottom = lastEl.offsetTop + lastEl.offsetHeight;
|
| 339 |
-
height = bottom - top;
|
| 340 |
-
}
|
| 341 |
-
if (top !== null && height !== null && parent !== null) {
|
| 342 |
-
// cook up a div (if necessary) and position it
|
| 343 |
-
let div = window.document.getElementById("code-annotation-line-highlight");
|
| 344 |
-
if (div === null) {
|
| 345 |
-
div = window.document.createElement("div");
|
| 346 |
-
div.setAttribute("id", "code-annotation-line-highlight");
|
| 347 |
-
div.style.position = 'absolute';
|
| 348 |
-
parent.appendChild(div);
|
| 349 |
-
}
|
| 350 |
-
div.style.top = top - 2 + "px";
|
| 351 |
-
div.style.height = height + 4 + "px";
|
| 352 |
-
let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter");
|
| 353 |
-
if (gutterDiv === null) {
|
| 354 |
-
gutterDiv = window.document.createElement("div");
|
| 355 |
-
gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter");
|
| 356 |
-
gutterDiv.style.position = 'absolute';
|
| 357 |
-
const codeCell = window.document.getElementById(targetCell);
|
| 358 |
-
const gutter = codeCell.querySelector('.code-annotation-gutter');
|
| 359 |
-
gutter.appendChild(gutterDiv);
|
| 360 |
-
}
|
| 361 |
-
gutterDiv.style.top = top - 2 + "px";
|
| 362 |
-
gutterDiv.style.height = height + 4 + "px";
|
| 363 |
-
}
|
| 364 |
-
selectedAnnoteEl = annoteEl;
|
| 365 |
-
}
|
| 366 |
-
};
|
| 367 |
-
const unselectCodeLines = () => {
|
| 368 |
-
const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"];
|
| 369 |
-
elementsIds.forEach((elId) => {
|
| 370 |
-
const div = window.document.getElementById(elId);
|
| 371 |
-
if (div) {
|
| 372 |
-
div.remove();
|
| 373 |
-
}
|
| 374 |
-
});
|
| 375 |
-
selectedAnnoteEl = undefined;
|
| 376 |
-
};
|
| 377 |
-
// Attach click handler to the DT
|
| 378 |
-
const annoteDls = window.document.querySelectorAll('dt[data-target-cell]');
|
| 379 |
-
for (const annoteDlNode of annoteDls) {
|
| 380 |
-
annoteDlNode.addEventListener('click', (event) => {
|
| 381 |
-
const clickedEl = event.target;
|
| 382 |
-
if (clickedEl !== selectedAnnoteEl) {
|
| 383 |
-
unselectCodeLines();
|
| 384 |
-
const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active');
|
| 385 |
-
if (activeEl) {
|
| 386 |
-
activeEl.classList.remove('code-annotation-active');
|
| 387 |
-
}
|
| 388 |
-
selectCodeLines(clickedEl);
|
| 389 |
-
clickedEl.classList.add('code-annotation-active');
|
| 390 |
-
} else {
|
| 391 |
-
// Unselect the line
|
| 392 |
-
unselectCodeLines();
|
| 393 |
-
clickedEl.classList.remove('code-annotation-active');
|
| 394 |
-
}
|
| 395 |
-
});
|
| 396 |
-
}
|
| 397 |
-
const findCites = (el) => {
|
| 398 |
-
const parentEl = el.parentElement;
|
| 399 |
-
if (parentEl) {
|
| 400 |
-
const cites = parentEl.dataset.cites;
|
| 401 |
-
if (cites) {
|
| 402 |
-
return {
|
| 403 |
-
el,
|
| 404 |
-
cites: cites.split(' ')
|
| 405 |
-
};
|
| 406 |
-
} else {
|
| 407 |
-
return findCites(el.parentElement)
|
| 408 |
-
}
|
| 409 |
-
} else {
|
| 410 |
-
return undefined;
|
| 411 |
-
}
|
| 412 |
-
};
|
| 413 |
-
var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
|
| 414 |
-
for (var i=0; i<bibliorefs.length; i++) {
|
| 415 |
-
const ref = bibliorefs[i];
|
| 416 |
-
const citeInfo = findCites(ref);
|
| 417 |
-
if (citeInfo) {
|
| 418 |
-
tippyHover(citeInfo.el, function() {
|
| 419 |
-
var popup = window.document.createElement('div');
|
| 420 |
-
citeInfo.cites.forEach(function(cite) {
|
| 421 |
-
var citeDiv = window.document.createElement('div');
|
| 422 |
-
citeDiv.classList.add('hanging-indent');
|
| 423 |
-
citeDiv.classList.add('csl-entry');
|
| 424 |
-
var biblioDiv = window.document.getElementById('ref-' + cite);
|
| 425 |
-
if (biblioDiv) {
|
| 426 |
-
citeDiv.innerHTML = biblioDiv.innerHTML;
|
| 427 |
-
}
|
| 428 |
-
popup.appendChild(citeDiv);
|
| 429 |
-
});
|
| 430 |
-
return popup.innerHTML;
|
| 431 |
-
});
|
| 432 |
-
}
|
| 433 |
-
}
|
| 434 |
-
});
|
| 435 |
-
</script>
|
| 436 |
-
<nav class="page-navigation">
|
| 437 |
-
<div class="nav-page nav-page-previous">
|
| 438 |
-
<a href="./positive_sum.html" class="pagination-link">
|
| 439 |
-
<i class="bi bi-arrow-left-short"></i> <span class="nav-page-text"><span class="chapter-number">6</span> <span class="chapter-title">Sum of positive</span></span>
|
| 440 |
-
</a>
|
| 441 |
-
</div>
|
| 442 |
-
<div class="nav-page nav-page-next">
|
| 443 |
-
</div>
|
| 444 |
-
</nav>
|
| 445 |
-
</div> <!-- /content -->
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
</body></html>
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
summary.html
DELETED
|
@@ -1,448 +0,0 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
|
| 3 |
-
|
| 4 |
-
<meta charset="utf-8">
|
| 5 |
-
<meta name="generator" content="quarto-1.3.433">
|
| 6 |
-
|
| 7 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
<title>Codewars Using R and RStudio - 2 Summary</title>
|
| 11 |
-
<style>
|
| 12 |
-
code{white-space: pre-wrap;}
|
| 13 |
-
span.smallcaps{font-variant: small-caps;}
|
| 14 |
-
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
| 15 |
-
div.column{flex: auto; overflow-x: auto;}
|
| 16 |
-
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
| 17 |
-
ul.task-list{list-style: none;}
|
| 18 |
-
ul.task-list li input[type="checkbox"] {
|
| 19 |
-
width: 0.8em;
|
| 20 |
-
margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
|
| 21 |
-
vertical-align: middle;
|
| 22 |
-
}
|
| 23 |
-
/* CSS for syntax highlighting */
|
| 24 |
-
pre > code.sourceCode { white-space: pre; position: relative; }
|
| 25 |
-
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
|
| 26 |
-
pre > code.sourceCode > span:empty { height: 1.2em; }
|
| 27 |
-
.sourceCode { overflow: visible; }
|
| 28 |
-
code.sourceCode > span { color: inherit; text-decoration: inherit; }
|
| 29 |
-
div.sourceCode { margin: 1em 0; }
|
| 30 |
-
pre.sourceCode { margin: 0; }
|
| 31 |
-
@media screen {
|
| 32 |
-
div.sourceCode { overflow: auto; }
|
| 33 |
-
}
|
| 34 |
-
@media print {
|
| 35 |
-
pre > code.sourceCode { white-space: pre-wrap; }
|
| 36 |
-
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
|
| 37 |
-
}
|
| 38 |
-
pre.numberSource code
|
| 39 |
-
{ counter-reset: source-line 0; }
|
| 40 |
-
pre.numberSource code > span
|
| 41 |
-
{ position: relative; left: -4em; counter-increment: source-line; }
|
| 42 |
-
pre.numberSource code > span > a:first-child::before
|
| 43 |
-
{ content: counter(source-line);
|
| 44 |
-
position: relative; left: -1em; text-align: right; vertical-align: baseline;
|
| 45 |
-
border: none; display: inline-block;
|
| 46 |
-
-webkit-touch-callout: none; -webkit-user-select: none;
|
| 47 |
-
-khtml-user-select: none; -moz-user-select: none;
|
| 48 |
-
-ms-user-select: none; user-select: none;
|
| 49 |
-
padding: 0 4px; width: 4em;
|
| 50 |
-
}
|
| 51 |
-
pre.numberSource { margin-left: 3em; padding-left: 4px; }
|
| 52 |
-
div.sourceCode
|
| 53 |
-
{ }
|
| 54 |
-
@media screen {
|
| 55 |
-
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
|
| 56 |
-
}
|
| 57 |
-
</style>
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
<script src="site_libs/quarto-nav/quarto-nav.js"></script>
|
| 61 |
-
<script src="site_libs/quarto-nav/headroom.min.js"></script>
|
| 62 |
-
<script src="site_libs/clipboard/clipboard.min.js"></script>
|
| 63 |
-
<script src="site_libs/quarto-search/autocomplete.umd.js"></script>
|
| 64 |
-
<script src="site_libs/quarto-search/fuse.min.js"></script>
|
| 65 |
-
<script src="site_libs/quarto-search/quarto-search.js"></script>
|
| 66 |
-
<meta name="quarto:offset" content="./">
|
| 67 |
-
<link href="./references.html" rel="next">
|
| 68 |
-
<link href="./intro.html" rel="prev">
|
| 69 |
-
<script src="site_libs/quarto-html/quarto.js"></script>
|
| 70 |
-
<script src="site_libs/quarto-html/popper.min.js"></script>
|
| 71 |
-
<script src="site_libs/quarto-html/tippy.umd.min.js"></script>
|
| 72 |
-
<script src="site_libs/quarto-html/anchor.min.js"></script>
|
| 73 |
-
<link href="site_libs/quarto-html/tippy.css" rel="stylesheet">
|
| 74 |
-
<link href="site_libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
|
| 75 |
-
<script src="site_libs/bootstrap/bootstrap.min.js"></script>
|
| 76 |
-
<link href="site_libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
|
| 77 |
-
<link href="site_libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">
|
| 78 |
-
<script id="quarto-search-options" type="application/json">{
|
| 79 |
-
"location": "sidebar",
|
| 80 |
-
"copy-button": false,
|
| 81 |
-
"collapse-after": 3,
|
| 82 |
-
"panel-placement": "start",
|
| 83 |
-
"type": "textbox",
|
| 84 |
-
"limit": 20,
|
| 85 |
-
"language": {
|
| 86 |
-
"search-no-results-text": "No results",
|
| 87 |
-
"search-matching-documents-text": "matching documents",
|
| 88 |
-
"search-copy-link-title": "Copy link to search",
|
| 89 |
-
"search-hide-matches-text": "Hide additional matches",
|
| 90 |
-
"search-more-match-text": "more match in this document",
|
| 91 |
-
"search-more-matches-text": "more matches in this document",
|
| 92 |
-
"search-clear-button-title": "Clear",
|
| 93 |
-
"search-detached-cancel-button-title": "Cancel",
|
| 94 |
-
"search-submit-button-title": "Submit",
|
| 95 |
-
"search-label": "Search"
|
| 96 |
-
}
|
| 97 |
-
}</script>
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
</head>
|
| 101 |
-
|
| 102 |
-
<body class="nav-sidebar floating">
|
| 103 |
-
|
| 104 |
-
<div id="quarto-search-results"></div>
|
| 105 |
-
<header id="quarto-header" class="headroom fixed-top">
|
| 106 |
-
<nav class="quarto-secondary-nav">
|
| 107 |
-
<div class="container-fluid d-flex">
|
| 108 |
-
<button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
|
| 109 |
-
<i class="bi bi-layout-text-sidebar-reverse"></i>
|
| 110 |
-
</button>
|
| 111 |
-
<nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="./summary.html"><span class="chapter-number">2</span> <span class="chapter-title">Summary</span></a></li></ol></nav>
|
| 112 |
-
<a class="flex-grow-1" role="button" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
|
| 113 |
-
</a>
|
| 114 |
-
<button type="button" class="btn quarto-search-button" aria-label="" onclick="window.quartoOpenSearch();">
|
| 115 |
-
<i class="bi bi-search"></i>
|
| 116 |
-
</button>
|
| 117 |
-
</div>
|
| 118 |
-
</nav>
|
| 119 |
-
</header>
|
| 120 |
-
<!-- content -->
|
| 121 |
-
<div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article">
|
| 122 |
-
<!-- sidebar -->
|
| 123 |
-
<nav id="quarto-sidebar" class="sidebar collapse collapse-horizontal sidebar-navigation floating overflow-auto">
|
| 124 |
-
<div class="pt-lg-2 mt-2 text-left sidebar-header">
|
| 125 |
-
<div class="sidebar-title mb-0 py-0">
|
| 126 |
-
<a href="./">Codewars Using R and RStudio</a>
|
| 127 |
-
</div>
|
| 128 |
-
</div>
|
| 129 |
-
<div class="mt-2 flex-shrink-0 align-items-center">
|
| 130 |
-
<div class="sidebar-search">
|
| 131 |
-
<div id="quarto-search" class="" title="Search"></div>
|
| 132 |
-
</div>
|
| 133 |
-
</div>
|
| 134 |
-
<div class="sidebar-menu-container">
|
| 135 |
-
<ul class="list-unstyled mt-1">
|
| 136 |
-
<li class="sidebar-item">
|
| 137 |
-
<div class="sidebar-item-container">
|
| 138 |
-
<a href="./index.html" class="sidebar-item-text sidebar-link">
|
| 139 |
-
<span class="menu-text">Preface</span></a>
|
| 140 |
-
</div>
|
| 141 |
-
</li>
|
| 142 |
-
<li class="sidebar-item">
|
| 143 |
-
<div class="sidebar-item-container">
|
| 144 |
-
<a href="./intro.html" class="sidebar-item-text sidebar-link">
|
| 145 |
-
<span class="menu-text"><span class="chapter-number">1</span> <span class="chapter-title">Introduction</span></span></a>
|
| 146 |
-
</div>
|
| 147 |
-
</li>
|
| 148 |
-
<li class="sidebar-item">
|
| 149 |
-
<div class="sidebar-item-container">
|
| 150 |
-
<a href="./summary.html" class="sidebar-item-text sidebar-link active">
|
| 151 |
-
<span class="menu-text"><span class="chapter-number">2</span> <span class="chapter-title">Summary</span></span></a>
|
| 152 |
-
</div>
|
| 153 |
-
</li>
|
| 154 |
-
<li class="sidebar-item">
|
| 155 |
-
<div class="sidebar-item-container">
|
| 156 |
-
<a href="./references.html" class="sidebar-item-text sidebar-link">
|
| 157 |
-
<span class="menu-text">References</span></a>
|
| 158 |
-
</div>
|
| 159 |
-
</li>
|
| 160 |
-
</ul>
|
| 161 |
-
</div>
|
| 162 |
-
</nav>
|
| 163 |
-
<div id="quarto-sidebar-glass" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass"></div>
|
| 164 |
-
<!-- margin-sidebar -->
|
| 165 |
-
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
|
| 166 |
-
|
| 167 |
-
</div>
|
| 168 |
-
<!-- main -->
|
| 169 |
-
<main class="content" id="quarto-document-content">
|
| 170 |
-
|
| 171 |
-
<header id="title-block-header" class="quarto-title-block default">
|
| 172 |
-
<div class="quarto-title">
|
| 173 |
-
<h1 class="title"><span class="chapter-number">2</span> <span class="chapter-title">Summary</span></h1>
|
| 174 |
-
</div>
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
<div class="quarto-title-meta">
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
</div>
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
</header>
|
| 187 |
-
|
| 188 |
-
<p>In summary, this book has no content whatsoever.</p>
|
| 189 |
-
<div class="cell">
|
| 190 |
-
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="dv">1</span> <span class="sc">+</span> <span class="dv">1</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 191 |
-
<div class="cell-output cell-output-stdout">
|
| 192 |
-
<pre><code>[1] 2</code></pre>
|
| 193 |
-
</div>
|
| 194 |
-
</div>
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
</main> <!-- /main -->
|
| 199 |
-
<script id="quarto-html-after-body" type="application/javascript">
|
| 200 |
-
window.document.addEventListener("DOMContentLoaded", function (event) {
|
| 201 |
-
const toggleBodyColorMode = (bsSheetEl) => {
|
| 202 |
-
const mode = bsSheetEl.getAttribute("data-mode");
|
| 203 |
-
const bodyEl = window.document.querySelector("body");
|
| 204 |
-
if (mode === "dark") {
|
| 205 |
-
bodyEl.classList.add("quarto-dark");
|
| 206 |
-
bodyEl.classList.remove("quarto-light");
|
| 207 |
-
} else {
|
| 208 |
-
bodyEl.classList.add("quarto-light");
|
| 209 |
-
bodyEl.classList.remove("quarto-dark");
|
| 210 |
-
}
|
| 211 |
-
}
|
| 212 |
-
const toggleBodyColorPrimary = () => {
|
| 213 |
-
const bsSheetEl = window.document.querySelector("link#quarto-bootstrap");
|
| 214 |
-
if (bsSheetEl) {
|
| 215 |
-
toggleBodyColorMode(bsSheetEl);
|
| 216 |
-
}
|
| 217 |
-
}
|
| 218 |
-
toggleBodyColorPrimary();
|
| 219 |
-
const icon = "";
|
| 220 |
-
const anchorJS = new window.AnchorJS();
|
| 221 |
-
anchorJS.options = {
|
| 222 |
-
placement: 'right',
|
| 223 |
-
icon: icon
|
| 224 |
-
};
|
| 225 |
-
anchorJS.add('.anchored');
|
| 226 |
-
const isCodeAnnotation = (el) => {
|
| 227 |
-
for (const clz of el.classList) {
|
| 228 |
-
if (clz.startsWith('code-annotation-')) {
|
| 229 |
-
return true;
|
| 230 |
-
}
|
| 231 |
-
}
|
| 232 |
-
return false;
|
| 233 |
-
}
|
| 234 |
-
const clipboard = new window.ClipboardJS('.code-copy-button', {
|
| 235 |
-
text: function(trigger) {
|
| 236 |
-
const codeEl = trigger.previousElementSibling.cloneNode(true);
|
| 237 |
-
for (const childEl of codeEl.children) {
|
| 238 |
-
if (isCodeAnnotation(childEl)) {
|
| 239 |
-
childEl.remove();
|
| 240 |
-
}
|
| 241 |
-
}
|
| 242 |
-
return codeEl.innerText;
|
| 243 |
-
}
|
| 244 |
-
});
|
| 245 |
-
clipboard.on('success', function(e) {
|
| 246 |
-
// button target
|
| 247 |
-
const button = e.trigger;
|
| 248 |
-
// don't keep focus
|
| 249 |
-
button.blur();
|
| 250 |
-
// flash "checked"
|
| 251 |
-
button.classList.add('code-copy-button-checked');
|
| 252 |
-
var currentTitle = button.getAttribute("title");
|
| 253 |
-
button.setAttribute("title", "Copied!");
|
| 254 |
-
let tooltip;
|
| 255 |
-
if (window.bootstrap) {
|
| 256 |
-
button.setAttribute("data-bs-toggle", "tooltip");
|
| 257 |
-
button.setAttribute("data-bs-placement", "left");
|
| 258 |
-
button.setAttribute("data-bs-title", "Copied!");
|
| 259 |
-
tooltip = new bootstrap.Tooltip(button,
|
| 260 |
-
{ trigger: "manual",
|
| 261 |
-
customClass: "code-copy-button-tooltip",
|
| 262 |
-
offset: [0, -8]});
|
| 263 |
-
tooltip.show();
|
| 264 |
-
}
|
| 265 |
-
setTimeout(function() {
|
| 266 |
-
if (tooltip) {
|
| 267 |
-
tooltip.hide();
|
| 268 |
-
button.removeAttribute("data-bs-title");
|
| 269 |
-
button.removeAttribute("data-bs-toggle");
|
| 270 |
-
button.removeAttribute("data-bs-placement");
|
| 271 |
-
}
|
| 272 |
-
button.setAttribute("title", currentTitle);
|
| 273 |
-
button.classList.remove('code-copy-button-checked');
|
| 274 |
-
}, 1000);
|
| 275 |
-
// clear code selection
|
| 276 |
-
e.clearSelection();
|
| 277 |
-
});
|
| 278 |
-
function tippyHover(el, contentFn) {
|
| 279 |
-
const config = {
|
| 280 |
-
allowHTML: true,
|
| 281 |
-
content: contentFn,
|
| 282 |
-
maxWidth: 500,
|
| 283 |
-
delay: 100,
|
| 284 |
-
arrow: false,
|
| 285 |
-
appendTo: function(el) {
|
| 286 |
-
return el.parentElement;
|
| 287 |
-
},
|
| 288 |
-
interactive: true,
|
| 289 |
-
interactiveBorder: 10,
|
| 290 |
-
theme: 'quarto',
|
| 291 |
-
placement: 'bottom-start'
|
| 292 |
-
};
|
| 293 |
-
window.tippy(el, config);
|
| 294 |
-
}
|
| 295 |
-
const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
|
| 296 |
-
for (var i=0; i<noterefs.length; i++) {
|
| 297 |
-
const ref = noterefs[i];
|
| 298 |
-
tippyHover(ref, function() {
|
| 299 |
-
// use id or data attribute instead here
|
| 300 |
-
let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
|
| 301 |
-
try { href = new URL(href).hash; } catch {}
|
| 302 |
-
const id = href.replace(/^#\/?/, "");
|
| 303 |
-
const note = window.document.getElementById(id);
|
| 304 |
-
return note.innerHTML;
|
| 305 |
-
});
|
| 306 |
-
}
|
| 307 |
-
let selectedAnnoteEl;
|
| 308 |
-
const selectorForAnnotation = ( cell, annotation) => {
|
| 309 |
-
let cellAttr = 'data-code-cell="' + cell + '"';
|
| 310 |
-
let lineAttr = 'data-code-annotation="' + annotation + '"';
|
| 311 |
-
const selector = 'span[' + cellAttr + '][' + lineAttr + ']';
|
| 312 |
-
return selector;
|
| 313 |
-
}
|
| 314 |
-
const selectCodeLines = (annoteEl) => {
|
| 315 |
-
const doc = window.document;
|
| 316 |
-
const targetCell = annoteEl.getAttribute("data-target-cell");
|
| 317 |
-
const targetAnnotation = annoteEl.getAttribute("data-target-annotation");
|
| 318 |
-
const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation));
|
| 319 |
-
const lines = annoteSpan.getAttribute("data-code-lines").split(",");
|
| 320 |
-
const lineIds = lines.map((line) => {
|
| 321 |
-
return targetCell + "-" + line;
|
| 322 |
-
})
|
| 323 |
-
let top = null;
|
| 324 |
-
let height = null;
|
| 325 |
-
let parent = null;
|
| 326 |
-
if (lineIds.length > 0) {
|
| 327 |
-
//compute the position of the single el (top and bottom and make a div)
|
| 328 |
-
const el = window.document.getElementById(lineIds[0]);
|
| 329 |
-
top = el.offsetTop;
|
| 330 |
-
height = el.offsetHeight;
|
| 331 |
-
parent = el.parentElement.parentElement;
|
| 332 |
-
if (lineIds.length > 1) {
|
| 333 |
-
const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]);
|
| 334 |
-
const bottom = lastEl.offsetTop + lastEl.offsetHeight;
|
| 335 |
-
height = bottom - top;
|
| 336 |
-
}
|
| 337 |
-
if (top !== null && height !== null && parent !== null) {
|
| 338 |
-
// cook up a div (if necessary) and position it
|
| 339 |
-
let div = window.document.getElementById("code-annotation-line-highlight");
|
| 340 |
-
if (div === null) {
|
| 341 |
-
div = window.document.createElement("div");
|
| 342 |
-
div.setAttribute("id", "code-annotation-line-highlight");
|
| 343 |
-
div.style.position = 'absolute';
|
| 344 |
-
parent.appendChild(div);
|
| 345 |
-
}
|
| 346 |
-
div.style.top = top - 2 + "px";
|
| 347 |
-
div.style.height = height + 4 + "px";
|
| 348 |
-
let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter");
|
| 349 |
-
if (gutterDiv === null) {
|
| 350 |
-
gutterDiv = window.document.createElement("div");
|
| 351 |
-
gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter");
|
| 352 |
-
gutterDiv.style.position = 'absolute';
|
| 353 |
-
const codeCell = window.document.getElementById(targetCell);
|
| 354 |
-
const gutter = codeCell.querySelector('.code-annotation-gutter');
|
| 355 |
-
gutter.appendChild(gutterDiv);
|
| 356 |
-
}
|
| 357 |
-
gutterDiv.style.top = top - 2 + "px";
|
| 358 |
-
gutterDiv.style.height = height + 4 + "px";
|
| 359 |
-
}
|
| 360 |
-
selectedAnnoteEl = annoteEl;
|
| 361 |
-
}
|
| 362 |
-
};
|
| 363 |
-
const unselectCodeLines = () => {
|
| 364 |
-
const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"];
|
| 365 |
-
elementsIds.forEach((elId) => {
|
| 366 |
-
const div = window.document.getElementById(elId);
|
| 367 |
-
if (div) {
|
| 368 |
-
div.remove();
|
| 369 |
-
}
|
| 370 |
-
});
|
| 371 |
-
selectedAnnoteEl = undefined;
|
| 372 |
-
};
|
| 373 |
-
// Attach click handler to the DT
|
| 374 |
-
const annoteDls = window.document.querySelectorAll('dt[data-target-cell]');
|
| 375 |
-
for (const annoteDlNode of annoteDls) {
|
| 376 |
-
annoteDlNode.addEventListener('click', (event) => {
|
| 377 |
-
const clickedEl = event.target;
|
| 378 |
-
if (clickedEl !== selectedAnnoteEl) {
|
| 379 |
-
unselectCodeLines();
|
| 380 |
-
const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active');
|
| 381 |
-
if (activeEl) {
|
| 382 |
-
activeEl.classList.remove('code-annotation-active');
|
| 383 |
-
}
|
| 384 |
-
selectCodeLines(clickedEl);
|
| 385 |
-
clickedEl.classList.add('code-annotation-active');
|
| 386 |
-
} else {
|
| 387 |
-
// Unselect the line
|
| 388 |
-
unselectCodeLines();
|
| 389 |
-
clickedEl.classList.remove('code-annotation-active');
|
| 390 |
-
}
|
| 391 |
-
});
|
| 392 |
-
}
|
| 393 |
-
const findCites = (el) => {
|
| 394 |
-
const parentEl = el.parentElement;
|
| 395 |
-
if (parentEl) {
|
| 396 |
-
const cites = parentEl.dataset.cites;
|
| 397 |
-
if (cites) {
|
| 398 |
-
return {
|
| 399 |
-
el,
|
| 400 |
-
cites: cites.split(' ')
|
| 401 |
-
};
|
| 402 |
-
} else {
|
| 403 |
-
return findCites(el.parentElement)
|
| 404 |
-
}
|
| 405 |
-
} else {
|
| 406 |
-
return undefined;
|
| 407 |
-
}
|
| 408 |
-
};
|
| 409 |
-
var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
|
| 410 |
-
for (var i=0; i<bibliorefs.length; i++) {
|
| 411 |
-
const ref = bibliorefs[i];
|
| 412 |
-
const citeInfo = findCites(ref);
|
| 413 |
-
if (citeInfo) {
|
| 414 |
-
tippyHover(citeInfo.el, function() {
|
| 415 |
-
var popup = window.document.createElement('div');
|
| 416 |
-
citeInfo.cites.forEach(function(cite) {
|
| 417 |
-
var citeDiv = window.document.createElement('div');
|
| 418 |
-
citeDiv.classList.add('hanging-indent');
|
| 419 |
-
citeDiv.classList.add('csl-entry');
|
| 420 |
-
var biblioDiv = window.document.getElementById('ref-' + cite);
|
| 421 |
-
if (biblioDiv) {
|
| 422 |
-
citeDiv.innerHTML = biblioDiv.innerHTML;
|
| 423 |
-
}
|
| 424 |
-
popup.appendChild(citeDiv);
|
| 425 |
-
});
|
| 426 |
-
return popup.innerHTML;
|
| 427 |
-
});
|
| 428 |
-
}
|
| 429 |
-
}
|
| 430 |
-
});
|
| 431 |
-
</script>
|
| 432 |
-
<nav class="page-navigation">
|
| 433 |
-
<div class="nav-page nav-page-previous">
|
| 434 |
-
<a href="./intro.html" class="pagination-link">
|
| 435 |
-
<i class="bi bi-arrow-left-short"></i> <span class="nav-page-text"><span class="chapter-number">1</span> <span class="chapter-title">Introduction</span></span>
|
| 436 |
-
</a>
|
| 437 |
-
</div>
|
| 438 |
-
<div class="nav-page nav-page-next">
|
| 439 |
-
<a href="./references.html" class="pagination-link">
|
| 440 |
-
<span class="nav-page-text">References</span> <i class="bi bi-arrow-right-short"></i>
|
| 441 |
-
</a>
|
| 442 |
-
</div>
|
| 443 |
-
</nav>
|
| 444 |
-
</div> <!-- /content -->
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
</body></html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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