If by simplification you mean "fewer tokens while avoiding text
definitions and @ and @: then here is a variation on Jose's approach:

 waveR=: [:<"_1 [:|.&|:^:4 3 2 1 0 [:(|."_1~ [:>. +/ .=&' ' % _2:) [:> ;:

I save 3 tokens by replacing (<5) with 4 3 2 1 0

I save 2 tokens by replacing
   [: - [: <. [: -: ' '+/ .=~
with
   [: >. +/ .=&' ' % _2:

I save 2 tokens by replacing
   ([: |. |:)
with
   |.&|:

Note, however that if you are purely counting tokens, u@v and u@:v can
be simpler than ([: u v).

Also, if you count text as a single token, text definitions are
automatically simpler than most everything.  (But if you add to the
token count the number of tokens represented in the text, this goes
away.)

-- 
Raul

On Sun, Jun 3, 2012 at 10:23 AM, Linda Alvord <lindaalv...@verizon.net> wrote:
>
> Viktor Cerovski and Jose Quintanta have provided solutions that are
> simplifying the waves.
>
>   B=:'a big arrow focused somewhere'
>   wave=: [: <"2 [: ([: |: |.)^:(<5) ([: > ;:)|."0 1~ [: - [: <. [: -: [:
> +/"1 ' ' = [: > ;:
>   #;:'[: <"2 [: ([: |: |.)^:(<5) ([: > ;:) |."0 1~ [: - [: <. [: -: [: +/"1
> '' '' = [: > ;:'
> 40
>   waveVC=:[: <"2 [: ([: |: |.)^:(<5) [: (|."0 1~ [: - [: <. [: -: [: +/"1 '
> ' = ]) [: > ;:
>   #;:'[: <"2 [: ([: |: |.)^:(<5) [: (|."0 1~ [: - [: <. [: -: [: +/"1 '' ''
> = ]) [: > ;'
> 39
>   waveJQ=.[: <"2 [: ([: |: |.)^:(<5) [: (|."0 1~ [: - [: <. [: -: ' '+/ .=~
> ]) [: > ;:
>   #;:'[: <"2 [: ([: |: |.)^:(<5) [: (|."0 1~ [: - [: <. [: -: '' ''+/ .=~
> ]) [: > ;:'
> 38
>   Any more simplifications waiting in thewings?
>
> Linda
>
> -----Original Message-----
> From: programming-boun...@jsoftware.com
> [mailto:programming-boun...@jsoftware.com] On Behalf Of Jose Quintana
> Sent: Sunday, June 03, 2012 12:33 AM
> To: programming@jsoftware.com
> Subject: Re: [Jprogramming] Challenge 11 Wave the Flag
>
>
> Cheating...    wave1=. [: <"2 [: ([: |: |.)^:(<5) [: (|."0 1~ [: - [: <. [:
> -: ' ' +/ .=~ ]) [: > ;:
>
>   cheat=. (lr<'wave1')&apply f.
>   lr<'cheat'
> '[: <"2 [: ([: |: |.)^:(<5) [: (|."0 1~ ([: - [: <. [: -: '' '' +/ .=~ ]))
> [: > ;:'&(128!:2)
>   #;:lr<'cheat'
> 7
> ... and without cheating
>   wave1=. [: <"2 [: ([: |: |.)^:(<5) [: (|."0 1~ [: - [: <. [: -: ' ' +/
> .=~ ]) [: > ;:
>   #;:    '[: <"2 [: ([: |: |.)^:(<5) [: (|."0 1~ [: - [: <. [: -: '' '' +/
> .=~ ]) [: > ;:'
> 38    > Date: Sat, 2 Jun 2012 02:38:40 -0700
>> From: viktor.cerov...@gmail.com
>> To: programming@jsoftware.com
>> Subject: Re: [Jprogramming] Challenge 11 Wave the Flag
>>
>>
>>
>>
>> Linda Alvord wrote:
>> >
>> >
>> >
>> > It was David Ward Lambert's idea to write a one line expression with
>> > the fewest tokens.  We worked together and got to 40 tokens.  Any
>> > ideas to make this any better.
>> >
>> >
>> >
>> >    B=:'a big arrow focused somewhere'
>> >
>> >    NB.  center justify (Hint from DWL  x |."0 1 y)
>> >
>> >    cj=: 13 :'(-<.-:+/"1 '' ''=>;:y)|."0 1>;:y'
>> >
>> >    cj
>> >
>> > ([: - [: <. [: -: [: +/"1 ' ' = [: > ;:) |."0 1 [: > ;:
>> >
>> >    cj B
>> >
>> >     a
>> >    big
>> >   arrow
>> >  focused
>> > somewhere
>> >
>> >    NB. quarter turns
>> >
>> >    qtla=: 13 :'y;(|:|.y);(|.|:|.|:y);(|.|:y);y'
>> >
>> >    qtla
>> >
>> > ] ; ([: |: |.) ; ([: |. [: |: [: |. |:) ; ] ;~ [: |. |:
>> >
>> >    qtla cj B
>> >
>> > ----------T-----T---------T-----T---------┐
>> > │    a    │s    │erehwemos│    e│    a    │
>> > │   big   │of   │ desucof │   dr│   big   │
>> > │  arrow  │moa  │  worra  │  wee│  arrow  │
>> > │ focused │ecrb │   gib   │ gosh│ focused │
>> > │somewhere│wuria│    a    │airuw│somewhere│
>> > │         │hsog │         │ brce│         │
>> > │         │eew  │         │  aom│         │
>> > │         │rd   │         │   fo│         │
>> > │         │e    │         │    s│         │
>> > L---------+-----+---------+-----+----------
>> >
>> >    NB. 5 quarter turns David Ward Lambert
>> >
>> >    qtdwl=: 13 :'<"2 ([:|:|.)^:(<5)y'
>> >
>> >    qtdwl cj B
>> >
>> > ----------T---------T---------T---------T---------┐
>> > │    a    │s        │erehwemos│    e    │    a    │
>> > │   big   │of       │ desucof │   dr    │   big   │
>> > │  arrow  │moa      │  worra  │  wee    │  arrow  │
>> > │ focused │ecrb     │   gib   │ gosh    │ focused │
>> > │somewhere│wuria    │    a    │airuw    │somewhere│
>> > │         │hsog     │         │ brce    │         │
>> > │         │eew      │         │  aom    │         │
>> > │         │rd       │         │   fo    │         │
>> > │         │e        │         │    s    │         │
>> > L---------+---------+---------+---------+----------
>> >
>> >    qtdwl
>> >
>> > [: <"2 ([: |: |.)^:(<5)
>> >
>> >
>> >
>> >    wave=: [: <"2 [: ([: |: |.)^:(<5) ([: > ;:)|."0 1~ [: - [: <. [: -:
> [:
>> > +/"1 ' ' = [: > ;:
>> >
>> >
>> Here is a 39 token version:
>>
>>    wave1=:[: <"2 [: ([: |: |.)^:(<5) [: (|."0 1~ [: - [: <. [: -: [: +/"1
> '
>> ' = ]) [: > ;:
>>
>>    #;:'[: <"2 [: ([: |: |.)^:(<5) [: (|."0 1~ [: - [: <. [: -: [: +/"1 ''
> ''
>> = ]) [: > ;:'
>> 39
>>
>>
>>
>> >
>> >    wave B
>> >
>> > ----------T---------T---------T---------T---------┐
>> > │    a    │s        │erehwemos│    e    │    a    │
>> > │   big   │of       │ desucof │   dr    │   big   │
>> > │  arrow  │moa      │  worra  │  wee    │  arrow  │
>> > │ focused │ecrb     │   gib   │ gosh    │ focused │
>> > │somewhere│wuria    │    a    │airuw    │somewhere│
>> > │         │hsog     │         │ brce    │         │
>> > │         │eew      │         │  aom    │         │
>> > │         │rd       │         │   fo    │         │
>> > │         │e        │         │    s    │         │
>> > L---------+---------+---------+---------+----------
>> >
>> >    wave
>> >
>> > [: <"2 [: ([: |: |.)^:(<5) ([: > ;:) |."0 1~ [: - [: <. [: -: [: +/"1 '
> '
>> > =
>> > [: > ;:
>> >
>> >    #;:'[:<"2[:([:|:|.)^:(<5)([:>;:)|."0 1~[:-[:<.[:-:[:+/"1'' ''=[:>;:'
>> >
>> > 40
>> >
>> >
>> >
>> > Hopefully David will send his version of 39 tokens but not simple J.
>> > Note also that you must paste the long line for wave together.
>> >
>> >
>> >
>> > Linda
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > From: Linda Alvord [mailto:lindaalv...@verizon.net]
>> > Sent: Tuesday, May 01, 2012 3:17 AM
>> > To: 'Linda Alvord'
>> > Subject: Challenge 11 Wave the Flag
>> >
>> >
>> >
>> > Challenge 10 Wave the Flag    PLEASE DO NOT RESPOND UNTIL 5/28/2012  12
> am
>> > EST
>> >
>> >
>> >
>> > Here's a little preparation for Memorial Day.
>> >
>> >
>> >
>> >   S=:10 16$(16$' '),176$(16$'*  '),16$' * '
>> >
>> >    T=:10 36$(36$'#'),72$' '
>> >
>> >    U=:9 52$(104$' '),364$(52$'#'),104$' '
>> >
>> >    <' ',"1(((S,"1 ' '),.T),U),"1 ' '
>> >
>> > --------------------------------------------------------┐
>> > │                  #################################### │
>> > │ *  *  *  *  *  *                                      │
>> > │  *  *  *  *  *                                        │
>> > │ *  *  *  *  *  * #################################### │
>> > │  *  *  *  *  *                                        │
>> > │ *  *  *  *  *  *                                      │
>> > │  *  *  *  *  *   #################################### │
>> > │ *  *  *  *  *  *                                      │
>> > │  *  *  *  *  *                                        │
>> > │ *  *  *  *  *  * #################################### │
>> > │                                                       │
>> > │                                                       │
>> > │ ####################################################  │
>> > │                                                       │
>> > │                                                       │
>> > │ ####################################################  │
>> > │                                                       │
>> > │                                                       │
>> > │ ####################################################  │
>> > L--------------------------------------------------------
>> >
>> >
>> >
>> > Part 1:  Use viewmat and create a little flag. Next design a
>> > function to rotate it clockwise 90 degrees successively until it is
>> > in the original position.
>> >
>> >
>> >
>> >    load viewmat
>> >
>> >    flag=:
>> >
>> > wwwwwwww
>> > wwwwwwww
>> > wwwwwwww
>> > wwwwwwww
>> >
>> > wwwwwwwwwwwwww
>> >
>> > wwwwwwww
>> > wwwwwwww
>> > wwwwwwww
>> > wwwwwwww
>> >
>> > wwwwwwwwwwwwww
>> >
>> > wwwwwwww
>> > wwwwwwww
>> > wwwwwwww
>> > wwwwwwww
>> >
>> > wwwwwwwwwwwwww
>> >
>> > wwwwwwww
>> > wwwwwwww
>> > wwwwwwww
>> > wwwwwwww
>> >
>> > wwwwwwwwwwwwww
>> >
>> > wwwwwwww
>> > wwwwwwww
>> > wwwwwwww
>> > wwwwwwww
>> >
>> >
>> >
>> > Part 2:
>> >
>> >
>> >
>> >    A=:'we celebrate Memorial Day on May the twenty eighth'
>> >
>> >    wave=:
>> >
>> > ------------T-----------T-----------T-----------T-----------┐
>> > │----------┐│----------┐│----------┐│----------┐│----------┐│
>> > ││   we    │││      Mc │││  hthgie │││ e       │││   we    ││
>> > ││celebrate│││et    ee │││  ytnewt │││ tl      │││celebrate││
>> > ││Memorial │││iw    ml │││   eht   │││ aa    yh│││Memorial ││
>> > ││   Day   │││getMoDoew│││   yaM   │││ riy yett│││   Day   ││
>> > ││   on    │││hnhanarbe│││    no   │││ebranahnh│││   on    ││
>> > ││   May   │││ttey yir │││   yaD   │││weoDoMteg│││   May   ││
>> > ││   the   │││hy    aa │││ lairomeM│││ lm    wi│││   the   ││
>> > ││ twenty  │││      lt │││etarbelec│││ ee    te│││ twenty  ││
>> > ││ eighth  │││       e │││    ew   │││ cM      │││ eighth  ││
>> > │L----------│L----------│L----------│L----------│L----------│
>> > L-----------+-----------+-----------+-----------+------------
>> >
>> >
>> >
>> > Reshape A into a 9 9 square matrix. Justify all lines in the center.
>> > If a line has an even number of letters put the extra letter on the
>> > left. Now design a function to rotate the words in a similar fashion
>> > to the flag above.  Note the letters in "we" as they move around
>> > clockwise. Your function should work for any square literal matrix.
>> >
>> >
>> >
>> > Happy Memorial Day!
>> >
>> >
>> >
>> > Linda
>> >
>> > --------------------------------------------------------------------
>> > -- For information about J forums see
>> > http://www.jsoftware.com/forums.htm
>> >
>>
>> --
>> View this message in context:
>> http://old.nabble.com/Re%3A-Challenge-11-Wave-the-Flag-tp33948875s2419
>> 3p33948951.html Sent from the J Programming mailing list archive at
>> Nabble.com.
>>
>> ----------------------------------------------------------------------
>> 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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to