(Challenge) Singlify Double Letters | SoloLearn: Learn to code for FREE!

+54

(Challenge) Singlify Double Letters

Here's an easy one. Take an input string and replace all double letters with single letters. E.g. Happy Mississippi! => Hapy Misisipi! The only tricky bit may be the shrinking length as letters are removed.

12/26/2017 4:17:07 AM

David Ashton

97 Answers

New Answer

+7

Closed-source-like JavaScript approach. I created both this code itself and the method to convert normal JavaScript source code to closed-source-like JS. I have a private code to automatically convert any JS source code to closed-source-like JS very easily, but it sould be difficult for other people to reverse the process :) This could be beneficial for companies who want to sell their apps or if the security of an app depends on it being closed source https://code.sololearn.com/WBWYRMIVmv2S/?ref=app

+44

https://code.sololearn.com/c8Rpw4gCF6hN/?ref=app

+22

I... I made a little something. :> https://code.sololearn.com/cQ8971friVmg/?ref=app

+20

https://code.sololearn.com/cmgkg7ysdogj/?ref=app

+19

Ok, got it. https://code.sololearn.com/cM6sEnKa3Emp/?ref=app

+19

I'm late, but it alright 😀 https://code.sololearn.com/cpmlzQHuw6qD/?ref=app

+18

My JavaScript one-liner https://code.sololearn.com/WvSeUwPZSZVH/?ref=app

+17

https://code.sololearn.com/cfmru654iTXS/?ref=app Simple and straightforward :)

+17

My apologies for not clarifying whether code-created double letters need to be reduced further (I didn't think about it because real words don't have triple and quadruple letters), but 'lasssso' becomes 'lasso' and no problem if your code takes it further to 'laso'. Thanks for all the great efforts!

+16

https://code.sololearn.com/c5aB8SBR2Y14/?ref=app

+16

Congratulations Sir Ashton for Moderator Badge!! and for 100 codes!

+16

I'm having an absolutely impossible time trying to choose a 'best answer' going through all these brilliant innovative clever creative demonstrations of thinking outside the box and learned a whole new bag of tricks in the process. But since it wouldn't be fair to just wander off without naming a winner, I'm going to choose Augustinas Lukauskas's simple but elegant JavaScript that actually works! https://code.sololearn.com/WBWYRMIVmv2S/?ref=app. (I would be pulling out my hair if I had any....) Congrats to everyone for a terrific job!

+15

My try.. https://code.sololearn.com/cXjo3PuWpkfm/?ref=app

+15

Here's mine by the way. Not nearly as elegant as many of the really clever solutions here! https://code.sololearn.com/cGF8xWbsutl0/?ref=app

+13

You can input string https://code.sololearn.com/cfMzkK5EdSBQ/?ref=app

+12

singlify=lambda c:c[0]+"".join(c[i] for i in range(1,len(c)) if c[i-1]!=c[i])

+12

Here's a one liner https://code.sololearn.com/c3Ywr609v43A/?ref=app

+12

Loved the challenge!! Here's mine in C https://code.sololearn.com/c2xKYMbanem6/?ref=app

+12

This code deletes repeated characters: https://code.sololearn.com/c8l5bioH78i7/?ref=app

+11

My try is in Java this time because many Python versions are here. Edit: I am adding Python. :) https://code.sololearn.com/c9Kiu73fUKWF/?ref=app https://code.sololearn.com/cUK7USFdGNv7/?ref=app