Linda, your work is very nicely laid out. I bet you found my verb it as
mysterious as I found your verb i, both using rank and empties to
introduce spaces. I learned (or at least saw) a lesson in the global
view of your very clean i. Nice work. Kip
i
[: |. [: ,"2 [: |: (i.0) ,:~ [: |. [: |: [: |. h
On 2/22/2012 2:17 AM, Linda Alvord wrote:
> Happy George Washington's Birthday, Kip! "Now is the time for .... " is a
> great touch.
>
> f=: 13 :',\,(($y)?$y){y'
> g=: 13 :'((>:i.$y)?>:i.$y){"1 f y'
> h=: 13 :'(,.1+i.$y){."1 g y'
> i=: 13 :'|.,"2|:(|.|:|. h y),: 2#$'' '''
> gw=: 13 :'(,.-(1+#y)+i.#y)|."1 i y'
> gw 'many'
> y
> n y
> y n a
> n y m a
> gw 'many'
> m
> y m
> y n m
> n m a y
> gw 'cherrytrees'
> e
> s e
> s e e
> e e s r
> s e e e r
> e r t e s e
> t h s r e e e
> h c t e e e r s
> s e e h c e r r t
> c t r e e h s r y e
> s c e r y h e t e r r
> a=:gw '%%%####'
> a,.a,.a,.a
> # # # #
> # # # # # # # #
> # % # # % # # % # # % #
> % % # # % % # # % % # # % % # #
> % # # % # % # # % # % # # % # % # # % #
> % # # # % % % # # # % % % # # # % % % # # # % %
> % # # % # # % % # # % # # % % # # % # # % % # # % # # %
>
> f
> [: ,\ [: , ] {~ $ ? $
> g
> (([:>: [: i. $) ? [:>: [: i. $) {"1 f
> h
> ([: ,. 1 + [: i. $) {."1 g
> i
> [: |. [: ,"2 [: |: (i.0) ,:~ [: |. [: |: [: |. h
> gw
> ([: ,. [: - (1 + #) + [: i. #) |."1 i
>
> Linda
>
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Kip Murray
> Sent: Wednesday, February 22, 2012 12:24 AM
> To: Programming forum
> Subject: Re: [Jprogramming] Challenge 6 Many Many Cherry Trees
>
> NB. Linda's Challenge 6
>
>
> oit rt 'abcdef'
> f
> a f
> e a f
> f a d e
> f a e d c
> f e a b d c
>
> oit rt 1 2 3 4 5 6
> 6
> 1 6
> 1 4 6
> 1 2 4 6
> 4 1 6 2 3
> 6 5 4 2 3 1
>
>
> NB. Details follow, restrictions noted at end
>
>
> sh =: ?&#~ { ] NB. shuffle
>
> rt =: [: |. [: sh&> i.@#<@}."0 _ [: sh<"_1 NB. right triangle
>
> ]a =: 'abcdef'
> abcdef
>
> ]art =: rt a
> +-+-+-+-+-+-+
> |b| | | | | |
> +-+-+-+-+-+-+
> |c|b| | | | |
> +-+-+-+-+-+-+
> |c|b|a| | | |
> +-+-+-+-+-+-+
> |c|e|b|a| | |
> +-+-+-+-+-+-+
> |c|e|a|d|b| |
> +-+-+-+-+-+-+
> |f|c|a|b|d|e|
> +-+-+-+-+-+-+
>
> ]b =: 1 2 3 4 5 6
> 1 2 3 4 5 6
>
> ]brt =: rt b
> +-+-+-+-+-+-+
> |5| | | | | |
> +-+-+-+-+-+-+
> |2|5| | | | |
> +-+-+-+-+-+-+
> |2|6|5| | | |
> +-+-+-+-+-+-+
> |6|4|2|5| | |
> +-+-+-+-+-+-+
> |4|5|1|2|6| |
> +-+-+-+-+-+-+
> |3|1|4|5|6|2|
> +-+-+-+-+-+-+
>
>
> ia =: ([ , a: , ])/ NB. insert a:
>
> it =: 3 : 0 " 1 NB. isosceles triangle from right triangle
> xx =. y i. a:
> ((-xx-#y) # a:), ia xx {. y
> )
>
> it art
> +-+-+-+-+-+-+-+-+-+-+-+
> | | | | | |b| | | | | |
> +-+-+-+-+-+-+-+-+-+-+-+
> | | | | |c| |b| | | | |
> +-+-+-+-+-+-+-+-+-+-+-+
> | | | |c| |b| |a| | | |
> +-+-+-+-+-+-+-+-+-+-+-+
> | | |c| |e| |b| |a| | |
> +-+-+-+-+-+-+-+-+-+-+-+
> | |c| |e| |a| |d| |b| |
> +-+-+-+-+-+-+-+-+-+-+-+
> |f| |c| |a| |b| |d| |e|
> +-+-+-+-+-+-+-+-+-+-+-+
>
> it brt
> +-+-+-+-+-+-+-+-+-+-+-+
> | | | | | |5| | | | | |
> +-+-+-+-+-+-+-+-+-+-+-+
> | | | | |2| |5| | | | |
> +-+-+-+-+-+-+-+-+-+-+-+
> | | | |2| |6| |5| | | |
> +-+-+-+-+-+-+-+-+-+-+-+
> | | |6| |4| |2| |5| | |
> +-+-+-+-+-+-+-+-+-+-+-+
> | |4| |5| |1| |2| |6| |
> +-+-+-+-+-+-+-+-+-+-+-+
> |3| |1| |4| |5| |6| |2|
> +-+-+-+-+-+-+-+-+-+-+-+
>
>
> vertchars =: 25 124 { a.
>
> oit =: 3 : 0
>
> NB. produces open isosceles triangle from boxed right triangle y
>
> rc =. 1:`{.@.(2=#) $ y NB. row count
>
> dhr =.<: {. $ ": 0 { y NB. decrement height of row display
>
> mhb =. (>: rc * dhr) $ 0 , (<: dhr) # 1 NB. mask for horz boundaries
>
> NB. now remove horz then vert boundaries from display of (it y)
>
> vertchars -."1~ mhb # ": it y
> )
>
> oit art
> b
> c b
> c b a
> c e b a
> c e a d b
> f c a b d e
>
> oit brt
> 5
> 2 5
> 2 6 5
> 6 4 2 5
> 4 5 1 2 6
> 3 1 4 5 6 2
>
> ]c =: 6 4 $ 'Now is the timefor all '
> Now
> is
> the
> time
> for
> all
>
> ]crt =: rt c
> +----+----+----+----+----+----+
> |Now | | | | | |
> +----+----+----+----+----+----+
> |Now |for | | | | |
> +----+----+----+----+----+----+
> |is |for |Now | | | |
> +----+----+----+----+----+----+
> |the |Now |is |for | | |
> +----+----+----+----+----+----+
> |is |Now |for |all |the | |
> +----+----+----+----+----+----+
> |all |time|the |Now |for |is |
> +----+----+----+----+----+----+
>
> oit crt
> Now
> Now for
> is for Now
> the Now is for
> is Now for all the
> all time the Now for is
>
> ]d =: 3 2 4 $ 'Now is the timefor all '
> Now
> is
>
> the
> time
>
> for
> all
>
> ]drt =: rt d
> +----+----+----+
> |the | | |
> |time| | |
> +----+----+----+
> |Now |the | |
> |is |time| |
> +----+----+----+
> |the |for |Now |
> |time|all |is |
> +----+----+----+
>
> oit drt
> the
> time
> Now the
> is time
> the for Now
> time all is
>
>
> NB. For verb oit to work, arguments to verb rt need to be open and
> NB. free of vertchars. I leave it as an exercise to remove these
> NB. requirements!
>
>
> Kip Murray
>
> On 2/14/2012 3:54 AM, Linda Alvord wrote:
>> Challenge 6 Many Many Cherry Trees PLEASE DO NOT RESPOND UNTIL 2/22/2012
>> 12 am EST
>>
>>
>>
>>
>>
>> If necessary, ask questions, but try not to give away your strategy for
>> solving the challenge.
>>
>>
>>
>> Design a function with no restrictions on style or specific functions.
>>
>> It should produce a triangle similar to the ones shown below. Each row is
> a
>> successive scramble of the character string above it with one added
> symbol.
>> The final line is a scramble of the entire list.
>>
>>
>>
>> gw 'many'
>>
>> a
>> a n
>> a y n
>> a m y n
>>
>>
>>
>> gw 'many'
>>
>> m
>> y m
>> y a m
>> n a m y
>>
>>
>>
>> gw 'cherrytrees'
>>
>> s
>> r s
>> h s r
>> h r s y
>> y s r e h
>> e h r s r y
>> y r e s h e r
>> s e r r e y e h
>> e s t e r e y h r
>> r e r s t r y e e h
>> e r c r h y r e t s e
>>
>> a=:gw '%%%####'
>>
>> a,.a,.a,.a
>>
>> % % % %
>> % # % # % # % #
>> % # % % # % % # % % # %
>> % # # % % # # % % # # % % # # %
>> # % # % # # % # % # # % # % # # % # % #
>> # % # % % # # % # % % # # % # % % # # % # % % #
>> # % # # # % % # % # # # % % # % # # # % % # % # # # % %
>>
>>
>>
>> Linda
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm