## Wizard Recommends

Using each digit from 1 to 9 exactly once each, compose three fractions, each with one digit in the numerator and two digits in the denominator, in which the sum of the three fractions is one.

For example, 8/16 + 9/27 + 3/24 meets every condition, except the sum equals 23/24, not 1.

Gialmere

5/34 + 7/68 + 9/12

There are permut(9,3)*permut(6,3)*permut(3,3)/fact(3) = 60,480 possible permutations to sort through to find the answer. I must admit I tried for at least an hour by trial and error and didn't find a solution.

So, I wrote a program to sort through all fact(9) = 362,880 ways to sort the nine digits and tested all of them. The tricky part was to sort through every possible way to order the nine numbers. Here is how to do it, using lexographic sorting.

1. Put all nine elements in an array, arranged from lowest to highest.
2. Find the last element in the array such that the following element is greater. If none are found, exit the program.
3. Starting with the element after that from step 2, find the last element in the array that is greater than that from step 2.
4. Swap the elements in the array from steps 2 and 3.
5. Reverse the elements in the array from the one after that from step 2 until the end.
6. Go back to step 2

Following this process, you'll find the correct answer six times, once for all six ways to order the three fractions.

I wrote the following code, to sort every digit from 1 to 9 in lexographic order and test each one if it was a solution.

```void three_fraction(void)
{
int i, x_max, y_max, temp_array, hold, pt;
int lex_array[] = { 1,2,3,4,5,6,7,8,9 };
int num_elements = sizeof(lex_array) / sizeof(lex_array);
int count = 0;
bool stop = false;
double tot3;
cerr << "Number of elements =\t" << num_elements << "\n";
do
{
count++;
tot3 = (double)lex_array / (double)(10 * lex_array + lex_array);
tot3 += (double)lex_array / (double)(10 * lex_array + lex_array);
tot3 += (double)lex_array / (double)(10 * lex_array + lex_array);
if (tot3 == 1.0)
{
cerr << count << "\t";
cerr << lex_array << "/" << lex_array << lex_array << " + ";
cerr << lex_array << "/" << lex_array << lex_array << " + ";
cerr << lex_array << "/" << lex_array << lex_array << "\n";
}
x_max = -1;
for (i = 0; i < (num_elements - 1); i++)
{
if (lex_array[i] < lex_array[i + 1])
x_max = i;
}
if (x_max >= 0)
{
y_max = 0;
for (i = x_max + 1; i < num_elements; i++)
{
if (lex_array[x_max] < lex_array[i])
y_max = i;
}
hold = lex_array[x_max];
lex_array[x_max] = lex_array[y_max];
lex_array[y_max] = hold;
if (x_max + 1 < num_elements - 1) // reverse
{
for (i = x_max + 1; i < num_elements; i++)
{
temp_array[i] = lex_array[i];
}
pt = 0;
for (i = x_max + 1; i < num_elements; i++)
{
lex_array[i] = temp_array[num_elements - 1 - pt];
pt++;
}
}
}
else
stop = true;
} while (stop == false);
}
```

This question is asked and discussed in my forum at Wizard of Vegas.

A man had a 10-gallon keg of wine and a jug. One day, he drew a jug-full of wine and then topped off the keg with water. Later on, when the wine and water had gotten thoroughly mixed, he drew another jug-full and again topped off the keg with water. The keg then contained equal quantities of wine and water.

What was the capacity of the jug?

Gialmere

10-5*sqrt(2) =~ 2.9289 gallons

Let j = volume of jug.

After the first time the jug was filled, there was 10-j gallons of wine left in the jug. After water replaced the wine, the ratio of wine to the entire keg was (10-j)/10.

After the jug scooped out the diluted wine, there was 10-j gallons of diluted wine left in the keg. The amount of pure wine in the diluted wine can be expressed as:

(10-j)*((10-j)/10) = 5

(10-j)^2 = 50

j^2 - 20j + 100 = 50

j^2 - 20j + 50 = 0

j = (20 +/- sqrt(400-200))/2

j = (20 +/- 10*sqrt(2))/2

j = 10 +/- 5*sqrt(2)

The jug can't be bigger than the keg, so we must use the negative sign:

j = 10 - 5*sqrt(2) =~ apx. 2.92893218813452 gallons.

This question is asked and discussed in my forum at Wizard of Vegas.

A six-sided die is rolled over and over until the sum of rolls is 13 or greater. What is the mean, median and mode of the final total?

Gialmere

Mean = 14.690219
Median = 14
Mode = 13

I had to use a Markov Chain for this one. The following table shows the probability of each final total according to the running sum in the left column. Start with the obvious cases for totals of 13 to 18. Then, for running sums of 0 to 12, take the average of the six cells below.

The probabilities for the initial state can be found in the first row for a sum of 0.

### Markov Chain

Sum of Rolls 13 14 15 16 17 18
0 0.279263 0.236996 0.192313 0.145585 0.097371 0.048472
1 0.290830 0.230791 0.188524 0.143842 0.097114 0.048899
2 0.293393 0.241931 0.181893 0.139625 0.094943 0.048215
3 0.289288 0.245178 0.193717 0.133678 0.091410 0.046728
4 0.280369 0.242560 0.198450 0.146988 0.086950 0.044682
5 0.268094 0.235687 0.197878 0.153768 0.102306 0.042267
6 0.253604 0.225827 0.193419 0.155611 0.111500 0.060039
7 0.360232 0.193566 0.165788 0.133380 0.095572 0.051462
8 0.308771 0.308771 0.142104 0.114326 0.081919 0.044110
9 0.264660 0.264660 0.264660 0.097994 0.070216 0.037809
10 0.226852 0.226852 0.226852 0.226852 0.060185 0.032407
11 0.194444 0.194444 0.194444 0.194444 0.194444 0.027778
12 0.166667 0.166667 0.166667 0.166667 0.166667 0.166667
13 1.000000 0.000000 0.000000 0.000000 0.000000 0.000000
14 0.000000 1.000000 0.000000 0.000000 0.000000 0.000000
15 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000
16 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000
17 0.000000 0.000000 0.000000 0.000000 1.000000 0.000000
18 0.000000 0.000000 0.000000 0.000000 0.000000 1.000000

This question is asked and discussed in my forum a Wizard of Vegas.