- A string containing printable ASCII (excluding spaces, tabs and new-lines)
- A boolean †
The parts of the String are divided into four groups:
- Lowercase letters
- Uppercase letters
Based on the boolean, we either output the highest occurrence of one (or multiple) of these four groups, or the lowest, replacing everything else with spaces.
- 3 uppercase letters:
- 6 lowercase letters:
- 0 digits
- 3 other:
These would be the outputs for
true: " ust est " // digits have the lowest occurrence (none), so everything is replaced with a space false: " "
(Note: You are allowed to ignore trailing spaces, so the outputs can also be
" ust est" and
- The input will never be empty or contain spaces, and will only consist of printable ASCII in the range
- You are allowed to take the input and/or outputs as character-array or list if you want to.
- † Any two consistent and distinct values for the boolean are allowed:
"lowest"; etc. Note that these distinct values should be used (somewhat) as a boolean! So it's not allowed to input two complete programs, one that gives the correct result for
trueand the other for
false, and then having your actual code only be
<run input with parameter>. Relevant new default loophole I've added, although it can still use a lot of finetuning regarding the definitions..
- If the occurrence of two or more groups is the same, we output all those occurrences.
- The necessary trailing spaces are optional, and a single trailing new-line is optional as well. Necessary leading spaces are mandatory. And any other leading spaces or new-lines aren't allowed.
- This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
- Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters, full programs. Your call.
- Default Loopholes are forbidden.
- If possible, please add a link with a test for your code.
- Also, please add an explanation if necessary.
Inputs: Output: "Just_A_Test!", true " ust est " (or " ust est") "Just_A_Test!", false " " (or "") "Aa1!Bb2@Cc3#Dd4$", either "Aa1!Bb2@Cc3#Dd4$" "H@$h!n9_!$_fun?", true " @$ ! _!$_ ?" "H@$h!n9_!$_fun?", false "H 9 " (or "H 9") "A", true "A" "A", false " " (or "") "H.ngm.n", true " ngm n" "H.ngm.n", false " " (or "") "H.ngm4n", false "H. 4 " (or "H. 4")