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
30 changes: 30 additions & 0 deletions fizzbuzz.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
50 changes: 50 additions & 0 deletions snakesladders.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down