1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Rep Power

    functional programming

    Write a short function using the functional programming features of Python
    that takes a list of strings (say all of equal length) and creates one string
    c00 , c10 , · · · , cn0 , c01 , c11 , · · · , cn1 , · · · , where cij is the j th character of the
    ith string in the list. In other words form a string by taking the first
    character of each string in the list, then the second character of each
    string, etc. in that order and concatenating all of them to form the out-
    put string. Example: on an input of [”abc”, ”pqr”, ”123”, ”456”] it must
    return ”ap14bq25cr36”. Bonus marks if you manage you to do this with-
    out assuming that all the strings are of equal length
  2. #2
  3. Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Aug 2011
    Rep Power
    Oooh! This is a good application for itertools.zip_longest.

    I'd employ string methods as well.

    If the assignment is due within the hour you might pass if you're able to demonstrate that you understand the question and explain "functional programming features of Python".
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo