(archive 'newLISPer)

December 21, 2005

Christmas quiz: four by four

Filed under: newLISP — newlisper @ 10:53
Tags:

Here’s a version of a traditional puzzle to exercise your mental maths muscles before Christmas. In newLISP, define symbols zero through nine that evaluate to their integer equivalents. In other words, define symbols so that you can type this into a newLISP console:

> zero one two three four five six seven eight nine

and get the answer:

0 1 2 3 4 5 6 7 8 9

However, the restrictions are that you cannot use any digits other than 4, and you must use four 4s, no fewer and no more. You can also use all the arithmetic operators (and parentheses, obviously).

To get you started, here’s the easiest one – zero:

(set 'zero (- 44 44))
Advertisements

2 Comments »

  1. >My first pass at solutions:(set ‘zero (- 44 44))(set ‘zero (+ 4 4 (- 4) (- 4)))(set ‘zero (+ 4 4 (- (+ 4 4))))(set ‘one (/ 44 44))(set ‘one (+ (/ 4 4) (- 4 4)))(set ‘one (+ (/ 4 4) (+ 4 (- 4))))(set ‘two (/ (* 4 4) (+ 4 4)))(set ‘two (+ (/ 4 4) (/ 4 4)))(set ‘two (- 4 (/ (+ 4 4) 4)))(set ‘three (/ (+ 4 4 4) 4))(set ‘four (+ 4 (* 4 (- 4 4))))(set ‘five (/ (+ 4 (* 4 4)) 4))(set ‘six (+ 4 (/ (+ 4 4) 4)))(set ‘seven (- (/ 44 4) 4))(set ‘seven (- (+ 4 4) (/ 4 4)))(set ‘eight (/ (* 4 (+ 4 4)) 4))(set ‘eight (- (* 4 4) (+ 4 4)))(set ‘eight (- (+ 4 4 4) 4))(set ‘nine (+ (+ 4 4) (/ 4 4)))P.S., I really like this blog!

    Comment by Sammo — December 22, 2005 @ 17:26 | Reply

  2. >Well done! I can’t imagine a more comprehensive set of answers!I suspect this question is many centuries old…

    Comment by newlisper — December 29, 2005 @ 21:39 | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: