Mailing List Archive: 49091 messages

## [REBOL] Re: Monday Puzzle

### From: jelinem1::nationwide::com at: 24-Jul-2001 9:34

```
Either I've got too much time or I'm a perfectionist. This may be the
solution you were looking for:

>> r: [0 [1 [2 [3 [4 [5 [6 [7 [8 [9]]]]]]]]]]
== [0 [1 [2 [3 [4 [5 [6 [7 [8 [9]]]]]]]]]]
>> append/only r/2/2/2/2/2/2/2/2/2 r
== [9 [0 [1 [2 [3 [4 [5 [6 [7 [8 [...]]]]]]]]]]]
>> r
== [0 [1 [2 [3 [4 [5 [6 [7 [8 [9 [...]]]]]]]]]]]
>> ; ----------------------------------------------------
>> loop 20 [prin [r/1 " "] r: second r] print ""
0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5  6  7  8  9
>> loop 20 [prin [length? y " "] y: second y] print ""
2  2  2  2  2  2  2  2  2  2  2  2  2  2  2  2  2  2  2  2

- Michael Jelinek

From:   [JELINEM1--nationwide--com]@rebol.com on 07/24/2001 08:22 AM
Sent by:        [rebol-bounce--rebol--com]
To:     [rebol-list--rebol--com]
cc:
Subject:        [REBOL] Re: Monday Puzzle

Here's a "brute force" solution. All else I can think of are either a
variation of this, or require more code to set up the 'y block.

>> f: does [a: [9] either 9 = a/1 [a/1: 0][a/1: 1 + a/1]]
>> y: []
== []
>> append y :f
== [func [][a: [9] either 9 = a/1 [a/1: 0] [a/1: 1 + a/1]]]
>> append/only y y
== [func [][a: [9] either 9 = a/1 [a/1: 0] [a/1: 1 + a/1]] [...]]
>> ; ----------------------------------------------------
>> loop 20 [prin [y/1 " "] y: second y] print ""
0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5  6  7  8  9
>> loop 20 [prin [length? y " "] y: second y] print ""
2  2  2  2  2  2  2  2  2  2  2  2  2  2  2  2  2  2  2  2

A nice diversion from work.

- Michael Jelinek

From:   "Larry Palmiter" <[larry--ecotope--com]>@rebol.com on 07/23/2001 10:29

PM
Sent by:        [rebol-bounce--rebol--com]
To:     <[rebol-list--rebol--com]>
cc:
Subject:        [REBOL] Monday Puzzle

Hi all,

Here's a puzzle. I made a block named y of length 2 which shows the
following behavior:

>> type? y
== block!
>> length? y
== 2
>> y/1
== 0

>> loop 20 [prin [y/1 " "] y: second y] print ""
0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5  6  7  8  9

Here's a hint!

>> loop 20 [prin [length? y " "] y: second y] print ""
2  2  2  2  2  2  2  2  2  2  2  2  2  2  2  2  2  2  2  2

How was the block constructed and what does the MOLD of the block look
like?

Enjoy
-Larry
```