Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions fizzbuzz.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,27 @@ knitr::opts_chunk$set(echo = TRUE)

This document contains student solutions to the fizzbuzz problem. Students will add to this file using the outline below. Write your name (using three hashtags), then below create an R code block and insert your code. Save the .rmd file, then knit the document to update the html output. Then submit a pull request to merge your changes to the main repository.

### Melissa Horger
```{r, eval=F}
FB <- c(1:100)

for (i in 1:100) {
if (i%%3==0)
FB[i]<-"Fizz"
}
for (j in 1:100){
if (j%%5==0)
FB[j]<-"Buzz"
}
for (k in 1:100){
if (k%%3 ==0 & k%%5 == 0)
FB[k]<-"FizzBuzz"
}

print(FB)
```


### Jeff Kravitz

```{r}
Expand Down
36 changes: 36 additions & 0 deletions fizzbuzz.html
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,42 @@ <h4 class="date"><em>2/12/2019</em></h4>


<p>This document contains student solutions to the fizzbuzz problem. Students will add to this file using the outline below. Write your name (using three hashtags), then below create an R code block and insert your code. Save the .rmd file, then knit the document to update the html output. Then submit a pull request to merge your changes to the main repository.</p>
<div id="melissa-horger" class="section level3">
<h3>Melissa Horger</h3>
<pre class="r"><code>FB &lt;- c(1:100)

for (i in 1:100) {
if (i%%3==0)
FB[i]&lt;-&quot;Fizz&quot;
}
for (j in 1:100){
if (j%%5==0)
FB[j]&lt;-&quot;Buzz&quot;
}
for (k in 1:100){
if (k%%3 ==0 &amp; k%%5 == 0)
FB[k]&lt;-&quot;FizzBuzz&quot;
}

print(FB)</code></pre>
<pre><code>## [1] &quot;1&quot; &quot;2&quot; &quot;Fizz&quot; &quot;4&quot; &quot;Buzz&quot; &quot;Fizz&quot;
## [7] &quot;7&quot; &quot;8&quot; &quot;Fizz&quot; &quot;Buzz&quot; &quot;11&quot; &quot;Fizz&quot;
## [13] &quot;13&quot; &quot;14&quot; &quot;FizzBuzz&quot; &quot;16&quot; &quot;17&quot; &quot;Fizz&quot;
## [19] &quot;19&quot; &quot;Buzz&quot; &quot;Fizz&quot; &quot;22&quot; &quot;23&quot; &quot;Fizz&quot;
## [25] &quot;Buzz&quot; &quot;26&quot; &quot;Fizz&quot; &quot;28&quot; &quot;29&quot; &quot;FizzBuzz&quot;
## [31] &quot;31&quot; &quot;32&quot; &quot;Fizz&quot; &quot;34&quot; &quot;Buzz&quot; &quot;Fizz&quot;
## [37] &quot;37&quot; &quot;38&quot; &quot;Fizz&quot; &quot;Buzz&quot; &quot;41&quot; &quot;Fizz&quot;
## [43] &quot;43&quot; &quot;44&quot; &quot;FizzBuzz&quot; &quot;46&quot; &quot;47&quot; &quot;Fizz&quot;
## [49] &quot;49&quot; &quot;Buzz&quot; &quot;Fizz&quot; &quot;52&quot; &quot;53&quot; &quot;Fizz&quot;
## [55] &quot;Buzz&quot; &quot;56&quot; &quot;Fizz&quot; &quot;58&quot; &quot;59&quot; &quot;FizzBuzz&quot;
## [61] &quot;61&quot; &quot;62&quot; &quot;Fizz&quot; &quot;64&quot; &quot;Buzz&quot; &quot;Fizz&quot;
## [67] &quot;67&quot; &quot;68&quot; &quot;Fizz&quot; &quot;Buzz&quot; &quot;71&quot; &quot;Fizz&quot;
## [73] &quot;73&quot; &quot;74&quot; &quot;FizzBuzz&quot; &quot;76&quot; &quot;77&quot; &quot;Fizz&quot;
## [79] &quot;79&quot; &quot;Buzz&quot; &quot;Fizz&quot; &quot;82&quot; &quot;83&quot; &quot;Fizz&quot;
## [85] &quot;Buzz&quot; &quot;86&quot; &quot;Fizz&quot; &quot;88&quot; &quot;89&quot; &quot;FizzBuzz&quot;
## [91] &quot;91&quot; &quot;92&quot; &quot;Fizz&quot; &quot;94&quot; &quot;Buzz&quot; &quot;Fizz&quot;
## [97] &quot;97&quot; &quot;98&quot; &quot;Fizz&quot; &quot;Buzz&quot;</code></pre>
</div>
<div id="jeff-kravitz" class="section level3">
<h3>Jeff Kravitz</h3>
<pre class="r"><code>total &lt;- 1
Expand Down
79 changes: 79 additions & 0 deletions snakesladders.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,85 @@ knitr::opts_chunk$set(echo = TRUE)

This document contains student solutions to the snakes and ladders problem. Students will add to this file using the outline below. Write your name (using three hashtags), then below create an R code block and insert your code. Save the .rmd file, then knit the document to update the html output. Then submit a pull request to merge your changes to the main repository.


### Melissa Horger
```{r, eval=F}
roll_dice<- function(x){
return(sample(1:6, x, replace = TRUE, prob = NULL))
}

roll_dice(10)

total_sum<-0
number_of_rolls<-0
while(total_sum < 25){
number_of_rolls <- number_of_rolls+1
total_sum <-total_sum+sample(c(1,2,3,4,5,6),1)
}
number_of_rolls

# based on the demo in the assignment, the average number of rolls needed to finish the board is 7.5


total_sum<-0
number_of_rolls<-0
while(total_sum < 25){
number_of_rolls <- number_of_rolls+1
total_sum <-total_sum+sample(c(1,2,3,4,5,6),1)
if(total_sum==3)
total_sum+7
if(total_sum==4)
total_sum+10
if(total_sum==6)
total_sum+11
if(total_sum==8)
total_sum+11
if(total_sum==9)
total_sum+9
if(total_sum==10)
total_sum+2
if(total_sum==16)
total_sum+8
if(total_sum==20)
total_sum+2
}
number_of_rolls
total_sum



save_rolls <- c()
for(sims in 1:100){
total_sum<-0
number_of_rolls<-0
while(total_sum < 25){
number_of_rolls <- number_of_rolls+1
total_sum <-total_sum+sample(c(1,2,3,4,5,6),1)
if(total_sum==3)
total_sum+7
if(total_sum==4)
total_sum+10
if(total_sum==6)
total_sum+11
if(total_sum==8)
total_sum+11
if(total_sum==9)
total_sum+9
if(total_sum==10)
total_sum+2
if(total_sum==16)
total_sum+8
if(total_sum==20)
total_sum+2
}
save_rolls[sims] <- number_of_rolls
}

save_rolls
```



### Jeff Kravitz

```{r}
Expand Down