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/55551       ~~-5+-~52       -~-5+-~53       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*44441 44-44+444/4442 4/4+4444/44443 44/44+4/4+4/44 4-4/4+444/4445 4-4-4+4+4+4/46 4-4/4+4-44/447 -4-44+44+44/48 4-4*44+44*4+49 4-4+4+4+44/4410 444/4-4444/4411 -4+4-4+4+44/412 4-4-4-4+4*4+413 4-4-4+4*4+4/414 4-4/44+444/4415 4-4+4*4-44/4416 -4-4-4-4*4+4417 4*4+4444/444418 4+4*4-4/4-4/419 -44+4*4*4-4/420 4-4/4+4*4+4/421 4-4+4+4*4+4/422 4-4+44/4+44/423 4+4+4*4-44/4424 4-44+44+4*4+425 -4-4*4+44+4/426 -4/4+4*4+44/427 -4+4*4+4+44/428 4*4-4-4+4*4+429 4-4-4-44/4+4430 4+4+44/4+44/431 4*4+4*4-44/4432 44-44/4-44/4433 44/44+4*4+4*434 44+44/44-44/435 -44/44-4-4+4436 -44-4-4+44+4437 4444/44-4*4*438 4-44/4+44+4/439 -4-4+4-4/4+4440 -4*4-4+4*4+4441 -4+44+444/44442 -4+44+4/4+4/443 -4+44+4-44/4444 -4*44+44*4+4445 -44+44+44+4/446 -4/4-4/4+4+4447 -4-4/4+4+44+448 -4-4-4+4*4+4449 -44/4-4+4*4*450 44-4-4/4+44/451 4+44+44/4-4-452 -44+4+44+44+453 44+4+4*4-44/454 44+44/4-44/4455 44-44+44+44/456 4-4-4-4+4*4*457 4/4-4-4+4*4*458 4-4/4+44+44/459 44+4-4+4+44/4`

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