# A clock for 2017

Design a clock where each number from 1 to 12 is obtained as an arithmetical operation using each digit of 2017 exactly once: for example, 4 could be made as $$2\times 7-10$$.

• Oh, I thought it was going to be this clock – David K Dec 14 '16 at 18:34
• "tick" means checkmark. It took me a while to figure out what it meant because this question is about clocks. – Gimme the 411 Apr 14 at 6:53

With the digits in order:

\begin{align} 1 &= 2 + 0 - 1 ^ 7 \\ 2 &= 2 + 0 \times 1 \times 7 \\ 3 &= 2 + 0 + 1 ^ 7 \\ 4 &= -2 - 0 - 1 + 7 \\ 5 &= 2 \times (0 - 1) + 7 \\ 6 &= 2 \times 0 - 1 + 7\\ 7 &= 2 \times 0 \times 1 + 7 \\ 8 &= 2 \times 0 + 1 + 7 \\ 9 &= 2 + 0 \times 1 + 7 \\ 10 &= 2 + 0 + 1 + 7 \\ 11 &= 2 + 0! + 1 + 7 \\ 12 &= 2 \times (0 - 1 + 7) \\ \end{align}

• 👏 my applauds... – Matas Vaitkevicius Dec 13 '16 at 12:52
• 4 feels like a bit of a cheat to me though :( – dcfyj Dec 16 '16 at 13:59
• To avoid using the negative on 4 you could do 2+0!+1^7 :) – dcfyj Dec 16 '16 at 14:04
• really impressive! – mau Dec 18 '16 at 16:15

I tried to make a digital clock.

$0 = (7 + 1 + 2) \times 0$
$1 = (2 + 7 + 1) ^ 0$
$2 = (7 + 1) \times 0 + 2$
$3 = 7 \times 0 + 2 + 1$
$4 = 2 \times 7 - 10$
$5 = 7 - 2 + 1 \times 0$
$6 = 7 - 1 + 2 \times 0$
$7 = 7 + 1 * 2 \times 0$
$8 = 7 + 1 + 0 \times 2$
$9 = 7 + 2 + 1 \times 0$
$10 = 1 + 2 + 7 + 0$
$11 = 12 - 7^0$
$12 = 12 + 7 \times 0$
$13 = 12 + 7 ^ 0$
$14 = 7 \times 2 + 1 \times 0$
$15 = 7 \times 2 + 1 + 0$
$16 = (7 + 1) \times 2 + 0$
$17 = (7 + 1) \times 2 + 0!$
$18 = (7 + 2) \times (1 + 0!)$
$19 = 10 + 2 + 7$
$20 = 17 + 2 + 0!$
$21 = 7 \times (2 + 1 + 0)$
$22 = 7 \times (2 + 1) + 0!$
$23 = 17 + (2 + 0!)!$ or $(7-2-1)! - 0!$ thanks to stack reader
$24 = 2 \times 7 + 10$

What the hell...lets do it for minutes also (I cheated a bit):

$25 = (7 - 1 - 0!)^2$
$26 = 27 - 1 + 0$
$27 = 27 + 1 \times 0$
$28 = 27 + 1 + 0$
$29 = 27 + 1 + 0!$
$30 = 10 \times \lfloor\frac{7}{2}\rfloor$
$31 = \lceil\log(17!) \times 2\rceil + 0!$ // $\log(17!) = 14.5510$
$32 = (1+0!)^{(7-2)}$
$33 = 17 \times 2 - 0!$
$34 = 17 \times 2 + 0$
$35 = 17 \times 2 + 0!$
$36 = \frac{70}{2} + 1$
$37 = \lfloor\ln {7}^{20}\rfloor - 1$ // $\ln {7}^{20} = (38.9182)$
$38 = \lfloor\ln {7}^{20}\rfloor \times 1$ // $\ln {7}^{20} = (38.9182)$
$39 = \lfloor\ln {7}^{20}\rfloor + 1$ // $\ln {7}^{20} = (38.9182)$
$40 = 10 \times \lceil\frac{7}{2}\rceil$
$41 = \lceil\ln {7}^{21}\rceil + 0$ // $\ln {7}^{21} = (40.8641)$
$42 = \lfloor\ln {72}^{10}\rfloor$ // $\ln {72}^{10} = (42.76666)$
$43 = \lceil\ln {72}^{10}\rceil$ // $\ln {72}^{10} = (42.76666)$
$44 = \lceil{(\ln 710})^{2}\rceil$ // $({\ln 710})^{2} = (43.1027)$
$45 = \lfloor\log(10!) * 7 - \ln(2)\rfloor$ // $\log(10!) = 6.5597$
$46 = \lceil\log(10!) * 7 - \ln(2)\rceil$ // $\log(10!) = 6.5597$
$47 = 7^2 - 1 - 0!$
$48 = 7^2 - 1 + 0$
$49 = 7^2 + 1 \times 0$
$50 = 7^2 + 1 + 0$
$51 = 7^2 + 1 + 0!$
$52 = \lceil\log(2^{170})\rceil$ // $\log(2^{170}) = (51.1750)$
$53 = \lfloor\ln(17!)\rfloor + 20$ // $\ln(17!) = 33.5050$
$54 = 27 \times (1 + 0!)$
$55 = \lceil\ln(27!)\rceil - 10$ // $\ln(27!) = 64.5575$
$56 = \lfloor\ln(17^{20})\rfloor$ // $\ln(17^{20}) = 56.6642$
$57 = \lceil\ln(17^{20})\rceil$ // $\ln(17^{20}) = 56.6642$
$58 = 70 - 12$
$59 = 7^2 + 10$

• @oleslaw....there was no need for 24, because I got 0, but thanks. :) – Marius Dec 13 '16 at 9:18
• (7-2-1)! - 0! = 23 – stack reader Dec 13 '16 at 9:19
• @stackreader. Thanks. I found an other one in the meantime. – Marius Dec 13 '16 at 9:19
• @Marius Oh, you're right. You can delete it or leave it as you want :P – oleslaw Dec 13 '16 at 9:20
• You could do $37 = 20 + 17$ ;-) – ETHproductions Dec 13 '16 at 21:34

$1 = 7 \times 0 + 2 - 1$

$2 = 7 \times 0 + 2 \times 1$

$3 = 20 - 17$

$4 = 7 - 2 - 1 - 0$

$5 = 7 - 2 - 0 \times 1$

$6 = 7 - 1 - 0 \times 2$

$7 = 0 \times 1 \times 2 + 7$

$8 = 0 \times 2 + 1 + 7$

$9 = 0 \times 1 + 2 + 7$

$10 = 0 + 1 + 2 + 7$

$11 = 12 - 7 ^ 0$

$12 = 0 \times 7 + 12$

I'm assuming I'm not allowed to use ^, so give me a few minutes to find an acceptable solution for 11!

• Drat! I got ninjaed... – Sid Dec 13 '16 at 8:25
• @TheGreatEscaper I believe there is no solution for 11 using only the +, -, * and / operators (checked with brute-force computer program) – oleslaw Dec 13 '16 at 9:10
• @oleslaw I'd figured just about that much. Especially when you realise the 0 is basically useless for 11. – TheGreatEscaper Dec 13 '16 at 9:31

$1 = 2*0*7+1$

$2 = 2+0*1*7$

$3 = 2+0*7+1$

$4 = (7+1+0)/2$

$5 = -2+0*1+7$

$6 = -2+0+1+7$

$7 = 2*0*1+7$

$8 = 2*0+1+7$

$9 = 2+0*1+7$

$10 = 2+0+1+7$

$11 = 12-7^0$

$12 = 12-7*0$

• Yup, 12-7^0=11 not 12. – Pokemon Dec 13 '16 at 8:28
• Yeah, my bad... I saw 12=12-7^0 – Sid Dec 13 '16 at 8:28

1=2*7*0+1
2=1*0*7+2
3=7*0+(2+1)
4=2*7-10
5=1*0+(7-2)
6=2*0+(7-1)
7=2*0*1+7
8=2*0+(7+1)
9=1*0+(7+2)
10=0+7+2+1
11=12-7^0
12=0*7+12

A couple more for $12$:

$12=20-1-7, 12=(2+0)\times(-1+7)$

Just for entertainment value, if we limit ourselves with just 4 basic operations (+-*/) without even unary minus, and if we agree to use four separate digits 2,0,1,7 without combining them into numbers like 12, we still can get 11 results out of 12!

Here is the C# code:

var found = new Tuple<int[],Tuple<Func<Decimal, Decimal, Decimal>,string>[]>[12];
var number = new[] { 2, 0, 1, 7 };
var op = new Tuple<Func<Decimal, Decimal, Decimal>, string>[]
{
new Tuple<Func<Decimal, Decimal, Decimal>, string>((x,y) => x + y,"+"),
new Tuple<Func<Decimal, Decimal, Decimal>, string>((x,y) => x - y,"-"),
new Tuple<Func<Decimal, Decimal, Decimal>, string>((x,y) => x * y,"*"),
new Tuple<Func<Decimal, Decimal, Decimal>, string>((x,y) => x / y,"/"),
};
foreach (var i in GetPermutations(number, 4))
{
foreach (var j in GetPermutationsWithRept(op, 3))
{
var ii = i.ToArray(); var jj = j.ToArray();
decimal result = ii[0]; var divideByZero = false;
for (int k = 0;k < 3; k++)
{
if (jj[k] == op[3] && ii[k + 1] == 0)
{
divideByZero = true;
break;
}
result = jj[k].Item1(result,ii[k+1]);
}
if (divideByZero) continue;
if (result <= 12 && result >=1 && result == ((decimal)(int)result))
{
found[(int)result-1] = new Tuple<int[],Tuple<Func<Decimal, Decimal, Decimal>,string>[]>(ii,jj);
}
}
}
PrintResult(found);


And here is the result:

1=(((7*0)-1)+2)
2=(((7/1)*0)+2)
3=(((7-1)-0)/2)
4=(((7-1)-0)-2)
5=(((7/1)-0)-2)
6=(((7+1)-0)-2)
7=(((1*0)/2)+7)
8=(((7-1)-0)+2)
9=(((7/1)-0)+2)
10=(((7+1)-0)+2)
11=Unknown
12=(((7-1)-0)*2)

Implementation of GetPermutations, GetPermutationsWithRept and PrintResult is left as an exercise for the reader.

Anyone would like to write up a code-golf challenge for finding the clock faces ;)?

• As a side note the dreadful Tuples look much nicer in C# 7. – Andrew Savinykh Dec 14 '16 at 8:25

1 = 1 + 0 * 2 * 7

2 = 2 + 0 * 1 * 7

3 = 1 + 2 + 0 * 7

4 = 7 - (0 + 1 + 2)

5 = 7 - 2 + 0 * 1

6 = 7 - 1 + 0 * 2

7 = 7 + 0 * 1 * 2

8 = 7 + 1 + 0 * 2

9 = 7 + 2 + 0 * 1

10 = 7 + 0 + 1 + 2

11 = 71 % 20

12 = 12 + 0 * 7

, where % is a modulus operator.

• why are some digits bold? – Marius Dec 13 '16 at 14:13
• @Marius Why are all the other numbers afraid of 7? Because 7 8 9 (eight is a homophone of ate). So 7 must be bold. Or it could be that Bhaskar highlighted the numbers which contribute to the final number, so 0 * 2 * 7 does not. – Andrew Morton Dec 13 '16 at 19:14
• @Marius looks like non-zero terms are bold – wilson Dec 14 '16 at 2:57
• @Marius : As Andrew and wilson say, I highlighted the non-zero terms that contribute to the final results. I thought it would help in reading it quicker. Nvm if it didnt. :) – Bhaskar Dec 14 '16 at 9:25

$1 = 1 ^ {720}$

$2 = 2^0 + 1^7$

$3 = 2^1 + 7^0$

$4 = 7 - 2 - 1 - 0$

$5 = 7 - 2^1 + 0$

$6 = (2 + 1)! + (7 × 0)$

$7 = 7 + ((2 + 1) × 0)$

$8 = 2 + 0 - 1 + 7$

$9 = 7 + 2 + (1 × 0)$

$10 = 2 + 0 + 1 + 7$

$11 = 2 + 0! + 1 + 7$

$12 = (7 + (2 + 1)!) - 0!$