Skip to main content
replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

Python 3, 48 47 bytes

Thanks to megomego for saving a byte with the -~i trick.

lambda s:''.join(c*-~i for i,c in enumerate(s)) 

This is mostly self-explanatory. One thing for those not versed in Python: The * operator is overloaded to act like Perl's x operator, repeating its string argument the number of times specified by its numeric argument. E.g. 'foo' * 3 == 'foofoofoo'

Python 3, 48 47 bytes

Thanks to mego for saving a byte with the -~i trick.

lambda s:''.join(c*-~i for i,c in enumerate(s)) 

This is mostly self-explanatory. One thing for those not versed in Python: The * operator is overloaded to act like Perl's x operator, repeating its string argument the number of times specified by its numeric argument. E.g. 'foo' * 3 == 'foofoofoo'

Python 3, 48 47 bytes

Thanks to mego for saving a byte with the -~i trick.

lambda s:''.join(c*-~i for i,c in enumerate(s)) 

This is mostly self-explanatory. One thing for those not versed in Python: The * operator is overloaded to act like Perl's x operator, repeating its string argument the number of times specified by its numeric argument. E.g. 'foo' * 3 == 'foofoofoo'

shaved off a byte - thanks mego
Source Link
jqkul
  • 2.3k
  • 1
  • 19
  • 24

Python 3, 4848 47 bytes

Thanks to mego for saving a byte with the -~i trick.

lambda s:''.join(c*(i+1)-~i for i,c in enumerate(s)) 

This is mostly self-explanatory. One thing for those not versed in Python: The * operator is overloaded to act like Perl's x operator, repeating its string argument the number of times specified by its numeric argument. E.g. 'foo' * 3 == 'foofoofoo'

Python 3, 48 bytes

lambda s:''.join(c*(i+1)for i,c in enumerate(s)) 

This is mostly self-explanatory. One thing for those not versed in Python: The * operator is overloaded to act like Perl's x operator, repeating its string argument the number of times specified by its numeric argument. E.g. 'foo' * 3 == 'foofoofoo'

Python 3, 48 47 bytes

Thanks to mego for saving a byte with the -~i trick.

lambda s:''.join(c*-~i for i,c in enumerate(s)) 

This is mostly self-explanatory. One thing for those not versed in Python: The * operator is overloaded to act like Perl's x operator, repeating its string argument the number of times specified by its numeric argument. E.g. 'foo' * 3 == 'foofoofoo'

Source Link
jqkul
  • 2.3k
  • 1
  • 19
  • 24

Python 3, 48 bytes

lambda s:''.join(c*(i+1)for i,c in enumerate(s)) 

This is mostly self-explanatory. One thing for those not versed in Python: The * operator is overloaded to act like Perl's x operator, repeating its string argument the number of times specified by its numeric argument. E.g. 'foo' * 3 == 'foofoofoo'