about | help | code help+videos | done | prefs |
Given an input String, return true if the String is made up of only the same character, repeated over and over. Return false if the input has any variety of characters. Precondition: str will have at least one character. HINT: This problem is a classic use case of what could be called the "assume, then disprove" type of problem. Many times in programming, an output checks for "at least one of" or "none of" something. A useful strategy in these cases is to assume the answer is that all the inputs will match a pattern the same way, with a boolean variable that can only change in one direction (true to false, or false to true) during the checking process.apcsaLoopsSameCharacter("aaa") → true apcsaLoopsSameCharacter("Aaa") → false apcsaLoopsSameCharacter("333333y3333") → false ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 210
Copyright Nick Parlante 2017 - privacy