---
author: "Write your name here"
number: STUDENT_NUMBER
title: "Homework 3"
subtitle: "Computing in Molecular Biology 1 – Molecular Biology and Genetics Department"
description: "Rehearsal for Midterm Exam"
date: "November 17, 2020"
output: 
  html_document: 
    number_sections: yes
    self_contained: no
editor_options: 
  chunk_output_type: inline
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

# Logic operations
For the following questions you will use `X` and `Y` defined as follows
```{r}
X <- rep(c(TRUE, FALSE), 2)
X
Y <- rep(c(TRUE, FALSE), c(2, 2))
Y
```
These are all the possible combinations of two logic variables. Now we want to see what happens when we combine them

## Evaluate "`X` and `Y`"
```{r q1}
# write here
```

## Evaluate "`X` or `Y`"
```{r q2}
# write here
```

## Evaluate "`X` and not `Y`"
```{r q3}
# write here
```

## Evaluate "not `X` and not `Y`"
```{r q4}
# write here
```

## Show that "not `X` and not `Y`" is the _negation_ of "`X` or `Y`". Print both results in different lines, so we can see they are the same. This is called _De Morgan's rule_.
```{r q5}
# write here
```

## Show that "not `X` or not `Y`" is the negation of "`X` and `Y`". Print both results in different lines, so we can see they are the same. This is also called _De Morgan's rule_.
```{r q6}
# write here
```

## (Bonus) Can you prove that `X` and `Y` are really all combinations of two logic variables?

<!-- DO NOT DELETE THIS -->

> Write your comment here. Keep the `>` and delete the rest
>
>
>

<!-- DO NOT DELETE THIS -->

# Combination of three logic variables
Consider now `A`, `B`, and `C`, defined as follows
```{r}
A <- rep(c(TRUE, FALSE), 4)
A
B <- rep(c(TRUE, TRUE, FALSE, FALSE), 2)
B
C <- rep(c(TRUE, FALSE), c(4, 4))
C
```
These are all the combinations of three logic values.

## Show that "`A` and the result of`B` or `C`" is equivalent to "the result of `A` and `B`, or the result of `A` and `C`". Print both results in different lines, so we can see they are the same. This is called _Distributive rule_.
```{r q7}
# write here
```

## Show that "`A` or the result of`B` and `C`" is equivalent to "the result of `A` or `B`, and the result of `A` or `C`". Print both results in different lines, so we can see they are the same. This is also called _Distributive rule_.
```{r q8}
# write here
```


## (Bonus) Can you show the _associative rule_?
```{r q9}
# write here
```

## (Bonus) Can you show the _commutative rule_?
```{r q10}
# write here
```

# Modifying a vector
In contrast to single-value variables, when we use indices to modify a vector, it changes on place.

The answers to the following questions should work for any vector `v`. For the sake of example, consider the vector `v` defined as
```{r}
v <- seq(from=7, to=1)
v
```
```{r q11}
# write here
```

## Change the first element to `8` and show the updated vector `v`.
```{r q12}
# write here
```

## Change the sign of the second element and show the updated vector `v`.
```{r q13}
# write here
```

## Add 7 to the third and fourth element and show the updated vector `v`.
```{r q14}
# write here
```

## Change again the sign of the second element and show the updated vector `v`.
```{r q15}
# write here
```


## Increase the last three elements by 10%.
```{r q16}
# write here
```





<style type="text/css">
h1 {font-size: 24px;}
h2 {font-size: 15px; font-weight: normal; margin-bottom: 0; line-height: 20px;}
hr {page-break-before: always; border: 0;} 
blockquote { border: #eee solid;}
.header-section-number::after {content: ". ";}
</style>
