From 3839b70a325163c6b44fe6923b4a469fdc21d645 Mon Sep 17 00:00:00 2001 From: aicon08 Date: Mon, 25 Feb 2019 00:38:28 +0000 Subject: [PATCH 1/2] Added Fizzbuzz Solution--Aira Contreras --- fizzbuzz.Rmd | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/fizzbuzz.Rmd b/fizzbuzz.Rmd index 58e4ceb..429d062 100644 --- a/fizzbuzz.Rmd +++ b/fizzbuzz.Rmd @@ -11,6 +11,36 @@ 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. + +### Aira Contreras + +```{r,eval=F} +a<-seq(1,100,1) + +for (i in a) +{ + + if(i%%3==0 & i%%5==0) + { + i<-"FizzBuzz" + print(i) + } + else if(i%%5==0) + { + i<-"Buzz" + print(i) + } + else if(i%%3==0) + { + i<-"Fizz" + print(i) + } + else if(i) + { + print(i) + } +} +``` ### Jeff Kravitz ```{r} From d3a2249d6e37e7e5f2fed78960f750dc1a281f1c Mon Sep 17 00:00:00 2001 From: aicon08 Date: Mon, 25 Feb 2019 01:23:31 +0000 Subject: [PATCH 2/2] Addition of Snakes and Ladders Solution--Aira Contreras --- snakesladders.Rmd | 50 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/snakesladders.Rmd b/snakesladders.Rmd index 045da5c..0fee5fd 100644 --- a/snakesladders.Rmd +++ b/snakesladders.Rmd @@ -11,6 +11,56 @@ 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. +### Aira Contreras + +```{r, eval=FALSE} +SnakesLadders<-function() +{ + +ladders<-data.frame(start=c(1,4,9,21,28,36,51,71,80),end=c(37,14,31,42,84,44,67,91,100)) + + +slides<-data.frame(start=c(98,95,93,87,64,62,56,49,47,16), end=c(78,75,73,24,60,19,53,11,26,6)) + +#print(ladders) +#print(slides) + +loc<-0 +nroll<-0 +slide<-0 +ladder<-0 + + + while(loc<=100) + { + die<-sample(c(1,2,3,4,5,6),1) + loc<-loc+die + nroll<-nroll+1 + + if(any(ladders$start %in% loc)) + { + loc<-ladders$end[ladders$start %in% loc] + ladder<- ladder+1 + } + + if(any(slides$start %in% loc)) + { + loc<-slides$end[slides$start %in% loc] + slide<-slide+1 + } + #print(c(loc,die)) + } +return(nroll) + +} + +totnroll<-0 +for(i in 1:1000) +{ + totnroll<-totnroll+SnakesLadders() +} +print(totnroll/1000) +``` ### Jeff Kravitz ```{r}