Thursday, May 13, 2010

13 chars in [4,+,-,*,/] can make all number in range(60)

Hi, it is Dr. NISHIO Hirokazu. Today I wonder how much characters required to make fixed-width one-digit-only digital clock. Which digit is the most suitable?

When I allow to use bitwise calculation, 5 is the most suitable digit. It requires only 8 characters.

0 555/5555
1 ~~-5+-~5
2 -~-5+-~5
3 555&5*55
...

Surprisingly in the hardest restriction it requires only 13 characters.

  • no bitwise operation. allow only the 4 arithmetical operations.
  • no minus-minus connection. 4--4 = 4 - -4 is not allowed
  • negate operation should not be aside of the other operation. 4+-4, 4*-4, 4/-4 are also omitted
  • true division. 4 / 44 is not 0, it is 1 / 11.


Here is the result. I think 37 == 4444/44-4*4*4 is very cute!! I love it!


0 4444*4-4*4444
1 44-44+444/444
2 4/4+4444/4444
3 44/44+4/4+4/4
4 4-4/4+444/444
5 4-4-4+4+4+4/4
6 4-4/4+4-44/44
7 -4-44+44+44/4
8 4-4*44+44*4+4
9 4-4+4+4+44/44
10 444/4-4444/44
11 -4+4-4+4+44/4
12 4-4-4-4+4*4+4
13 4-4-4+4*4+4/4
14 4-4/44+444/44
15 4-4+4*4-44/44
16 -4-4-4-4*4+44
17 4*4+4444/4444
18 4+4*4-4/4-4/4
19 -44+4*4*4-4/4
20 4-4/4+4*4+4/4
21 4-4+4+4*4+4/4
22 4-4+44/4+44/4
23 4+4+4*4-44/44
24 4-44+44+4*4+4
25 -4-4*4+44+4/4
26 -4/4+4*4+44/4
27 -4+4*4+4+44/4
28 4*4-4-4+4*4+4
29 4-4-4-44/4+44
30 4+4+44/4+44/4
31 4*4+4*4-44/44
32 44-44/4-44/44
33 44/44+4*4+4*4
34 44+44/44-44/4
35 -44/44-4-4+44
36 -44-4-4+44+44
37 4444/44-4*4*4
38 4-44/4+44+4/4
39 -4-4+4-4/4+44
40 -4*4-4+4*4+44
41 -4+44+444/444
42 -4+44+4/4+4/4
43 -4+44+4-44/44
44 -4*44+44*4+44
45 -44+44+44+4/4
46 -4/4-4/4+4+44
47 -4-4/4+4+44+4
48 -4-4-4+4*4+44
49 -44/4-4+4*4*4
50 44-4-4/4+44/4
51 4+44+44/4-4-4
52 -44+4+44+44+4
53 44+4+4*4-44/4
54 44+44/4-44/44
55 44-44+44+44/4
56 4-4-4-4+4*4*4
57 4/4-4-4+4*4*4
58 4-4/4+44+44/4
59 44+4-4+4+44/4


see also The list of all numbers which can generate from nine 4s and arithmetics operations.

No comments: