Here's the goal: make a function that takes any number of equal-length strings, and returns an array of strings, where each string is the concatenation of the Nth character in each string.
japhy -- Perl and Regex Hacker
Sample input: qw( jeff john mary )
Sample output: qw( jjm eoa fhr fny )
Here are my attempts:
# 51 chars sub s2a{@_=@_;reverse+map{join"",map+chop,@_}1..length$_[0]} # 51 chars sub s2a{@_=@_;map{join"",map+s/(.)//s&&$1,@_}1..length$_[0]} # 48 chars sub s2a{map{join"",map+s/(.)//s&&$1,@_=@_}1..length$_[0]} # 47 chars sub s2a{map{join"",map{s/(.)//s;$1}@_=@_}1..length$_[0]} # 45 chars sub s2a{map{join"",map{s/.//s;$&}@_=@_}1..length$_[0]}
japhy -- Perl and Regex Hacker
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: (Golf) Strings-to-Array
by tye (Sage) on Mar 29, 2001 at 02:34 UTC | |
Re (tilly) 1: (Golf) Strings-to-Array
by tilly (Archbishop) on Mar 30, 2001 at 09:17 UTC | |
by MeowChow (Vicar) on Mar 30, 2001 at 12:18 UTC | |
by jorg (Friar) on Mar 30, 2001 at 15:46 UTC | |
by tilly (Archbishop) on Mar 30, 2001 at 18:09 UTC | |
by demerphq (Chancellor) on Sep 01, 2001 at 04:56 UTC | |
by tilly (Archbishop) on Sep 01, 2001 at 05:13 UTC | |
by demerphq (Chancellor) on Sep 01, 2001 at 18:27 UTC | |
by tilly (Archbishop) on Sep 03, 2001 at 03:38 UTC | |
by demerphq (Chancellor) on Sep 01, 2001 at 05:37 UTC | |
Re: (Golf) Strings-to-Array
by MeowChow (Vicar) on Mar 30, 2001 at 07:42 UTC | |
by japhy (Canon) on Mar 30, 2001 at 07:48 UTC | |
Re: (Golf) Strings-to-Array
by MrNobo1024 (Hermit) on Mar 29, 2001 at 03:50 UTC | |
by japhy (Canon) on Mar 29, 2001 at 04:21 UTC | |
Re: (Golf) Strings-to-Array
by MeowChow (Vicar) on Mar 30, 2001 at 23:21 UTC |
Back to
Obfuscated Code