Spaces:
Running
Running
aepstar
commited on
Commit
·
60fc59c
1
Parent(s):
4103597
update
Browse files- _quarto.yml +3 -0
- cw001evenodd.html +12 -7
- cw002multiply.html +10 -5
- cw003countsheep.html +10 -5
- cw004reducegrow.html +10 -5
- cw005make_negative.html +9 -4
- cw006positive_sum.html +13 -8
- cw007reversedstrings.html +545 -0
- cw008bool_to_word.html +530 -0
- index.html +9 -3
_quarto.yml
CHANGED
@@ -19,6 +19,9 @@ book:
|
|
19 |
- cw004reducegrow.qmd
|
20 |
- cw005make_negative.qmd
|
21 |
- cw006positive_sum.qmd
|
|
|
|
|
|
|
22 |
|
23 |
bibliography: references.bib
|
24 |
|
|
|
19 |
- cw004reducegrow.qmd
|
20 |
- cw005make_negative.qmd
|
21 |
- cw006positive_sum.qmd
|
22 |
+
- cw007reversedstrings.qmd
|
23 |
+
- cw008bool_to_word.qmd
|
24 |
+
|
25 |
|
26 |
bibliography: references.bib
|
27 |
|
cw001evenodd.html
CHANGED
@@ -188,8 +188,14 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
188 |
</li>
|
189 |
<li class="sidebar-item">
|
190 |
<div class="sidebar-item-container">
|
191 |
-
<a href="./
|
192 |
-
<span class="menu-text">
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
</div>
|
194 |
</li>
|
195 |
</ul>
|
@@ -230,9 +236,8 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
230 |
|
231 |
</header>
|
232 |
|
233 |
-
<p>Tantangan #1/366 - 15 Feb 2024</p>
|
234 |
<p><a href="https://www.codewars.com/kata/53da3dbb4a5168369a0000fe/train/r" class="uri">https://www.codewars.com/kata/53da3dbb4a5168369a0000fe/train/r</a></p>
|
235 |
-
<p><span class="badge rounded-pill quarto-badge " style="background-color: grey;">8kyu</span> Even or Odd</p>
|
236 |
<section id="instruction" class="level2" data-number="1.1">
|
237 |
<h2 data-number="1.1" class="anchored" data-anchor-id="instruction"><span class="header-section-number">1.1</span> Instruction</h2>
|
238 |
<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>
|
@@ -274,19 +279,19 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
274 |
<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>
|
275 |
<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>
|
276 |
<div class="cell-output cell-output-stdout">
|
277 |
-
<pre><code>Test passed
|
278 |
</div>
|
279 |
<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>
|
280 |
<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>
|
281 |
<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>
|
282 |
<div class="cell-output cell-output-stdout">
|
283 |
-
<pre><code>Test passed
|
284 |
</div>
|
285 |
<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>
|
286 |
<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>
|
287 |
<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>
|
288 |
<div class="cell-output cell-output-stdout">
|
289 |
-
<pre><code>Test passed
|
290 |
</div>
|
291 |
<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>
|
292 |
<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>
|
|
|
188 |
</li>
|
189 |
<li class="sidebar-item">
|
190 |
<div class="sidebar-item-container">
|
191 |
+
<a href="./cw007reversedstrings.html" class="sidebar-item-text sidebar-link">
|
192 |
+
<span class="menu-text"><span class="chapter-number">7</span> <span class="chapter-title">Reversed Strings</span></span></a>
|
193 |
+
</div>
|
194 |
+
</li>
|
195 |
+
<li class="sidebar-item">
|
196 |
+
<div class="sidebar-item-container">
|
197 |
+
<a href="./cw008bool_to_word.html" class="sidebar-item-text sidebar-link">
|
198 |
+
<span class="menu-text"><span class="chapter-number">8</span> <span class="chapter-title">Convert boolean values to strings ‘Yes’ or ‘No’</span></span></a>
|
199 |
</div>
|
200 |
</li>
|
201 |
</ul>
|
|
|
236 |
|
237 |
</header>
|
238 |
|
239 |
+
<p><span class="badge rounded-pill quarto-badge " style="background-color: grey;">8kyu</span> Tantangan #1/366 - 15 Feb 2024</p>
|
240 |
<p><a href="https://www.codewars.com/kata/53da3dbb4a5168369a0000fe/train/r" class="uri">https://www.codewars.com/kata/53da3dbb4a5168369a0000fe/train/r</a></p>
|
|
|
241 |
<section id="instruction" class="level2" data-number="1.1">
|
242 |
<h2 data-number="1.1" class="anchored" data-anchor-id="instruction"><span class="header-section-number">1.1</span> Instruction</h2>
|
243 |
<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>
|
|
|
279 |
<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>
|
280 |
<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>
|
281 |
<div class="cell-output cell-output-stdout">
|
282 |
+
<pre><code>Test passed 🥳</code></pre>
|
283 |
</div>
|
284 |
<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>
|
285 |
<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>
|
286 |
<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>
|
287 |
<div class="cell-output cell-output-stdout">
|
288 |
+
<pre><code>Test passed 🥇</code></pre>
|
289 |
</div>
|
290 |
<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>
|
291 |
<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>
|
292 |
<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>
|
293 |
<div class="cell-output cell-output-stdout">
|
294 |
+
<pre><code>Test passed 😸</code></pre>
|
295 |
</div>
|
296 |
<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>
|
297 |
<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>
|
cw002multiply.html
CHANGED
@@ -188,8 +188,14 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
188 |
</li>
|
189 |
<li class="sidebar-item">
|
190 |
<div class="sidebar-item-container">
|
191 |
-
<a href="./
|
192 |
-
<span class="menu-text">
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
</div>
|
194 |
</li>
|
195 |
</ul>
|
@@ -230,9 +236,8 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
230 |
|
231 |
</header>
|
232 |
|
233 |
-
<p>Tantangan #2/366 - 16 Feb 2024</p>
|
234 |
<p><a href="https://www.codewars.com/kata/50654ddff44f800200000004/train/r" class="uri">https://www.codewars.com/kata/50654ddff44f800200000004/train/r</a></p>
|
235 |
-
<p><span class="badge rounded-pill quarto-badge " style="background-color: grey;">8kyu</span> Multiply</p>
|
236 |
<section id="instruction" class="level2" data-number="2.1">
|
237 |
<h2 data-number="2.1" class="anchored" data-anchor-id="instruction"><span class="header-section-number">2.1</span> Instruction</h2>
|
238 |
<p>This code does not execute properly. Try to figure out why.</p>
|
@@ -273,7 +278,7 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
273 |
<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>
|
274 |
<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>
|
275 |
<div class="cell-output cell-output-stdout">
|
276 |
-
<pre><code>Test passed
|
277 |
</div>
|
278 |
</div>
|
279 |
</section>
|
|
|
188 |
</li>
|
189 |
<li class="sidebar-item">
|
190 |
<div class="sidebar-item-container">
|
191 |
+
<a href="./cw007reversedstrings.html" class="sidebar-item-text sidebar-link">
|
192 |
+
<span class="menu-text"><span class="chapter-number">7</span> <span class="chapter-title">Reversed Strings</span></span></a>
|
193 |
+
</div>
|
194 |
+
</li>
|
195 |
+
<li class="sidebar-item">
|
196 |
+
<div class="sidebar-item-container">
|
197 |
+
<a href="./cw008bool_to_word.html" class="sidebar-item-text sidebar-link">
|
198 |
+
<span class="menu-text"><span class="chapter-number">8</span> <span class="chapter-title">Convert boolean values to strings ‘Yes’ or ‘No’</span></span></a>
|
199 |
</div>
|
200 |
</li>
|
201 |
</ul>
|
|
|
236 |
|
237 |
</header>
|
238 |
|
239 |
+
<p><span class="badge rounded-pill quarto-badge " style="background-color: grey;">8kyu</span> Tantangan #2/366 - 16 Feb 2024</p>
|
240 |
<p><a href="https://www.codewars.com/kata/50654ddff44f800200000004/train/r" class="uri">https://www.codewars.com/kata/50654ddff44f800200000004/train/r</a></p>
|
|
|
241 |
<section id="instruction" class="level2" data-number="2.1">
|
242 |
<h2 data-number="2.1" class="anchored" data-anchor-id="instruction"><span class="header-section-number">2.1</span> Instruction</h2>
|
243 |
<p>This code does not execute properly. Try to figure out why.</p>
|
|
|
278 |
<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>
|
279 |
<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>
|
280 |
<div class="cell-output cell-output-stdout">
|
281 |
+
<pre><code>Test passed 😸</code></pre>
|
282 |
</div>
|
283 |
</div>
|
284 |
</section>
|
cw003countsheep.html
CHANGED
@@ -188,8 +188,14 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
188 |
</li>
|
189 |
<li class="sidebar-item">
|
190 |
<div class="sidebar-item-container">
|
191 |
-
<a href="./
|
192 |
-
<span class="menu-text">
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
</div>
|
194 |
</li>
|
195 |
</ul>
|
@@ -230,9 +236,8 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
230 |
|
231 |
</header>
|
232 |
|
233 |
-
<p>Tantangan #3/366 - 17 Feb 2024</p>
|
234 |
<p><a href="https://www.codewars.com/kata/5b077ebdaf15be5c7f000077/train/r" class="uri">https://www.codewars.com/kata/5b077ebdaf15be5c7f000077/train/r</a></p>
|
235 |
-
<p><span class="badge rounded-pill quarto-badge " style="background-color: grey;">8kyu</span> If you can’t sleep, just count sheep!!</p>
|
236 |
<section id="instruction" class="level2" data-number="3.1">
|
237 |
<h2 data-number="3.1" class="anchored" data-anchor-id="instruction"><span class="header-section-number">3.1</span> Instruction</h2>
|
238 |
<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>
|
@@ -276,7 +281,7 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
276 |
<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>
|
277 |
<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>
|
278 |
<div class="cell-output cell-output-stdout">
|
279 |
-
<pre><code>Test passed
|
280 |
</div>
|
281 |
</div>
|
282 |
</section>
|
|
|
188 |
</li>
|
189 |
<li class="sidebar-item">
|
190 |
<div class="sidebar-item-container">
|
191 |
+
<a href="./cw007reversedstrings.html" class="sidebar-item-text sidebar-link">
|
192 |
+
<span class="menu-text"><span class="chapter-number">7</span> <span class="chapter-title">Reversed Strings</span></span></a>
|
193 |
+
</div>
|
194 |
+
</li>
|
195 |
+
<li class="sidebar-item">
|
196 |
+
<div class="sidebar-item-container">
|
197 |
+
<a href="./cw008bool_to_word.html" class="sidebar-item-text sidebar-link">
|
198 |
+
<span class="menu-text"><span class="chapter-number">8</span> <span class="chapter-title">Convert boolean values to strings ‘Yes’ or ‘No’</span></span></a>
|
199 |
</div>
|
200 |
</li>
|
201 |
</ul>
|
|
|
236 |
|
237 |
</header>
|
238 |
|
239 |
+
<p><span class="badge rounded-pill quarto-badge " style="background-color: grey;">8kyu</span> Tantangan #3/366 - 17 Feb 2024</p>
|
240 |
<p><a href="https://www.codewars.com/kata/5b077ebdaf15be5c7f000077/train/r" class="uri">https://www.codewars.com/kata/5b077ebdaf15be5c7f000077/train/r</a></p>
|
|
|
241 |
<section id="instruction" class="level2" data-number="3.1">
|
242 |
<h2 data-number="3.1" class="anchored" data-anchor-id="instruction"><span class="header-section-number">3.1</span> Instruction</h2>
|
243 |
<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>
|
|
|
281 |
<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>
|
282 |
<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>
|
283 |
<div class="cell-output cell-output-stdout">
|
284 |
+
<pre><code>Test passed 🥇</code></pre>
|
285 |
</div>
|
286 |
</div>
|
287 |
</section>
|
cw004reducegrow.html
CHANGED
@@ -188,8 +188,14 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
188 |
</li>
|
189 |
<li class="sidebar-item">
|
190 |
<div class="sidebar-item-container">
|
191 |
-
<a href="./
|
192 |
-
<span class="menu-text">
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
</div>
|
194 |
</li>
|
195 |
</ul>
|
@@ -230,9 +236,8 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
230 |
|
231 |
</header>
|
232 |
|
233 |
-
<p>Tantangan #4/366 -
|
234 |
<p><a href="https://www.codewars.com/kata/57f780909f7e8e3183000078/train/r" class="uri">https://www.codewars.com/kata/57f780909f7e8e3183000078/train/r</a></p>
|
235 |
-
<p><span class="badge rounded-pill quarto-badge " style="background-color: grey;">8kyu</span> Beginner - Reduce but Grow</p>
|
236 |
<section id="instruction" class="level2" data-number="4.1">
|
237 |
<h2 data-number="4.1" class="anchored" data-anchor-id="instruction"><span class="header-section-number">4.1</span> Instruction</h2>
|
238 |
<p>Given a non-empty array of integers, return the result of multiplying the values together in order. Example:</p>
|
@@ -270,7 +275,7 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
270 |
<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>
|
271 |
<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>
|
272 |
<div class="cell-output cell-output-stdout">
|
273 |
-
<pre><code>Test passed
|
274 |
</div>
|
275 |
</div>
|
276 |
</section>
|
|
|
188 |
</li>
|
189 |
<li class="sidebar-item">
|
190 |
<div class="sidebar-item-container">
|
191 |
+
<a href="./cw007reversedstrings.html" class="sidebar-item-text sidebar-link">
|
192 |
+
<span class="menu-text"><span class="chapter-number">7</span> <span class="chapter-title">Reversed Strings</span></span></a>
|
193 |
+
</div>
|
194 |
+
</li>
|
195 |
+
<li class="sidebar-item">
|
196 |
+
<div class="sidebar-item-container">
|
197 |
+
<a href="./cw008bool_to_word.html" class="sidebar-item-text sidebar-link">
|
198 |
+
<span class="menu-text"><span class="chapter-number">8</span> <span class="chapter-title">Convert boolean values to strings ‘Yes’ or ‘No’</span></span></a>
|
199 |
</div>
|
200 |
</li>
|
201 |
</ul>
|
|
|
236 |
|
237 |
</header>
|
238 |
|
239 |
+
<p><span class="badge rounded-pill quarto-badge " style="background-color: grey;">8kyu</span> Tantangan #4/366 - 18 Feb 2024</p>
|
240 |
<p><a href="https://www.codewars.com/kata/57f780909f7e8e3183000078/train/r" class="uri">https://www.codewars.com/kata/57f780909f7e8e3183000078/train/r</a></p>
|
|
|
241 |
<section id="instruction" class="level2" data-number="4.1">
|
242 |
<h2 data-number="4.1" class="anchored" data-anchor-id="instruction"><span class="header-section-number">4.1</span> Instruction</h2>
|
243 |
<p>Given a non-empty array of integers, return the result of multiplying the values together in order. Example:</p>
|
|
|
275 |
<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>
|
276 |
<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>
|
277 |
<div class="cell-output cell-output-stdout">
|
278 |
+
<pre><code>Test passed 😸</code></pre>
|
279 |
</div>
|
280 |
</div>
|
281 |
</section>
|
cw005make_negative.html
CHANGED
@@ -188,8 +188,14 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
188 |
</li>
|
189 |
<li class="sidebar-item">
|
190 |
<div class="sidebar-item-container">
|
191 |
-
<a href="./
|
192 |
-
<span class="menu-text">
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
</div>
|
194 |
</li>
|
195 |
</ul>
|
@@ -230,9 +236,8 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
230 |
|
231 |
</header>
|
232 |
|
233 |
-
<p>Tantangan #5/366 -
|
234 |
<p><a href="https://www.codewars.com/kata/55685cd7ad70877c23000102/train/r" class="uri">https://www.codewars.com/kata/55685cd7ad70877c23000102/train/r</a></p>
|
235 |
-
<p><span class="badge rounded-pill quarto-badge " style="background-color: grey;">8kyu</span> Return Negative</p>
|
236 |
<section id="instruction" class="level2" data-number="5.1">
|
237 |
<h2 data-number="5.1" class="anchored" data-anchor-id="instruction"><span class="header-section-number">5.1</span> Instruction</h2>
|
238 |
<p>In this simple assignment you are given a number and have to make it negative. But maybe the number is already negative?</p>
|
|
|
188 |
</li>
|
189 |
<li class="sidebar-item">
|
190 |
<div class="sidebar-item-container">
|
191 |
+
<a href="./cw007reversedstrings.html" class="sidebar-item-text sidebar-link">
|
192 |
+
<span class="menu-text"><span class="chapter-number">7</span> <span class="chapter-title">Reversed Strings</span></span></a>
|
193 |
+
</div>
|
194 |
+
</li>
|
195 |
+
<li class="sidebar-item">
|
196 |
+
<div class="sidebar-item-container">
|
197 |
+
<a href="./cw008bool_to_word.html" class="sidebar-item-text sidebar-link">
|
198 |
+
<span class="menu-text"><span class="chapter-number">8</span> <span class="chapter-title">Convert boolean values to strings ‘Yes’ or ‘No’</span></span></a>
|
199 |
</div>
|
200 |
</li>
|
201 |
</ul>
|
|
|
236 |
|
237 |
</header>
|
238 |
|
239 |
+
<p><span class="badge rounded-pill quarto-badge " style="background-color: grey;">8kyu</span> Tantangan #5/366 - 19 Feb 2024</p>
|
240 |
<p><a href="https://www.codewars.com/kata/55685cd7ad70877c23000102/train/r" class="uri">https://www.codewars.com/kata/55685cd7ad70877c23000102/train/r</a></p>
|
|
|
241 |
<section id="instruction" class="level2" data-number="5.1">
|
242 |
<h2 data-number="5.1" class="anchored" data-anchor-id="instruction"><span class="header-section-number">5.1</span> Instruction</h2>
|
243 |
<p>In this simple assignment you are given a number and have to make it negative. But maybe the number is already negative?</p>
|
cw006positive_sum.html
CHANGED
@@ -64,7 +64,7 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
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="./
|
68 |
<link href="./cw005make_negative.html" rel="prev">
|
69 |
<link href="./logo.png" rel="icon" type="image/png">
|
70 |
<script src="site_libs/quarto-html/quarto.js"></script>
|
@@ -188,8 +188,14 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
188 |
</li>
|
189 |
<li class="sidebar-item">
|
190 |
<div class="sidebar-item-container">
|
191 |
-
<a href="./
|
192 |
-
<span class="menu-text">
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
</div>
|
194 |
</li>
|
195 |
</ul>
|
@@ -230,9 +236,8 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
230 |
|
231 |
</header>
|
232 |
|
233 |
-
<p>Tantangan #6/366 -
|
234 |
<p><a href="https://www.codewars.com/kata/5715eaedb436cf5606000381/train/r" class="uri">https://www.codewars.com/kata/5715eaedb436cf5606000381/train/r</a></p>
|
235 |
-
<p><span class="badge rounded-pill quarto-badge " style="background-color: grey;">8kyu</span> Sum of positive</p>
|
236 |
<section id="instruction" class="level2" data-number="6.1">
|
237 |
<h2 data-number="6.1" class="anchored" data-anchor-id="instruction"><span class="header-section-number">6.1</span> Instruction</h2>
|
238 |
<p>You get an array of numbers, return the sum of all of the positives ones.</p>
|
@@ -283,7 +288,7 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
283 |
<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>
|
284 |
<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>
|
285 |
<div class="cell-output cell-output-stdout">
|
286 |
-
<pre><code>Test passed
|
287 |
</div>
|
288 |
</div>
|
289 |
</section>
|
@@ -540,8 +545,8 @@ window.document.addEventListener("DOMContentLoaded", function (event) {
|
|
540 |
</a>
|
541 |
</div>
|
542 |
<div class="nav-page nav-page-next">
|
543 |
-
<a href="./
|
544 |
-
<span class="nav-page-text">
|
545 |
</a>
|
546 |
</div>
|
547 |
</nav>
|
|
|
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="./cw007reversedstrings.html" rel="next">
|
68 |
<link href="./cw005make_negative.html" rel="prev">
|
69 |
<link href="./logo.png" rel="icon" type="image/png">
|
70 |
<script src="site_libs/quarto-html/quarto.js"></script>
|
|
|
188 |
</li>
|
189 |
<li class="sidebar-item">
|
190 |
<div class="sidebar-item-container">
|
191 |
+
<a href="./cw007reversedstrings.html" class="sidebar-item-text sidebar-link">
|
192 |
+
<span class="menu-text"><span class="chapter-number">7</span> <span class="chapter-title">Reversed Strings</span></span></a>
|
193 |
+
</div>
|
194 |
+
</li>
|
195 |
+
<li class="sidebar-item">
|
196 |
+
<div class="sidebar-item-container">
|
197 |
+
<a href="./cw008bool_to_word.html" class="sidebar-item-text sidebar-link">
|
198 |
+
<span class="menu-text"><span class="chapter-number">8</span> <span class="chapter-title">Convert boolean values to strings ‘Yes’ or ‘No’</span></span></a>
|
199 |
</div>
|
200 |
</li>
|
201 |
</ul>
|
|
|
236 |
|
237 |
</header>
|
238 |
|
239 |
+
<p><span class="badge rounded-pill quarto-badge " style="background-color: grey;">8kyu</span> Tantangan #6/366 - 20 Feb 2024</p>
|
240 |
<p><a href="https://www.codewars.com/kata/5715eaedb436cf5606000381/train/r" class="uri">https://www.codewars.com/kata/5715eaedb436cf5606000381/train/r</a></p>
|
|
|
241 |
<section id="instruction" class="level2" data-number="6.1">
|
242 |
<h2 data-number="6.1" class="anchored" data-anchor-id="instruction"><span class="header-section-number">6.1</span> Instruction</h2>
|
243 |
<p>You get an array of numbers, return the sum of all of the positives ones.</p>
|
|
|
288 |
<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>
|
289 |
<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>
|
290 |
<div class="cell-output cell-output-stdout">
|
291 |
+
<pre><code>Test passed 🎉</code></pre>
|
292 |
</div>
|
293 |
</div>
|
294 |
</section>
|
|
|
545 |
</a>
|
546 |
</div>
|
547 |
<div class="nav-page nav-page-next">
|
548 |
+
<a href="./cw007reversedstrings.html" class="pagination-link">
|
549 |
+
<span class="nav-page-text"><span class="chapter-number">7</span> <span class="chapter-title">Reversed Strings</span></span> <i class="bi bi-arrow-right-short"></i>
|
550 |
</a>
|
551 |
</div>
|
552 |
</nav>
|
cw007reversedstrings.html
ADDED
@@ -0,0 +1,545 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 - 7 Reversed Strings</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="./cw008bool_to_word.html" rel="next">
|
68 |
+
<link href="./cw006positive_sum.html" rel="prev">
|
69 |
+
<link href="./logo.png" rel="icon" type="image/png">
|
70 |
+
<script src="site_libs/quarto-html/quarto.js"></script>
|
71 |
+
<script src="site_libs/quarto-html/popper.min.js"></script>
|
72 |
+
<script src="site_libs/quarto-html/tippy.umd.min.js"></script>
|
73 |
+
<script src="site_libs/quarto-html/anchor.min.js"></script>
|
74 |
+
<link href="site_libs/quarto-html/tippy.css" rel="stylesheet">
|
75 |
+
<link href="site_libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
|
76 |
+
<script src="site_libs/bootstrap/bootstrap.min.js"></script>
|
77 |
+
<link href="site_libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
|
78 |
+
<link href="site_libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">
|
79 |
+
<link href="site_libs/quarto-contrib/badge/badge.css" rel="stylesheet">
|
80 |
+
<script id="quarto-search-options" type="application/json">{
|
81 |
+
"location": "sidebar",
|
82 |
+
"copy-button": false,
|
83 |
+
"collapse-after": 3,
|
84 |
+
"panel-placement": "start",
|
85 |
+
"type": "textbox",
|
86 |
+
"limit": 20,
|
87 |
+
"language": {
|
88 |
+
"search-no-results-text": "No results",
|
89 |
+
"search-matching-documents-text": "matching documents",
|
90 |
+
"search-copy-link-title": "Copy link to search",
|
91 |
+
"search-hide-matches-text": "Hide additional matches",
|
92 |
+
"search-more-match-text": "more match in this document",
|
93 |
+
"search-more-matches-text": "more matches in this document",
|
94 |
+
"search-clear-button-title": "Clear",
|
95 |
+
"search-detached-cancel-button-title": "Cancel",
|
96 |
+
"search-submit-button-title": "Submit",
|
97 |
+
"search-label": "Search"
|
98 |
+
}
|
99 |
+
}</script>
|
100 |
+
|
101 |
+
|
102 |
+
<meta name="twitter:title" content="Codewars Challenge 2024 Menggunakan R dan RStudio - 7 Reversed Strings">
|
103 |
+
<meta name="twitter:description" content="">
|
104 |
+
<meta name="twitter:image" content="https://huggingface.co/spaces/aephidayatuloh/codewars2024/new_starcore_logo.png">
|
105 |
+
<meta name="twitter:image-height" content="434">
|
106 |
+
<meta name="twitter:image-width" content="1946">
|
107 |
+
<meta name="twitter:card" content="summary_large_image">
|
108 |
+
</head>
|
109 |
+
|
110 |
+
<body class="nav-sidebar floating">
|
111 |
+
|
112 |
+
<div id="quarto-search-results"></div>
|
113 |
+
<header id="quarto-header" class="headroom fixed-top">
|
114 |
+
<nav class="quarto-secondary-nav">
|
115 |
+
<div class="container-fluid d-flex">
|
116 |
+
<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(); }">
|
117 |
+
<i class="bi bi-layout-text-sidebar-reverse"></i>
|
118 |
+
</button>
|
119 |
+
<nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="./cw007reversedstrings.html"><span class="chapter-number">7</span> <span class="chapter-title">Reversed Strings</span></a></li></ol></nav>
|
120 |
+
<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(); }">
|
121 |
+
</a>
|
122 |
+
<button type="button" class="btn quarto-search-button" aria-label="" onclick="window.quartoOpenSearch();">
|
123 |
+
<i class="bi bi-search"></i>
|
124 |
+
</button>
|
125 |
+
</div>
|
126 |
+
</nav>
|
127 |
+
</header>
|
128 |
+
<!-- content -->
|
129 |
+
<div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article">
|
130 |
+
<!-- sidebar -->
|
131 |
+
<nav id="quarto-sidebar" class="sidebar collapse collapse-horizontal sidebar-navigation floating overflow-auto">
|
132 |
+
<div class="pt-lg-2 mt-2 text-left sidebar-header">
|
133 |
+
<div class="sidebar-title mb-0 py-0">
|
134 |
+
<a href="./">Codewars Challenge 2024 Menggunakan R dan RStudio</a>
|
135 |
+
<div class="sidebar-tools-main">
|
136 |
+
<a href="https://huggingface.co/spaces/aephidayatuloh/codewars2024/tree/main" rel="" title="Source Code" class="quarto-navigation-tool px-1" aria-label="Source Code"><i class="bi bi-git"></i></a>
|
137 |
+
</div>
|
138 |
+
</div>
|
139 |
+
</div>
|
140 |
+
<div class="mt-2 flex-shrink-0 align-items-center">
|
141 |
+
<div class="sidebar-search">
|
142 |
+
<div id="quarto-search" class="" title="Search"></div>
|
143 |
+
</div>
|
144 |
+
</div>
|
145 |
+
<div class="sidebar-menu-container">
|
146 |
+
<ul class="list-unstyled mt-1">
|
147 |
+
<li class="sidebar-item">
|
148 |
+
<div class="sidebar-item-container">
|
149 |
+
<a href="./index.html" class="sidebar-item-text sidebar-link">
|
150 |
+
<span class="menu-text">Pengantar</span></a>
|
151 |
+
</div>
|
152 |
+
</li>
|
153 |
+
<li class="sidebar-item">
|
154 |
+
<div class="sidebar-item-container">
|
155 |
+
<a href="./cw001evenodd.html" class="sidebar-item-text sidebar-link">
|
156 |
+
<span class="menu-text"><span class="chapter-number">1</span> <span class="chapter-title">Even or Odd</span></span></a>
|
157 |
+
</div>
|
158 |
+
</li>
|
159 |
+
<li class="sidebar-item">
|
160 |
+
<div class="sidebar-item-container">
|
161 |
+
<a href="./cw002multiply.html" class="sidebar-item-text sidebar-link">
|
162 |
+
<span class="menu-text"><span class="chapter-number">2</span> <span class="chapter-title">Multiply</span></span></a>
|
163 |
+
</div>
|
164 |
+
</li>
|
165 |
+
<li class="sidebar-item">
|
166 |
+
<div class="sidebar-item-container">
|
167 |
+
<a href="./cw003countsheep.html" class="sidebar-item-text sidebar-link">
|
168 |
+
<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>
|
169 |
+
</div>
|
170 |
+
</li>
|
171 |
+
<li class="sidebar-item">
|
172 |
+
<div class="sidebar-item-container">
|
173 |
+
<a href="./cw004reducegrow.html" class="sidebar-item-text sidebar-link">
|
174 |
+
<span class="menu-text"><span class="chapter-number">4</span> <span class="chapter-title">Beginner - Reduce but Grow</span></span></a>
|
175 |
+
</div>
|
176 |
+
</li>
|
177 |
+
<li class="sidebar-item">
|
178 |
+
<div class="sidebar-item-container">
|
179 |
+
<a href="./cw005make_negative.html" class="sidebar-item-text sidebar-link">
|
180 |
+
<span class="menu-text"><span class="chapter-number">5</span> <span class="chapter-title">Return Negative</span></span></a>
|
181 |
+
</div>
|
182 |
+
</li>
|
183 |
+
<li class="sidebar-item">
|
184 |
+
<div class="sidebar-item-container">
|
185 |
+
<a href="./cw006positive_sum.html" class="sidebar-item-text sidebar-link">
|
186 |
+
<span class="menu-text"><span class="chapter-number">6</span> <span class="chapter-title">Sum of positive</span></span></a>
|
187 |
+
</div>
|
188 |
+
</li>
|
189 |
+
<li class="sidebar-item">
|
190 |
+
<div class="sidebar-item-container">
|
191 |
+
<a href="./cw007reversedstrings.html" class="sidebar-item-text sidebar-link active">
|
192 |
+
<span class="menu-text"><span class="chapter-number">7</span> <span class="chapter-title">Reversed Strings</span></span></a>
|
193 |
+
</div>
|
194 |
+
</li>
|
195 |
+
<li class="sidebar-item">
|
196 |
+
<div class="sidebar-item-container">
|
197 |
+
<a href="./cw008bool_to_word.html" class="sidebar-item-text sidebar-link">
|
198 |
+
<span class="menu-text"><span class="chapter-number">8</span> <span class="chapter-title">Convert boolean values to strings ‘Yes’ or ‘No’</span></span></a>
|
199 |
+
</div>
|
200 |
+
</li>
|
201 |
+
</ul>
|
202 |
+
</div>
|
203 |
+
</nav>
|
204 |
+
<div id="quarto-sidebar-glass" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass"></div>
|
205 |
+
<!-- margin-sidebar -->
|
206 |
+
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
|
207 |
+
<nav id="TOC" role="doc-toc" class="toc-active">
|
208 |
+
<h2 id="toc-title">Table of contents</h2>
|
209 |
+
|
210 |
+
<ul>
|
211 |
+
<li><a href="#instruction" id="toc-instruction" class="nav-link active" data-scroll-target="#instruction"><span class="header-section-number">7.1</span> Instruction</a></li>
|
212 |
+
<li><a href="#youtube-video" id="toc-youtube-video" class="nav-link" data-scroll-target="#youtube-video"><span class="header-section-number">7.2</span> YouTube Video</a></li>
|
213 |
+
<li><a href="#solution-code" id="toc-solution-code" class="nav-link" data-scroll-target="#solution-code"><span class="header-section-number">7.3</span> Solution Code</a></li>
|
214 |
+
<li><a href="#test" id="toc-test" class="nav-link" data-scroll-target="#test"><span class="header-section-number">7.4</span> Test</a></li>
|
215 |
+
<li><a href="#supported-by" id="toc-supported-by" class="nav-link" data-scroll-target="#supported-by"><span class="header-section-number">7.5</span> Supported by</a></li>
|
216 |
+
</ul>
|
217 |
+
</nav>
|
218 |
+
</div>
|
219 |
+
<!-- main -->
|
220 |
+
<main class="content" id="quarto-document-content">
|
221 |
+
|
222 |
+
<header id="title-block-header" class="quarto-title-block default">
|
223 |
+
<div class="quarto-title">
|
224 |
+
<h1 class="title"><span class="chapter-number">7</span> <span class="chapter-title">Reversed Strings</span></h1>
|
225 |
+
</div>
|
226 |
+
|
227 |
+
|
228 |
+
|
229 |
+
<div class="quarto-title-meta">
|
230 |
+
|
231 |
+
|
232 |
+
|
233 |
+
|
234 |
+
</div>
|
235 |
+
|
236 |
+
|
237 |
+
</header>
|
238 |
+
|
239 |
+
<p>Tantangan #7/366 - 21 Feb 2024</p>
|
240 |
+
<p><a href="https://www.codewars.com/kata/5168bb5dfe9a00b126000018/train/r" class="uri">https://www.codewars.com/kata/5168bb5dfe9a00b126000018/train/r</a></p>
|
241 |
+
<p><span class="badge rounded-pill quarto-badge " style="background-color: grey;">8kyu</span> Reversed Strings</p>
|
242 |
+
<section id="instruction" class="level2" data-number="7.1">
|
243 |
+
<h2 data-number="7.1" class="anchored" data-anchor-id="instruction"><span class="header-section-number">7.1</span> Instruction</h2>
|
244 |
+
<p>Complete the solution so that it reverses the string passed into it.</p>
|
245 |
+
<pre><code>'world' => 'dlrow'
|
246 |
+
'word' => 'drow'</code></pre>
|
247 |
+
</section>
|
248 |
+
<section id="youtube-video" class="level2" data-number="7.2">
|
249 |
+
<h2 data-number="7.2" class="anchored" data-anchor-id="youtube-video"><span class="header-section-number">7.2</span> YouTube Video</h2>
|
250 |
+
<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>
|
251 |
+
</section>
|
252 |
+
<section id="solution-code" class="level2" data-number="7.3">
|
253 |
+
<h2 data-number="7.3" class="anchored" data-anchor-id="solution-code"><span class="header-section-number">7.3</span> Solution Code</h2>
|
254 |
+
<p>Solusi bar-bar</p>
|
255 |
+
<div class="cell">
|
256 |
+
<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>solution <span class="ot"><-</span> <span class="cf">function</span>(s){</span>
|
257 |
+
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> str_split <span class="ot"><-</span> <span class="fu">unlist</span>(<span class="fu">strsplit</span>(s, <span class="st">""</span>))</span>
|
258 |
+
<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>
|
259 |
+
</div>
|
260 |
+
<p>Solusi simple</p>
|
261 |
+
<div class="cell">
|
262 |
+
<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>solution <span class="ot"><-</span> <span class="cf">function</span>(s){</span>
|
263 |
+
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">paste</span>(<span class="fu">rev</span>(<span class="fu">unlist</span>(<span class="fu">strsplit</span>(s, <span class="st">""</span>))), <span class="at">collapse =</span> <span class="st">""</span>)</span>
|
264 |
+
<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>
|
265 |
+
</div>
|
266 |
+
</section>
|
267 |
+
<section id="test" class="level2" data-number="7.4">
|
268 |
+
<h2 data-number="7.4" class="anchored" data-anchor-id="test"><span class="header-section-number">7.4</span> Test</h2>
|
269 |
+
<div class="cell">
|
270 |
+
<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>
|
271 |
+
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a></span>
|
272 |
+
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a><span class="fu">test_that</span>(<span class="st">"example"</span>, {</span>
|
273 |
+
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">expect_equal</span>(<span class="fu">solution</span>(<span class="st">'world'</span>), <span class="st">'dlrow'</span>)</span>
|
274 |
+
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">expect_equal</span>(<span class="fu">solution</span>(<span class="st">'hello'</span>), <span class="st">'olleh'</span>)</span>
|
275 |
+
<span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">expect_equal</span>(<span class="fu">solution</span>(<span class="st">''</span>), <span class="st">''</span>)</span>
|
276 |
+
<span id="cb4-7"><a href="#cb4-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">expect_equal</span>(<span class="fu">solution</span>(<span class="st">'h'</span>), <span class="st">'h'</span>)</span>
|
277 |
+
<span id="cb4-8"><a href="#cb4-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>
|
278 |
+
<div class="cell-output cell-output-stdout">
|
279 |
+
<pre><code>Test passed 🥇</code></pre>
|
280 |
+
</div>
|
281 |
+
</div>
|
282 |
+
</section>
|
283 |
+
<section id="supported-by" class="level2" data-number="7.5">
|
284 |
+
<h2 data-number="7.5" class="anchored" data-anchor-id="supported-by"><span class="header-section-number">7.5</span> Supported by</h2>
|
285 |
+
<div class="quarto-figure quarto-figure-center">
|
286 |
+
<figure class="figure">
|
287 |
+
<p><a href="https://www.starcore.co"><img src="new_starcore_logo.png" class="img-fluid figure-img"></a></p>
|
288 |
+
<figcaption class="figure-caption">StarCore Analytics</figcaption>
|
289 |
+
</figure>
|
290 |
+
</div>
|
291 |
+
|
292 |
+
|
293 |
+
</section>
|
294 |
+
|
295 |
+
</main> <!-- /main -->
|
296 |
+
<script id="quarto-html-after-body" type="application/javascript">
|
297 |
+
window.document.addEventListener("DOMContentLoaded", function (event) {
|
298 |
+
const toggleBodyColorMode = (bsSheetEl) => {
|
299 |
+
const mode = bsSheetEl.getAttribute("data-mode");
|
300 |
+
const bodyEl = window.document.querySelector("body");
|
301 |
+
if (mode === "dark") {
|
302 |
+
bodyEl.classList.add("quarto-dark");
|
303 |
+
bodyEl.classList.remove("quarto-light");
|
304 |
+
} else {
|
305 |
+
bodyEl.classList.add("quarto-light");
|
306 |
+
bodyEl.classList.remove("quarto-dark");
|
307 |
+
}
|
308 |
+
}
|
309 |
+
const toggleBodyColorPrimary = () => {
|
310 |
+
const bsSheetEl = window.document.querySelector("link#quarto-bootstrap");
|
311 |
+
if (bsSheetEl) {
|
312 |
+
toggleBodyColorMode(bsSheetEl);
|
313 |
+
}
|
314 |
+
}
|
315 |
+
toggleBodyColorPrimary();
|
316 |
+
const icon = "";
|
317 |
+
const anchorJS = new window.AnchorJS();
|
318 |
+
anchorJS.options = {
|
319 |
+
placement: 'right',
|
320 |
+
icon: icon
|
321 |
+
};
|
322 |
+
anchorJS.add('.anchored');
|
323 |
+
const isCodeAnnotation = (el) => {
|
324 |
+
for (const clz of el.classList) {
|
325 |
+
if (clz.startsWith('code-annotation-')) {
|
326 |
+
return true;
|
327 |
+
}
|
328 |
+
}
|
329 |
+
return false;
|
330 |
+
}
|
331 |
+
const clipboard = new window.ClipboardJS('.code-copy-button', {
|
332 |
+
text: function(trigger) {
|
333 |
+
const codeEl = trigger.previousElementSibling.cloneNode(true);
|
334 |
+
for (const childEl of codeEl.children) {
|
335 |
+
if (isCodeAnnotation(childEl)) {
|
336 |
+
childEl.remove();
|
337 |
+
}
|
338 |
+
}
|
339 |
+
return codeEl.innerText;
|
340 |
+
}
|
341 |
+
});
|
342 |
+
clipboard.on('success', function(e) {
|
343 |
+
// button target
|
344 |
+
const button = e.trigger;
|
345 |
+
// don't keep focus
|
346 |
+
button.blur();
|
347 |
+
// flash "checked"
|
348 |
+
button.classList.add('code-copy-button-checked');
|
349 |
+
var currentTitle = button.getAttribute("title");
|
350 |
+
button.setAttribute("title", "Copied!");
|
351 |
+
let tooltip;
|
352 |
+
if (window.bootstrap) {
|
353 |
+
button.setAttribute("data-bs-toggle", "tooltip");
|
354 |
+
button.setAttribute("data-bs-placement", "left");
|
355 |
+
button.setAttribute("data-bs-title", "Copied!");
|
356 |
+
tooltip = new bootstrap.Tooltip(button,
|
357 |
+
{ trigger: "manual",
|
358 |
+
customClass: "code-copy-button-tooltip",
|
359 |
+
offset: [0, -8]});
|
360 |
+
tooltip.show();
|
361 |
+
}
|
362 |
+
setTimeout(function() {
|
363 |
+
if (tooltip) {
|
364 |
+
tooltip.hide();
|
365 |
+
button.removeAttribute("data-bs-title");
|
366 |
+
button.removeAttribute("data-bs-toggle");
|
367 |
+
button.removeAttribute("data-bs-placement");
|
368 |
+
}
|
369 |
+
button.setAttribute("title", currentTitle);
|
370 |
+
button.classList.remove('code-copy-button-checked');
|
371 |
+
}, 1000);
|
372 |
+
// clear code selection
|
373 |
+
e.clearSelection();
|
374 |
+
});
|
375 |
+
function tippyHover(el, contentFn) {
|
376 |
+
const config = {
|
377 |
+
allowHTML: true,
|
378 |
+
content: contentFn,
|
379 |
+
maxWidth: 500,
|
380 |
+
delay: 100,
|
381 |
+
arrow: false,
|
382 |
+
appendTo: function(el) {
|
383 |
+
return el.parentElement;
|
384 |
+
},
|
385 |
+
interactive: true,
|
386 |
+
interactiveBorder: 10,
|
387 |
+
theme: 'quarto',
|
388 |
+
placement: 'bottom-start'
|
389 |
+
};
|
390 |
+
window.tippy(el, config);
|
391 |
+
}
|
392 |
+
const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
|
393 |
+
for (var i=0; i<noterefs.length; i++) {
|
394 |
+
const ref = noterefs[i];
|
395 |
+
tippyHover(ref, function() {
|
396 |
+
// use id or data attribute instead here
|
397 |
+
let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
|
398 |
+
try { href = new URL(href).hash; } catch {}
|
399 |
+
const id = href.replace(/^#\/?/, "");
|
400 |
+
const note = window.document.getElementById(id);
|
401 |
+
return note.innerHTML;
|
402 |
+
});
|
403 |
+
}
|
404 |
+
let selectedAnnoteEl;
|
405 |
+
const selectorForAnnotation = ( cell, annotation) => {
|
406 |
+
let cellAttr = 'data-code-cell="' + cell + '"';
|
407 |
+
let lineAttr = 'data-code-annotation="' + annotation + '"';
|
408 |
+
const selector = 'span[' + cellAttr + '][' + lineAttr + ']';
|
409 |
+
return selector;
|
410 |
+
}
|
411 |
+
const selectCodeLines = (annoteEl) => {
|
412 |
+
const doc = window.document;
|
413 |
+
const targetCell = annoteEl.getAttribute("data-target-cell");
|
414 |
+
const targetAnnotation = annoteEl.getAttribute("data-target-annotation");
|
415 |
+
const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation));
|
416 |
+
const lines = annoteSpan.getAttribute("data-code-lines").split(",");
|
417 |
+
const lineIds = lines.map((line) => {
|
418 |
+
return targetCell + "-" + line;
|
419 |
+
})
|
420 |
+
let top = null;
|
421 |
+
let height = null;
|
422 |
+
let parent = null;
|
423 |
+
if (lineIds.length > 0) {
|
424 |
+
//compute the position of the single el (top and bottom and make a div)
|
425 |
+
const el = window.document.getElementById(lineIds[0]);
|
426 |
+
top = el.offsetTop;
|
427 |
+
height = el.offsetHeight;
|
428 |
+
parent = el.parentElement.parentElement;
|
429 |
+
if (lineIds.length > 1) {
|
430 |
+
const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]);
|
431 |
+
const bottom = lastEl.offsetTop + lastEl.offsetHeight;
|
432 |
+
height = bottom - top;
|
433 |
+
}
|
434 |
+
if (top !== null && height !== null && parent !== null) {
|
435 |
+
// cook up a div (if necessary) and position it
|
436 |
+
let div = window.document.getElementById("code-annotation-line-highlight");
|
437 |
+
if (div === null) {
|
438 |
+
div = window.document.createElement("div");
|
439 |
+
div.setAttribute("id", "code-annotation-line-highlight");
|
440 |
+
div.style.position = 'absolute';
|
441 |
+
parent.appendChild(div);
|
442 |
+
}
|
443 |
+
div.style.top = top - 2 + "px";
|
444 |
+
div.style.height = height + 4 + "px";
|
445 |
+
let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter");
|
446 |
+
if (gutterDiv === null) {
|
447 |
+
gutterDiv = window.document.createElement("div");
|
448 |
+
gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter");
|
449 |
+
gutterDiv.style.position = 'absolute';
|
450 |
+
const codeCell = window.document.getElementById(targetCell);
|
451 |
+
const gutter = codeCell.querySelector('.code-annotation-gutter');
|
452 |
+
gutter.appendChild(gutterDiv);
|
453 |
+
}
|
454 |
+
gutterDiv.style.top = top - 2 + "px";
|
455 |
+
gutterDiv.style.height = height + 4 + "px";
|
456 |
+
}
|
457 |
+
selectedAnnoteEl = annoteEl;
|
458 |
+
}
|
459 |
+
};
|
460 |
+
const unselectCodeLines = () => {
|
461 |
+
const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"];
|
462 |
+
elementsIds.forEach((elId) => {
|
463 |
+
const div = window.document.getElementById(elId);
|
464 |
+
if (div) {
|
465 |
+
div.remove();
|
466 |
+
}
|
467 |
+
});
|
468 |
+
selectedAnnoteEl = undefined;
|
469 |
+
};
|
470 |
+
// Attach click handler to the DT
|
471 |
+
const annoteDls = window.document.querySelectorAll('dt[data-target-cell]');
|
472 |
+
for (const annoteDlNode of annoteDls) {
|
473 |
+
annoteDlNode.addEventListener('click', (event) => {
|
474 |
+
const clickedEl = event.target;
|
475 |
+
if (clickedEl !== selectedAnnoteEl) {
|
476 |
+
unselectCodeLines();
|
477 |
+
const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active');
|
478 |
+
if (activeEl) {
|
479 |
+
activeEl.classList.remove('code-annotation-active');
|
480 |
+
}
|
481 |
+
selectCodeLines(clickedEl);
|
482 |
+
clickedEl.classList.add('code-annotation-active');
|
483 |
+
} else {
|
484 |
+
// Unselect the line
|
485 |
+
unselectCodeLines();
|
486 |
+
clickedEl.classList.remove('code-annotation-active');
|
487 |
+
}
|
488 |
+
});
|
489 |
+
}
|
490 |
+
const findCites = (el) => {
|
491 |
+
const parentEl = el.parentElement;
|
492 |
+
if (parentEl) {
|
493 |
+
const cites = parentEl.dataset.cites;
|
494 |
+
if (cites) {
|
495 |
+
return {
|
496 |
+
el,
|
497 |
+
cites: cites.split(' ')
|
498 |
+
};
|
499 |
+
} else {
|
500 |
+
return findCites(el.parentElement)
|
501 |
+
}
|
502 |
+
} else {
|
503 |
+
return undefined;
|
504 |
+
}
|
505 |
+
};
|
506 |
+
var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
|
507 |
+
for (var i=0; i<bibliorefs.length; i++) {
|
508 |
+
const ref = bibliorefs[i];
|
509 |
+
const citeInfo = findCites(ref);
|
510 |
+
if (citeInfo) {
|
511 |
+
tippyHover(citeInfo.el, function() {
|
512 |
+
var popup = window.document.createElement('div');
|
513 |
+
citeInfo.cites.forEach(function(cite) {
|
514 |
+
var citeDiv = window.document.createElement('div');
|
515 |
+
citeDiv.classList.add('hanging-indent');
|
516 |
+
citeDiv.classList.add('csl-entry');
|
517 |
+
var biblioDiv = window.document.getElementById('ref-' + cite);
|
518 |
+
if (biblioDiv) {
|
519 |
+
citeDiv.innerHTML = biblioDiv.innerHTML;
|
520 |
+
}
|
521 |
+
popup.appendChild(citeDiv);
|
522 |
+
});
|
523 |
+
return popup.innerHTML;
|
524 |
+
});
|
525 |
+
}
|
526 |
+
}
|
527 |
+
});
|
528 |
+
</script>
|
529 |
+
<nav class="page-navigation">
|
530 |
+
<div class="nav-page nav-page-previous">
|
531 |
+
<a href="./cw006positive_sum.html" class="pagination-link">
|
532 |
+
<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>
|
533 |
+
</a>
|
534 |
+
</div>
|
535 |
+
<div class="nav-page nav-page-next">
|
536 |
+
<a href="./cw008bool_to_word.html" class="pagination-link">
|
537 |
+
<span class="nav-page-text"><span class="chapter-number">8</span> <span class="chapter-title">Convert boolean values to strings ‘Yes’ or ‘No’</span></span> <i class="bi bi-arrow-right-short"></i>
|
538 |
+
</a>
|
539 |
+
</div>
|
540 |
+
</nav>
|
541 |
+
</div> <!-- /content -->
|
542 |
+
|
543 |
+
|
544 |
+
|
545 |
+
</body></html>
|
cw008bool_to_word.html
ADDED
@@ -0,0 +1,530 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 - 8 Convert boolean values to strings ‘Yes’ or ‘No’</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="./cw007reversedstrings.html" rel="prev">
|
68 |
+
<link href="./logo.png" rel="icon" type="image/png">
|
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 |
+
<meta name="twitter:title" content="Codewars Challenge 2024 Menggunakan R dan RStudio - 8 Convert boolean values to strings ‘Yes’ or ‘No’">
|
102 |
+
<meta name="twitter:description" content="">
|
103 |
+
<meta name="twitter:image" content="https://huggingface.co/spaces/aephidayatuloh/codewars2024/new_starcore_logo.png">
|
104 |
+
<meta name="twitter:image-height" content="434">
|
105 |
+
<meta name="twitter:image-width" content="1946">
|
106 |
+
<meta name="twitter:card" content="summary_large_image">
|
107 |
+
</head>
|
108 |
+
|
109 |
+
<body class="nav-sidebar floating">
|
110 |
+
|
111 |
+
<div id="quarto-search-results"></div>
|
112 |
+
<header id="quarto-header" class="headroom fixed-top">
|
113 |
+
<nav class="quarto-secondary-nav">
|
114 |
+
<div class="container-fluid d-flex">
|
115 |
+
<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(); }">
|
116 |
+
<i class="bi bi-layout-text-sidebar-reverse"></i>
|
117 |
+
</button>
|
118 |
+
<nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="./cw008bool_to_word.html"><span class="chapter-number">8</span> <span class="chapter-title">Convert boolean values to strings 'Yes' or 'No'</span></a></li></ol></nav>
|
119 |
+
<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(); }">
|
120 |
+
</a>
|
121 |
+
<button type="button" class="btn quarto-search-button" aria-label="" onclick="window.quartoOpenSearch();">
|
122 |
+
<i class="bi bi-search"></i>
|
123 |
+
</button>
|
124 |
+
</div>
|
125 |
+
</nav>
|
126 |
+
</header>
|
127 |
+
<!-- content -->
|
128 |
+
<div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article">
|
129 |
+
<!-- sidebar -->
|
130 |
+
<nav id="quarto-sidebar" class="sidebar collapse collapse-horizontal sidebar-navigation floating overflow-auto">
|
131 |
+
<div class="pt-lg-2 mt-2 text-left sidebar-header">
|
132 |
+
<div class="sidebar-title mb-0 py-0">
|
133 |
+
<a href="./">Codewars Challenge 2024 Menggunakan R dan RStudio</a>
|
134 |
+
<div class="sidebar-tools-main">
|
135 |
+
<a href="https://huggingface.co/spaces/aephidayatuloh/codewars2024/tree/main" rel="" title="Source Code" class="quarto-navigation-tool px-1" aria-label="Source Code"><i class="bi bi-git"></i></a>
|
136 |
+
</div>
|
137 |
+
</div>
|
138 |
+
</div>
|
139 |
+
<div class="mt-2 flex-shrink-0 align-items-center">
|
140 |
+
<div class="sidebar-search">
|
141 |
+
<div id="quarto-search" class="" title="Search"></div>
|
142 |
+
</div>
|
143 |
+
</div>
|
144 |
+
<div class="sidebar-menu-container">
|
145 |
+
<ul class="list-unstyled mt-1">
|
146 |
+
<li class="sidebar-item">
|
147 |
+
<div class="sidebar-item-container">
|
148 |
+
<a href="./index.html" class="sidebar-item-text sidebar-link">
|
149 |
+
<span class="menu-text">Pengantar</span></a>
|
150 |
+
</div>
|
151 |
+
</li>
|
152 |
+
<li class="sidebar-item">
|
153 |
+
<div class="sidebar-item-container">
|
154 |
+
<a href="./cw001evenodd.html" class="sidebar-item-text sidebar-link">
|
155 |
+
<span class="menu-text"><span class="chapter-number">1</span> <span class="chapter-title">Even or Odd</span></span></a>
|
156 |
+
</div>
|
157 |
+
</li>
|
158 |
+
<li class="sidebar-item">
|
159 |
+
<div class="sidebar-item-container">
|
160 |
+
<a href="./cw002multiply.html" class="sidebar-item-text sidebar-link">
|
161 |
+
<span class="menu-text"><span class="chapter-number">2</span> <span class="chapter-title">Multiply</span></span></a>
|
162 |
+
</div>
|
163 |
+
</li>
|
164 |
+
<li class="sidebar-item">
|
165 |
+
<div class="sidebar-item-container">
|
166 |
+
<a href="./cw003countsheep.html" class="sidebar-item-text sidebar-link">
|
167 |
+
<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>
|
168 |
+
</div>
|
169 |
+
</li>
|
170 |
+
<li class="sidebar-item">
|
171 |
+
<div class="sidebar-item-container">
|
172 |
+
<a href="./cw004reducegrow.html" class="sidebar-item-text sidebar-link">
|
173 |
+
<span class="menu-text"><span class="chapter-number">4</span> <span class="chapter-title">Beginner - Reduce but Grow</span></span></a>
|
174 |
+
</div>
|
175 |
+
</li>
|
176 |
+
<li class="sidebar-item">
|
177 |
+
<div class="sidebar-item-container">
|
178 |
+
<a href="./cw005make_negative.html" class="sidebar-item-text sidebar-link">
|
179 |
+
<span class="menu-text"><span class="chapter-number">5</span> <span class="chapter-title">Return Negative</span></span></a>
|
180 |
+
</div>
|
181 |
+
</li>
|
182 |
+
<li class="sidebar-item">
|
183 |
+
<div class="sidebar-item-container">
|
184 |
+
<a href="./cw006positive_sum.html" class="sidebar-item-text sidebar-link">
|
185 |
+
<span class="menu-text"><span class="chapter-number">6</span> <span class="chapter-title">Sum of positive</span></span></a>
|
186 |
+
</div>
|
187 |
+
</li>
|
188 |
+
<li class="sidebar-item">
|
189 |
+
<div class="sidebar-item-container">
|
190 |
+
<a href="./cw007reversedstrings.html" class="sidebar-item-text sidebar-link">
|
191 |
+
<span class="menu-text"><span class="chapter-number">7</span> <span class="chapter-title">Reversed Strings</span></span></a>
|
192 |
+
</div>
|
193 |
+
</li>
|
194 |
+
<li class="sidebar-item">
|
195 |
+
<div class="sidebar-item-container">
|
196 |
+
<a href="./cw008bool_to_word.html" class="sidebar-item-text sidebar-link active">
|
197 |
+
<span class="menu-text"><span class="chapter-number">8</span> <span class="chapter-title">Convert boolean values to strings ‘Yes’ or ‘No’</span></span></a>
|
198 |
+
</div>
|
199 |
+
</li>
|
200 |
+
</ul>
|
201 |
+
</div>
|
202 |
+
</nav>
|
203 |
+
<div id="quarto-sidebar-glass" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass"></div>
|
204 |
+
<!-- margin-sidebar -->
|
205 |
+
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
|
206 |
+
<nav id="TOC" role="doc-toc" class="toc-active">
|
207 |
+
<h2 id="toc-title">Table of contents</h2>
|
208 |
+
|
209 |
+
<ul>
|
210 |
+
<li><a href="#instruction" id="toc-instruction" class="nav-link active" data-scroll-target="#instruction"><span class="header-section-number">8.1</span> Instruction</a></li>
|
211 |
+
<li><a href="#youtube-video" id="toc-youtube-video" class="nav-link" data-scroll-target="#youtube-video"><span class="header-section-number">8.2</span> YouTube Video</a></li>
|
212 |
+
<li><a href="#solution-code" id="toc-solution-code" class="nav-link" data-scroll-target="#solution-code"><span class="header-section-number">8.3</span> Solution Code</a></li>
|
213 |
+
<li><a href="#test" id="toc-test" class="nav-link" data-scroll-target="#test"><span class="header-section-number">8.4</span> Test</a></li>
|
214 |
+
<li><a href="#supported-by" id="toc-supported-by" class="nav-link" data-scroll-target="#supported-by"><span class="header-section-number">8.5</span> Supported by</a></li>
|
215 |
+
</ul>
|
216 |
+
</nav>
|
217 |
+
</div>
|
218 |
+
<!-- main -->
|
219 |
+
<main class="content" id="quarto-document-content">
|
220 |
+
|
221 |
+
<header id="title-block-header" class="quarto-title-block default">
|
222 |
+
<div class="quarto-title">
|
223 |
+
<h1 class="title"><span class="chapter-number">8</span> <span class="chapter-title">Convert boolean values to strings ‘Yes’ or ‘No’</span></h1>
|
224 |
+
</div>
|
225 |
+
|
226 |
+
|
227 |
+
|
228 |
+
<div class="quarto-title-meta">
|
229 |
+
|
230 |
+
|
231 |
+
|
232 |
+
|
233 |
+
</div>
|
234 |
+
|
235 |
+
|
236 |
+
</header>
|
237 |
+
|
238 |
+
<p><span class="badge rounded-pill quarto-badge " style="background-color: grey;">8kyu</span> Tantangan #8/366 - 22 Feb 2024</p>
|
239 |
+
<p><a href="https://www.codewars.com/kata/53369039d7ab3ac506000467/train/r" class="uri">https://www.codewars.com/kata/53369039d7ab3ac506000467/train/r</a></p>
|
240 |
+
<section id="instruction" class="level2" data-number="8.1">
|
241 |
+
<h2 data-number="8.1" class="anchored" data-anchor-id="instruction"><span class="header-section-number">8.1</span> Instruction</h2>
|
242 |
+
<p>Complete the method that takes a boolean value and return a <code>"Yes"</code> string for <code>true</code>, or a <code>"No"</code> string for <code>false</code>.</p>
|
243 |
+
</section>
|
244 |
+
<section id="youtube-video" class="level2" data-number="8.2">
|
245 |
+
<h2 data-number="8.2" class="anchored" data-anchor-id="youtube-video"><span class="header-section-number">8.2</span> YouTube Video</h2>
|
246 |
+
<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>
|
247 |
+
</section>
|
248 |
+
<section id="solution-code" class="level2" data-number="8.3">
|
249 |
+
<h2 data-number="8.3" class="anchored" data-anchor-id="solution-code"><span class="header-section-number">8.3</span> Solution Code</h2>
|
250 |
+
<p>Solusi bar-bar</p>
|
251 |
+
<div class="cell">
|
252 |
+
<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>bool_to_word <span class="ot"><-</span> <span class="cf">function</span>(bool){</span>
|
253 |
+
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">ifelse</span>(bool, <span class="st">"Yes"</span>, <span class="st">"No"</span>)</span>
|
254 |
+
<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>
|
255 |
+
</div>
|
256 |
+
</section>
|
257 |
+
<section id="test" class="level2" data-number="8.4">
|
258 |
+
<h2 data-number="8.4" class="anchored" data-anchor-id="test"><span class="header-section-number">8.4</span> Test</h2>
|
259 |
+
<div class="cell">
|
260 |
+
<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><span class="fu">library</span>(testthat)</span>
|
261 |
+
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a></span>
|
262 |
+
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="fu">test_that</span>(<span class="st">'Basic tests'</span>, {</span>
|
263 |
+
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">expect_equal</span>(<span class="fu">bool_to_word</span>(<span class="cn">TRUE</span>), <span class="st">'Yes'</span>)</span>
|
264 |
+
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">expect_equal</span>(<span class="fu">bool_to_word</span>(<span class="cn">FALSE</span>), <span class="st">'No'</span>)</span>
|
265 |
+
<span id="cb2-6"><a href="#cb2-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>
|
266 |
+
<div class="cell-output cell-output-stdout">
|
267 |
+
<pre><code>Test passed 🎊</code></pre>
|
268 |
+
</div>
|
269 |
+
</div>
|
270 |
+
</section>
|
271 |
+
<section id="supported-by" class="level2" data-number="8.5">
|
272 |
+
<h2 data-number="8.5" class="anchored" data-anchor-id="supported-by"><span class="header-section-number">8.5</span> Supported by</h2>
|
273 |
+
<div class="quarto-figure quarto-figure-center">
|
274 |
+
<figure class="figure">
|
275 |
+
<p><a href="https://www.starcore.co"><img src="new_starcore_logo.png" class="img-fluid figure-img"></a></p>
|
276 |
+
<figcaption class="figure-caption">StarCore Analytics</figcaption>
|
277 |
+
</figure>
|
278 |
+
</div>
|
279 |
+
|
280 |
+
|
281 |
+
</section>
|
282 |
+
|
283 |
+
</main> <!-- /main -->
|
284 |
+
<script id="quarto-html-after-body" type="application/javascript">
|
285 |
+
window.document.addEventListener("DOMContentLoaded", function (event) {
|
286 |
+
const toggleBodyColorMode = (bsSheetEl) => {
|
287 |
+
const mode = bsSheetEl.getAttribute("data-mode");
|
288 |
+
const bodyEl = window.document.querySelector("body");
|
289 |
+
if (mode === "dark") {
|
290 |
+
bodyEl.classList.add("quarto-dark");
|
291 |
+
bodyEl.classList.remove("quarto-light");
|
292 |
+
} else {
|
293 |
+
bodyEl.classList.add("quarto-light");
|
294 |
+
bodyEl.classList.remove("quarto-dark");
|
295 |
+
}
|
296 |
+
}
|
297 |
+
const toggleBodyColorPrimary = () => {
|
298 |
+
const bsSheetEl = window.document.querySelector("link#quarto-bootstrap");
|
299 |
+
if (bsSheetEl) {
|
300 |
+
toggleBodyColorMode(bsSheetEl);
|
301 |
+
}
|
302 |
+
}
|
303 |
+
toggleBodyColorPrimary();
|
304 |
+
const icon = "";
|
305 |
+
const anchorJS = new window.AnchorJS();
|
306 |
+
anchorJS.options = {
|
307 |
+
placement: 'right',
|
308 |
+
icon: icon
|
309 |
+
};
|
310 |
+
anchorJS.add('.anchored');
|
311 |
+
const isCodeAnnotation = (el) => {
|
312 |
+
for (const clz of el.classList) {
|
313 |
+
if (clz.startsWith('code-annotation-')) {
|
314 |
+
return true;
|
315 |
+
}
|
316 |
+
}
|
317 |
+
return false;
|
318 |
+
}
|
319 |
+
const clipboard = new window.ClipboardJS('.code-copy-button', {
|
320 |
+
text: function(trigger) {
|
321 |
+
const codeEl = trigger.previousElementSibling.cloneNode(true);
|
322 |
+
for (const childEl of codeEl.children) {
|
323 |
+
if (isCodeAnnotation(childEl)) {
|
324 |
+
childEl.remove();
|
325 |
+
}
|
326 |
+
}
|
327 |
+
return codeEl.innerText;
|
328 |
+
}
|
329 |
+
});
|
330 |
+
clipboard.on('success', function(e) {
|
331 |
+
// button target
|
332 |
+
const button = e.trigger;
|
333 |
+
// don't keep focus
|
334 |
+
button.blur();
|
335 |
+
// flash "checked"
|
336 |
+
button.classList.add('code-copy-button-checked');
|
337 |
+
var currentTitle = button.getAttribute("title");
|
338 |
+
button.setAttribute("title", "Copied!");
|
339 |
+
let tooltip;
|
340 |
+
if (window.bootstrap) {
|
341 |
+
button.setAttribute("data-bs-toggle", "tooltip");
|
342 |
+
button.setAttribute("data-bs-placement", "left");
|
343 |
+
button.setAttribute("data-bs-title", "Copied!");
|
344 |
+
tooltip = new bootstrap.Tooltip(button,
|
345 |
+
{ trigger: "manual",
|
346 |
+
customClass: "code-copy-button-tooltip",
|
347 |
+
offset: [0, -8]});
|
348 |
+
tooltip.show();
|
349 |
+
}
|
350 |
+
setTimeout(function() {
|
351 |
+
if (tooltip) {
|
352 |
+
tooltip.hide();
|
353 |
+
button.removeAttribute("data-bs-title");
|
354 |
+
button.removeAttribute("data-bs-toggle");
|
355 |
+
button.removeAttribute("data-bs-placement");
|
356 |
+
}
|
357 |
+
button.setAttribute("title", currentTitle);
|
358 |
+
button.classList.remove('code-copy-button-checked');
|
359 |
+
}, 1000);
|
360 |
+
// clear code selection
|
361 |
+
e.clearSelection();
|
362 |
+
});
|
363 |
+
function tippyHover(el, contentFn) {
|
364 |
+
const config = {
|
365 |
+
allowHTML: true,
|
366 |
+
content: contentFn,
|
367 |
+
maxWidth: 500,
|
368 |
+
delay: 100,
|
369 |
+
arrow: false,
|
370 |
+
appendTo: function(el) {
|
371 |
+
return el.parentElement;
|
372 |
+
},
|
373 |
+
interactive: true,
|
374 |
+
interactiveBorder: 10,
|
375 |
+
theme: 'quarto',
|
376 |
+
placement: 'bottom-start'
|
377 |
+
};
|
378 |
+
window.tippy(el, config);
|
379 |
+
}
|
380 |
+
const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
|
381 |
+
for (var i=0; i<noterefs.length; i++) {
|
382 |
+
const ref = noterefs[i];
|
383 |
+
tippyHover(ref, function() {
|
384 |
+
// use id or data attribute instead here
|
385 |
+
let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
|
386 |
+
try { href = new URL(href).hash; } catch {}
|
387 |
+
const id = href.replace(/^#\/?/, "");
|
388 |
+
const note = window.document.getElementById(id);
|
389 |
+
return note.innerHTML;
|
390 |
+
});
|
391 |
+
}
|
392 |
+
let selectedAnnoteEl;
|
393 |
+
const selectorForAnnotation = ( cell, annotation) => {
|
394 |
+
let cellAttr = 'data-code-cell="' + cell + '"';
|
395 |
+
let lineAttr = 'data-code-annotation="' + annotation + '"';
|
396 |
+
const selector = 'span[' + cellAttr + '][' + lineAttr + ']';
|
397 |
+
return selector;
|
398 |
+
}
|
399 |
+
const selectCodeLines = (annoteEl) => {
|
400 |
+
const doc = window.document;
|
401 |
+
const targetCell = annoteEl.getAttribute("data-target-cell");
|
402 |
+
const targetAnnotation = annoteEl.getAttribute("data-target-annotation");
|
403 |
+
const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation));
|
404 |
+
const lines = annoteSpan.getAttribute("data-code-lines").split(",");
|
405 |
+
const lineIds = lines.map((line) => {
|
406 |
+
return targetCell + "-" + line;
|
407 |
+
})
|
408 |
+
let top = null;
|
409 |
+
let height = null;
|
410 |
+
let parent = null;
|
411 |
+
if (lineIds.length > 0) {
|
412 |
+
//compute the position of the single el (top and bottom and make a div)
|
413 |
+
const el = window.document.getElementById(lineIds[0]);
|
414 |
+
top = el.offsetTop;
|
415 |
+
height = el.offsetHeight;
|
416 |
+
parent = el.parentElement.parentElement;
|
417 |
+
if (lineIds.length > 1) {
|
418 |
+
const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]);
|
419 |
+
const bottom = lastEl.offsetTop + lastEl.offsetHeight;
|
420 |
+
height = bottom - top;
|
421 |
+
}
|
422 |
+
if (top !== null && height !== null && parent !== null) {
|
423 |
+
// cook up a div (if necessary) and position it
|
424 |
+
let div = window.document.getElementById("code-annotation-line-highlight");
|
425 |
+
if (div === null) {
|
426 |
+
div = window.document.createElement("div");
|
427 |
+
div.setAttribute("id", "code-annotation-line-highlight");
|
428 |
+
div.style.position = 'absolute';
|
429 |
+
parent.appendChild(div);
|
430 |
+
}
|
431 |
+
div.style.top = top - 2 + "px";
|
432 |
+
div.style.height = height + 4 + "px";
|
433 |
+
let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter");
|
434 |
+
if (gutterDiv === null) {
|
435 |
+
gutterDiv = window.document.createElement("div");
|
436 |
+
gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter");
|
437 |
+
gutterDiv.style.position = 'absolute';
|
438 |
+
const codeCell = window.document.getElementById(targetCell);
|
439 |
+
const gutter = codeCell.querySelector('.code-annotation-gutter');
|
440 |
+
gutter.appendChild(gutterDiv);
|
441 |
+
}
|
442 |
+
gutterDiv.style.top = top - 2 + "px";
|
443 |
+
gutterDiv.style.height = height + 4 + "px";
|
444 |
+
}
|
445 |
+
selectedAnnoteEl = annoteEl;
|
446 |
+
}
|
447 |
+
};
|
448 |
+
const unselectCodeLines = () => {
|
449 |
+
const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"];
|
450 |
+
elementsIds.forEach((elId) => {
|
451 |
+
const div = window.document.getElementById(elId);
|
452 |
+
if (div) {
|
453 |
+
div.remove();
|
454 |
+
}
|
455 |
+
});
|
456 |
+
selectedAnnoteEl = undefined;
|
457 |
+
};
|
458 |
+
// Attach click handler to the DT
|
459 |
+
const annoteDls = window.document.querySelectorAll('dt[data-target-cell]');
|
460 |
+
for (const annoteDlNode of annoteDls) {
|
461 |
+
annoteDlNode.addEventListener('click', (event) => {
|
462 |
+
const clickedEl = event.target;
|
463 |
+
if (clickedEl !== selectedAnnoteEl) {
|
464 |
+
unselectCodeLines();
|
465 |
+
const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active');
|
466 |
+
if (activeEl) {
|
467 |
+
activeEl.classList.remove('code-annotation-active');
|
468 |
+
}
|
469 |
+
selectCodeLines(clickedEl);
|
470 |
+
clickedEl.classList.add('code-annotation-active');
|
471 |
+
} else {
|
472 |
+
// Unselect the line
|
473 |
+
unselectCodeLines();
|
474 |
+
clickedEl.classList.remove('code-annotation-active');
|
475 |
+
}
|
476 |
+
});
|
477 |
+
}
|
478 |
+
const findCites = (el) => {
|
479 |
+
const parentEl = el.parentElement;
|
480 |
+
if (parentEl) {
|
481 |
+
const cites = parentEl.dataset.cites;
|
482 |
+
if (cites) {
|
483 |
+
return {
|
484 |
+
el,
|
485 |
+
cites: cites.split(' ')
|
486 |
+
};
|
487 |
+
} else {
|
488 |
+
return findCites(el.parentElement)
|
489 |
+
}
|
490 |
+
} else {
|
491 |
+
return undefined;
|
492 |
+
}
|
493 |
+
};
|
494 |
+
var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
|
495 |
+
for (var i=0; i<bibliorefs.length; i++) {
|
496 |
+
const ref = bibliorefs[i];
|
497 |
+
const citeInfo = findCites(ref);
|
498 |
+
if (citeInfo) {
|
499 |
+
tippyHover(citeInfo.el, function() {
|
500 |
+
var popup = window.document.createElement('div');
|
501 |
+
citeInfo.cites.forEach(function(cite) {
|
502 |
+
var citeDiv = window.document.createElement('div');
|
503 |
+
citeDiv.classList.add('hanging-indent');
|
504 |
+
citeDiv.classList.add('csl-entry');
|
505 |
+
var biblioDiv = window.document.getElementById('ref-' + cite);
|
506 |
+
if (biblioDiv) {
|
507 |
+
citeDiv.innerHTML = biblioDiv.innerHTML;
|
508 |
+
}
|
509 |
+
popup.appendChild(citeDiv);
|
510 |
+
});
|
511 |
+
return popup.innerHTML;
|
512 |
+
});
|
513 |
+
}
|
514 |
+
}
|
515 |
+
});
|
516 |
+
</script>
|
517 |
+
<nav class="page-navigation">
|
518 |
+
<div class="nav-page nav-page-previous">
|
519 |
+
<a href="./cw007reversedstrings.html" class="pagination-link">
|
520 |
+
<i class="bi bi-arrow-left-short"></i> <span class="nav-page-text"><span class="chapter-number">7</span> <span class="chapter-title">Reversed Strings</span></span>
|
521 |
+
</a>
|
522 |
+
</div>
|
523 |
+
<div class="nav-page nav-page-next">
|
524 |
+
</div>
|
525 |
+
</nav>
|
526 |
+
</div> <!-- /content -->
|
527 |
+
|
528 |
+
|
529 |
+
|
530 |
+
</body></html>
|
index.html
CHANGED
@@ -153,8 +153,14 @@ ul.task-list li input[type="checkbox"] {
|
|
153 |
</li>
|
154 |
<li class="sidebar-item">
|
155 |
<div class="sidebar-item-container">
|
156 |
-
<a href="./
|
157 |
-
<span class="menu-text">
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
</div>
|
159 |
</li>
|
160 |
</ul>
|
@@ -196,7 +202,7 @@ ul.task-list li input[type="checkbox"] {
|
|
196 |
<div>
|
197 |
<div class="quarto-title-meta-heading">Published</div>
|
198 |
<div class="quarto-title-meta-contents">
|
199 |
-
<p class="date">Last Updated on
|
200 |
</div>
|
201 |
</div>
|
202 |
|
|
|
153 |
</li>
|
154 |
<li class="sidebar-item">
|
155 |
<div class="sidebar-item-container">
|
156 |
+
<a href="./cw007reversedstrings.html" class="sidebar-item-text sidebar-link">
|
157 |
+
<span class="menu-text"><span class="chapter-number">7</span> <span class="chapter-title">Reversed Strings</span></span></a>
|
158 |
+
</div>
|
159 |
+
</li>
|
160 |
+
<li class="sidebar-item">
|
161 |
+
<div class="sidebar-item-container">
|
162 |
+
<a href="./cw008bool_to_word.html" class="sidebar-item-text sidebar-link">
|
163 |
+
<span class="menu-text"><span class="chapter-number">8</span> <span class="chapter-title">Convert boolean values to strings ‘Yes’ or ‘No’</span></span></a>
|
164 |
</div>
|
165 |
</li>
|
166 |
</ul>
|
|
|
202 |
<div>
|
203 |
<div class="quarto-title-meta-heading">Published</div>
|
204 |
<div class="quarto-title-meta-contents">
|
205 |
+
<p class="date">Last Updated on 07 February, 2024</p>
|
206 |
</div>
|
207 |
</div>
|
208 |
|