+ 7
Challenge: String Accumulator
Given an input string, must output an "accumulated" string, like shown in examples: input string --> output string "abc" --> "A-Bb-Ccc" "ECxa" --> "E-Cc-Xxx-Aaaa" "XmkkucH" --> "X-Mm-Kkk-Kkkk-Uuuuu-Cccccc-Hhhhhhh" "SoloLearN" --> "S-Oo-Lll-Oooo-Lllll-Eeeeee-Aaaaaaa-Rrrrrrrr-Nnnnnnnnn" "QpYWffvYGGyaX" --> "Q-Pp-Yyy-Wwww-Fffff-Ffffff-Vvvvvvv-Yyyyyyyy-Ggggggggg-Gggggggggg-Yyyyyyyyyyy-Aaaaaaaaaaaa-Xxxxxxxxxxxxx" And so on.. Let the codes begin and... happy hacking!
8 odpowiedzi
+ 13
+ 7
my seven-liner code in Python.. 😅
https://code.sololearn.com/cbnu8d6se3q9/?ref=app
+ 6
>>> Here's my try in Python :D
>>> https://code.sololearn.com/cWDJ0bOdR6on/#py
+ 5
A quick (though cramped) one-liner in Ruby:
https://code.sololearn.com/c1oWp4whRm6s/?ref=app
+ 5
one liner in python...
enter a string
https://code.sololearn.com/c9V8g03J4UQY/?ref=app
+ 4
Here's my C# implementation ✌
LINQ One-Liner〰
string.Join("-", str.Select(
(c, i) => c.ToString().ToUpper() +
new string(Enumerable.Repeat(c, i).ToArray())
))
https://code.sololearn.com/c04sO2WFk9M2/?ref=app
+ 4
Here you go. Ignores whitespace.
https://code.sololearn.com/cXbbu7L0jpCe/?ref=app