+ 30
CHALLENGE: Split string when character changes
Level : easy Task: 🆎➡️🅰️🅱️ Split a given string when character changes. 🚫 without built functions (as split or regex or pattern...). ✔️Note: the given string can contain all type of characters (alphanumeric, special symbols, spaces) Example: Input: AaaabbbbYY@---..aaaa 555%%%%(((f))) Output: A aaa bbbb YY @ --- .. aaaa 555 %%%% ((( f ))) https://code.sololearn.com/cy0Eh3MfJ3RE
24 odpowiedzi
+ 7
One-liner in Ruby:
puts gets.chomp.chars.chunk(&:itself).flat_map { |x| x[1].join }
I am a fan of Simon's response's elegance and speed, though.
https://code.sololearn.com/cXUMnSG0WSXi/?ref=app
+ 17
My try using C++:
https://code.sololearn.com/c2lF149jCF0b/?ref=app
+ 15
@Louis
Thank you for having noticed it 😉
When checking on Q/A I used the word "split" but not "cut"
+ 12
Here's my code 👇
https://code.sololearn.com/c66ba6px3ChG/?ref=app
+ 11
+ 11
https://code.sololearn.com/ca9MGjnl5EpA/?ref=app
+ 10
I'm so late to this, oh well, here's my attempt on the challenge ; )
Thanks @LukArToDo,
https://code.sololearn.com/ck0pTecQ8NEL/?ref=app
+ 9
My try.. OOP style..
Enter a line, press↩ and enter a number(optional).
For a default case type nothing.
https://code.sololearn.com/cnhMnDSB5x85/?ref=app
+ 8
My try (C++)
https://code.sololearn.com/csC0Ss90Cat0/?ref=app
+ 7
Here's my solution
https://code.sololearn.com/ccJvelxGTSxj/?ref=app
+ 7
my try!!
this is the funniest code i have ever made!!
great challenge!!!
https://code.sololearn.com/cR0oLkUCwnqq/?ref=app
+ 6
https://code.sololearn.com/WogbyhVCm145/?ref=app
+ 5
https://code.sololearn.com/cV3Zkv6GUD0H/?ref=app
+ 5
This is my take on splitting a string.
https://code.sololearn.com/cK0VH98iP9w9/?ref=app
+ 5
Split string when character changes in js.
https://code.sololearn.com/W2mUpwCpqI5p/?ref=app