diff --git a/fizzbuzz.Rmd b/fizzbuzz.Rmd index 58e4ceb..e73189e 100644 --- a/fizzbuzz.Rmd +++ b/fizzbuzz.Rmd @@ -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} diff --git a/fizzbuzz.html b/fizzbuzz.html index 7457e94..a1408e1 100644 --- a/fizzbuzz.html +++ b/fizzbuzz.html @@ -192,6 +192,42 @@
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.
+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)
+## [1] "1" "2" "Fizz" "4" "Buzz" "Fizz"
+## [7] "7" "8" "Fizz" "Buzz" "11" "Fizz"
+## [13] "13" "14" "FizzBuzz" "16" "17" "Fizz"
+## [19] "19" "Buzz" "Fizz" "22" "23" "Fizz"
+## [25] "Buzz" "26" "Fizz" "28" "29" "FizzBuzz"
+## [31] "31" "32" "Fizz" "34" "Buzz" "Fizz"
+## [37] "37" "38" "Fizz" "Buzz" "41" "Fizz"
+## [43] "43" "44" "FizzBuzz" "46" "47" "Fizz"
+## [49] "49" "Buzz" "Fizz" "52" "53" "Fizz"
+## [55] "Buzz" "56" "Fizz" "58" "59" "FizzBuzz"
+## [61] "61" "62" "Fizz" "64" "Buzz" "Fizz"
+## [67] "67" "68" "Fizz" "Buzz" "71" "Fizz"
+## [73] "73" "74" "FizzBuzz" "76" "77" "Fizz"
+## [79] "79" "Buzz" "Fizz" "82" "83" "Fizz"
+## [85] "Buzz" "86" "Fizz" "88" "89" "FizzBuzz"
+## [91] "91" "92" "Fizz" "94" "Buzz" "Fizz"
+## [97] "97" "98" "Fizz" "Buzz"
+total <- 1
diff --git a/snakesladders.Rmd b/snakesladders.Rmd
index 045da5c..41763f1 100644
--- a/snakesladders.Rmd
+++ b/snakesladders.Rmd
@@ -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}