```{r data generation, echo = FALSE, results = "hide"}
## Base64-encoded PNG clipart images (CC0)
## created by base64enc::base64encode("file.png")
banana    <- "[encoded data, 9708 characters]"
orange    <- "[encoded data, 9348 characters]"
pineapple <- "[encoded data, 18108 characters]"
writeBin(base64enc::base64decode(banana),    "banana.png")
writeBin(base64enc::base64decode(orange),    "orange.png")
writeBin(base64enc::base64decode(pineapple), "pineapple.png")
img0 <- sprintf("![%s](%s.png){width=\"0.85cm\"}", c("banana", "orange", "pineapple"), c("banana", "orange", "pineapple"))
img <- function(x = "b") img0[factor(x, levels = c("b", "o", "p"))]

## prices ("in cent")
b <- sample(20:99, size = 1)
o <- sample(20:99, size = 1)
p <- sample(199:499, size = 1)
x <- c(b, o, p)

## three simple fruit baskets
G <- sample(c("bbo", "bbp", "boo", "bpp", "oop", "opp"), 3)
G <- t(sapply(G, function(x) sample(strsplit(x, "")[[1]])))
A <- t(apply(G, 1, function(x) table(factor(x, levels = c("b", "o", "p")))))

## corresponding prices
d <- A %*% x

## new fruit basket with all fruits and corresponding price
sol <- sum(x)
```


Question
========

Given the following information:

|                  |     |                  |     |                  |   |            |
|:----------------:|:---:|:----------------:|:---:|:----------------:|:-:|-----------:|
| `r img(G[1, 1])` | $+$ | `r img(G[1, 2])` | $+$ | `r img(G[1, 3])` | = | $`r d[1]`$ |
| `r img(G[2, 1])` | $+$ | `r img(G[2, 2])` | $+$ | `r img(G[2, 3])` | = | $`r d[2]`$ |
| `r img(G[3, 1])` | $+$ | `r img(G[3, 2])` | $+$ | `r img(G[3, 3])` | = | $`r d[3]`$ |

Compute:

|              |     |              |     |              |   |            |
|:------------:|:---:|:------------:|:---:|:------------:|:-:|-----------:|
| `r img("b")` | $+$ | `r img("o")` | $+$ | `r img("p")` | = | $\text{?}$ |


Solution
========

The information provided can be interpreted as the price for three fruit baskets
with different combinations of the three fruits. This corresponds to a system of
linear equations where the price of the three fruits is the vector of unknowns $x$:

|         |              |         |              |         |              |
|--------:|:-------------|--------:|:-------------|--------:|:-------------|
| $x_1 =$ | `r img("b")` | $x_2 =$ | `r img("o")` | $x_3 =$ | `r img("p")` |

The system of linear equations is then:
$$
\begin{aligned}
`r toLatex(A, escape = FALSE)` \cdot `r toLatex(matrix(paste0("x_", 1:3), ncol = 1), escape = FALSE)` & = & `r toLatex(matrix(d, ncol = 1), escape = FALSE)`
\end{aligned}
$$
This can be solved using any solution algorithm, e.g., elimination:
$$
x_1 = `r b`, \, x_2 = `r o`, \, x_3 = `r p`.
$$
Based on the three prices for the different fruits it is straightforward to
compute the total price of the fourth fruit basket via:

|              |     |              |     |              |   |            |
|:------------:|:---:|:------------:|:---:|:------------:|:-:|-----------:|
| `r img("b")` | $+$ | `r img("o")` | $+$ | `r img("p")` | = |            |
| $x_1$        | $+$ | $x_2$        | $+$ | $x_3$        | = |            |
| $`r x[1]`$   | $+$ | $`r x[2]`$   | $+$ | $`r x[3]`$   | = | $`r sol`$  |


Meta-information
================
exname: Fruit baskets (numeric)
extype: num
exsolution: `r fmt(sol)`
extol: 0

