Skip to content

Commit

Permalink
Specified that dice should be six-sided and added bonus exercise
Browse files Browse the repository at this point in the history
  • Loading branch information
abner-hb committed Mar 29, 2024
1 parent 6a62ae7 commit 6ce7468
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion 02_getting_started_with_r.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -684,4 +684,6 @@ All of the objects that we create inside a function will disappear after it fini

Let's try to practice all of the basic features of **[R]{.sans-serif}** that you just learned.

Write a function that can simulate the roll of a pair of dice (let's call them red and blue) an arbitrary number of times. This function should return a vector with the values of the red die that were strictly larger than the corresponding values of the blue die. Hint: to simulate rolling a die, you can use the function `sample()`.
Write a function that can simulate the roll of a pair of six-sided dice (let's call them red and blue) an arbitrary number of times. This function should return a vector with the values of the red die that were strictly larger than the corresponding values of the blue die. Hint: to simulate rolling a die, you can use the function `sample()`.

Bonus: modify your function so that the dice can have different numbers of faces.
3 changes: 2 additions & 1 deletion docs/02_getting_started_with_r.html
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,8 @@ <h2 data-number="2.8" class="anchored" data-anchor-id="writing-our-own-functions
<section id="exercise" class="level2" data-number="2.9">
<h2 data-number="2.9" class="anchored" data-anchor-id="exercise"><span class="header-section-number">2.9</span> Exercise</h2>
<p>Let’s try to practice all of the basic features of <strong><span class="sans-serif">R</span></strong> that you just learned.</p>
<p>Write a function that can simulate the roll of a pair of dice (let’s call them red and blue) an arbitrary number of times. This function should return a vector with the values of the red die that were strictly larger than the corresponding values of the blue die. Hint: to simulate rolling a die, you can use the function <code>sample()</code>.</p>
<p>Write a function that can simulate the roll of a pair of six-sided dice (let’s call them red and blue) an arbitrary number of times. This function should return a vector with the values of the red die that were strictly larger than the corresponding values of the blue die. Hint: to simulate rolling a die, you can use the function <code>sample()</code>.</p>
<p>Bonus: modify your function so that the dice can have different numbers of faces.</p>


</section>
Expand Down
2 changes: 1 addition & 1 deletion docs/search.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"href": "02_getting_started_with_r.html#exercise",
"title": "2  Getting Started with R",
"section": "2.9 Exercise",
"text": "2.9 Exercise\nLet’s try to practice all of the basic features of R that you just learned.\nWrite a function that can simulate the roll of a pair of dice (let’s call them red and blue) an arbitrary number of times. This function should return a vector with the values of the red die that were strictly larger than the corresponding values of the blue die. Hint: to simulate rolling a die, you can use the function sample()."
"text": "2.9 Exercise\nLet’s try to practice all of the basic features of R that you just learned.\nWrite a function that can simulate the roll of a pair of six-sided dice (let’s call them red and blue) an arbitrary number of times. This function should return a vector with the values of the red die that were strictly larger than the corresponding values of the blue die. Hint: to simulate rolling a die, you can use the function sample().\nBonus: modify your function so that the dice can have different numbers of faces."
},
{
"objectID": "05_data_for_analysis.html#creating-data-random-numbers",
Expand Down

0 comments on commit 6ce7468

Please # to comment.