# 1.
# assign values
x <- 1.1
a <- 2.2
b <- 3.3

# a. 
x^(a^b)
## [1] 3.61714
# b.
(x^a)^b
## [1] 1.997611
# c.
3*x^3 + 2*x^2 + 1
## [1] 7.413
# 2. 
# a.
c(seq(8), rev(seq(7)))
##  [1] 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1
# b.
rep(seq(5), 1:5)
##  [1] 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5
# c.
rep(5:1, 1:5)
##  [1] 5 4 4 3 3 3 2 2 2 2 1 1 1 1 1
# 3.
# create the x and y coordinates
cartesian_coord <- runif(2)
# extract x and y values
x <- cartesian_coord[1]
y <- cartesian_coord[2]
# calculate the r and theta to convert cartesian to polar coordinate
r <- sqrt(x^2 + y^2)
theta <- atan(y/x)
polar_coord <- c(r, theta)


# 4.
# create the original queue
queue <- c("sheep", "fox", "owl", "ant")
# a. the serpent arrives and gets in line
queue <- append(queue, 'serpent')
# b. the sheep enters the ark
queue <- queue[! queue %in% 'sheep']
# c. the donkey arrives and talks his way to the front of the line
queue <- append('donkey', queue)
# d. the serpent gets impatient and leaves
queue <- queue[! queue %in% 'serpent']
# e. the owl gets bored and leaves
queue <- queue[! queue %in% 'owl']
# f. the aphid arrives and the ant invites him to cut in line
queue <- append(queue, 'aphid', after=which(queue=='ant')-1)
# g. determine the position of the aphid in the line
pos <- which(queue=='aphid')


# 5. 
# create the vector
vector <- seq(100)
# remove desired values
vector <- vector[(vector %% 2) & (vector %% 3) & (vector %% 7)]