Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Varun Dixit
151 PointsCan anyone solve this! man this is very hard to me all PRO-grammers its a challenge!!!!
Craig Dennis please help me sir... Write a program to do basic string compression. For a character which is repeated more than once, replace consecutive duplicate occurrences with the count of repetitions e.g. if a String has 'x' repeated 5 times, replace this "xxxxx" with "x5".
1 Answer
Craig Dennis
Treehouse TeacherI'll give you some pseudo code....
Create a new string var
Create a previous character var
Create counter var
Loop through each character in original string
Is current char equal to previous?
Increment counter
Otherwise
Write letter
Is counter greater than one?
Write counter
Reset counter
Varun Dixit
151 PointsVarun Dixit
151 PointsCraig Dennis sir can you please tell what is wrong in my logic that i build in more than 6hr i'm really feeling very bad about me :(