From: riks@ogicse.ogi.edu (Rik Fischer Smoody)
Newsgroups: rec.puzzles
Subject: Re: Four of a kind
Date: 28 Aug 92 00:00:35 GMT
Article-I.D.: ogicse.42052
Organization: Oregon Graduate Institute (formerly OGC), Beaverton, OR

In article <1992Aug27.183258.15169@ecst.csuchico.edu> PANDERSON@OAVAX.CSUCHICO.EDU writes:
>Take four numbers and writ them down beside each other. e.g.
>
>5   3   17   34
>
>Find the difference between each number and the number to its right. In 
>the case of the fourth number find the difference between it and the first 
>number( that is in this case between 17 and 21). Continue to do this and 
>you will always come to four of the smae number. This apparently only 
>works with four number.
>
>Example:
>
>5   3  17   34
>2   14  17  29
>12  3    12  27
>9   9     15  15
>0   6      0    6
>6   6      6    6
Actually, you must take the absolute value of differences, but not to quibble.
I think it's guaranteed to work for any 2**N numbers.
For example:

1 (0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 7 )
2 (7 0 0 3 3 0 0 0 0 0 0 0 0 0 0 7 )
3 (0 7 0 3 0 3 0 0 0 0 0 0 0 0 0 7 )
4 (7 7 7 3 3 3 3 0 0 0 0 0 0 0 0 7 )
5 (0 0 0 4 0 0 0 3 0 0 0 0 0 0 0 7 )
6 (7 0 0 4 4 0 0 3 3 0 0 0 0 0 0 7 )
7 (0 7 0 4 0 4 0 3 0 3 0 0 0 0 0 7 )
8 (7 7 7 4 4 4 4 3 3 3 3 0 0 0 0 7 )
9 (0 0 0 3 0 0 0 1 0 0 0 3 0 0 0 7 )
10 (7 0 0 3 3 0 0 1 1 0 0 3 3 0 0 7 )
11 (0 7 0 3 0 3 0 1 0 1 0 3 0 3 0 7 )
12 (7 7 7 3 3 3 3 1 1 1 1 3 3 3 3 7 )
13 (0 0 0 4 0 0 0 2 0 0 0 2 0 0 0 4 )
14 (4 0 0 4 4 0 0 2 2 0 0 2 2 0 0 4 )
15 (0 4 0 4 0 4 0 2 0 2 0 2 0 2 0 4 )
16 (4 4 4 4 4 4 4 2 2 2 2 2 2 2 2 4 )
17 (0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 2 )
18 (2 0 0 0 0 0 0 2 2 0 0 0 0 0 0 2 )
19 (0 2 0 0 0 0 0 2 0 2 0 0 0 0 0 2 )
20 (2 2 2 0 0 0 0 2 2 2 2 0 0 0 0 2 )
21 (0 0 0 2 0 0 0 2 0 0 0 2 0 0 0 2 )
22 (2 0 0 2 2 0 0 2 2 0 0 2 2 0 0 2 )
23 (0 2 0 2 0 2 0 2 0 2 0 2 0 2 0 2 )
24 (2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 )



Here's a Smalltalk hack that you can play with to see what's going on...
'From Objectworks(r)\Smalltalk, Release 4.0b of 8 November 1991 on 27 August 1992 at 4:53:32 pm'!

OrderedCollection variableSubclass: #CircleCollection
    instanceVariableNames: ''
    classVariableNames: ''
    poolDictionaries: ''
    category: 'Collections-Sequenceable'!


!CircleCollection methodsFor: 'computing'!

circleDiffabs
    | rslt tmp |
    rslt := self copyEmpty: self size.
    tmp := self last.
    self do: [ :each |
        rslt add: (tmp - each) abs.
        tmp := each].
    ^rslt!

circleDiffall
    | coll iter |
    coll := self.
    iter := 0.
    [ (coll detect: [ :e | e > 0] ifNone: [nil]) isNil] whileFalse: [
	iter := iter +1.
        Transcript cr; show: iter printString.
        Transcript space; show: coll printString.
        coll := coll  circleDiffabs].

"       | cd |
    cd _ CircleCollection new.
    cd addAll: #(0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 7).
    cd circleDiffall
"! !

!CircleCollection methodsFor: 'printing'!

printOn: aStream
    "Append to the argument aStream a sequence of characters
    that identifies the collection.  ."
    aStream nextPut: $(.
    self do:
        [:element |
        element printOn: aStream.
        aStream space].
    aStream nextPut: $)! !

Rik Fischer Smoody
    smOOdynamics	Systems Made Outa Objects
	2400 NE 25th, Suite 800
	Portland, OR 97212
503-249-8300		riks@cse.ogi.edu
Newsgroups: rec.puzzles