The perl solution best fits the problem description.

perl -ne 's!^([a-z])(\.?)$!print chop().($2?$/:$")for($1..a.$1)[1..25]!
ie'

http://codegolf.stackexchange.com/questions/7036/print-custom-alphabet

At the right hand side of Bob's sentence identify [i.{.@] as hook (i.{.)
to save a character.  Rearrange to release the passive adverb, removing
another character.  I next inserted a lengthy agenda to make the
sentence better agree with the task description.  Input testing though
improved, is still poor.

   golfabet=: 1j1&#@]`(,.@])`(''"_)@.([:+/' .'e.,)(a.{~,(2#65
97)+/i.26)&(1}.26{.(i.{.)}.[)
   
   golfabet 'c'      NB. spaces between letters, 'c' not in result
d e f g h i j k l m n o p q r s t u v w x y z a b 

   $ golfabet '`.'   NB. no output for some invalid inputs
0

   $ golfabet '0a'   NB. incorrect! ?
25 1

   NB. I'm sure I can fix this with 20 additional characters---


> From: bob therriault <bobtherria...@mac.com>
> To: programm...@jsoftware.com
> Subject: Re: [Jprogramming] Print Custom Alphabet
> Message-ID: <8421272d-bbb9-4eec-bcf7-38fe608f2...@mac.com>
> Content-Type: text/plain; CHARSET=US-ASCII
> 
> Tweaks get me down to 55
> 
>   (,.@]^:('.'e.[)(a.{~,2#65 97+/i.26)&(26{.[}.~1+[i.0{])) 'u' 
> vwxyzabcdefghijklmnopqrstu 


"I can name that tune in 3 notes!"

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to