Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Sandbox

Post History

50%
+0 −0
Sandbox Mediocre pop count [FINALIZED]

posted 1y ago by trichoplax‭  ·  edited 1y ago by trichoplax‭

#6: Post edited by user avatar trichoplax‭ · 2022-10-09T19:24:45Z (over 1 year ago)
Mark as finalized
  • Mediocre pop count
  • Mediocre pop count [FINALIZED]
  • Given a sequence of letters, omit those with the highest or lowest pop count.
  • ## Terminology
  • The pop count or [population count] of a binary string is the number of `1`s in it.
  • For this challenge, the pop count of a letter is the number of `1`s in its ASCII character code in binary.
  • For example, the letter "Z" has ASCII character code 90, which is `1011010` in binary. There are 4 `1`s in this binary string, so the pop count of "Z" is 4.
  • Here is the pop count of every letter, in the format `letter : pop count`:
  • ```text
  • A : 2
  • B : 2
  • C : 3
  • D : 2
  • E : 3
  • F : 3
  • G : 4
  • H : 2
  • I : 3
  • J : 3
  • K : 4
  • L : 3
  • M : 4
  • N : 4
  • O : 5
  • P : 2
  • Q : 3
  • R : 3
  • S : 4
  • T : 3
  • U : 4
  • V : 4
  • W : 5
  • X : 3
  • Y : 4
  • Z : 4
  • a : 3
  • b : 3
  • c : 4
  • d : 3
  • e : 4
  • f : 4
  • g : 5
  • h : 3
  • i : 4
  • j : 4
  • k : 5
  • l : 4
  • m : 5
  • n : 5
  • o : 6
  • p : 3
  • q : 4
  • r : 4
  • s : 5
  • t : 4
  • u : 5
  • v : 5
  • w : 6
  • x : 4
  • y : 5
  • z : 5
  • ```
  • ## Input
  • - A sequence of letters
  • - This may be a string or any ordered data structure of characters
  • - The letters may contain a mixture of upper and lower case
  • - The characters that count as letters for this challenge are A-Z and a-z, specifically `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`
  • - The input may be empty (it may have length zero)
  • ## Output
  • - A sequence of letters
  • - This may be a string or any ordered data structure of characters. It does not need to match the input format (provided it is consistent between inputs)
  • - For example, you may take input as an array of characters, and output as a string, provided this does not change for different inputs
  • - All of the letters from the input are included in the output in the same order, except for those with the highest or lowest pop count, which are omitted
  • - If all of the letters have either the highest or lowest pop count, the output is empty (a sequence of length zero)
  • - Case must be maintained
  • - a letter that is lower case in the input must be lower case in the output (if present)
  • - a letter that is upper case in the input must be upper case in the output (if present)
  • ## Test cases
  • Test cases are in the format `"input" : "output"`
  • ```text
  • "" : ""
  • "a" : ""
  • "ab" : ""
  • "abc" : ""
  • "abcd" : ""
  • "abcde" : ""
  • "abcdef" : ""
  • "abcdefg" : "cef"
  • "A" : ""
  • "AB" : ""
  • "ABC" : ""
  • "ABCD" : ""
  • "ABCDE" : ""
  • "ABCDEF" : ""
  • "ABCDEFG" : "CEF"
  • "oAPwSoeHcoDretMBBoesoBsagHDoew" : "SecretMessage"
  • "SecretMessage" : "SecretMee"
  • ```
  • > Explanations are optional, but I'm more likely to upvote answers that have one.
  • [population count]: https://en.wikipedia.org/wiki/Hamming_weight "Wikipedia page for 'Hamming weight' - a generalisation of pop count"
  • # Now posted: [Mediocre pop count](https://codegolf.codidact.com/posts/287199)
  • ---
  • Given a sequence of letters, omit those with the highest or lowest pop count.
  • ## Terminology
  • The pop count or [population count] of a binary string is the number of `1`s in it.
  • For this challenge, the pop count of a letter is the number of `1`s in its ASCII character code in binary.
  • For example, the letter "Z" has ASCII character code 90, which is `1011010` in binary. There are 4 `1`s in this binary string, so the pop count of "Z" is 4.
  • Here is the pop count of every letter, in the format `letter : pop count`:
  • ```text
  • A : 2
  • B : 2
  • C : 3
  • D : 2
  • E : 3
  • F : 3
  • G : 4
  • H : 2
  • I : 3
  • J : 3
  • K : 4
  • L : 3
  • M : 4
  • N : 4
  • O : 5
  • P : 2
  • Q : 3
  • R : 3
  • S : 4
  • T : 3
  • U : 4
  • V : 4
  • W : 5
  • X : 3
  • Y : 4
  • Z : 4
  • a : 3
  • b : 3
  • c : 4
  • d : 3
  • e : 4
  • f : 4
  • g : 5
  • h : 3
  • i : 4
  • j : 4
  • k : 5
  • l : 4
  • m : 5
  • n : 5
  • o : 6
  • p : 3
  • q : 4
  • r : 4
  • s : 5
  • t : 4
  • u : 5
  • v : 5
  • w : 6
  • x : 4
  • y : 5
  • z : 5
  • ```
  • ## Input
  • - A sequence of letters
  • - This may be a string or any ordered data structure of characters
  • - The letters may contain a mixture of upper and lower case
  • - The characters that count as letters for this challenge are A-Z and a-z, specifically `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`
  • - The input may be empty (it may have length zero)
  • ## Output
  • - A sequence of letters
  • - This may be a string or any ordered data structure of characters. It does not need to match the input format (provided it is consistent between inputs)
  • - For example, you may take input as an array of characters, and output as a string, provided this does not change for different inputs
  • - All of the letters from the input are included in the output in the same order, except for those with the highest or lowest pop count, which are omitted
  • - If all of the letters have either the highest or lowest pop count, the output is empty (a sequence of length zero)
  • - Case must be maintained
  • - a letter that is lower case in the input must be lower case in the output (if present)
  • - a letter that is upper case in the input must be upper case in the output (if present)
  • ## Test cases
  • Test cases are in the format `"input" : "output"`
  • ```text
  • "" : ""
  • "a" : ""
  • "ab" : ""
  • "abc" : ""
  • "abcd" : ""
  • "abcde" : ""
  • "abcdef" : ""
  • "abcdefg" : "cef"
  • "A" : ""
  • "AB" : ""
  • "ABC" : ""
  • "ABCD" : ""
  • "ABCDE" : ""
  • "ABCDEF" : ""
  • "ABCDEFG" : "CEF"
  • "oAPwSoeHcoDretMBBoesoBsagHDoew" : "SecretMessage"
  • "SecretMessage" : "SecretMee"
  • ```
  • > Explanations are optional, but I'm more likely to upvote answers that have one.
  • [population count]: https://en.wikipedia.org/wiki/Hamming_weight "Wikipedia page for 'Hamming weight' - a generalisation of pop count"
#5: Post edited by user avatar trichoplax‭ · 2022-10-09T19:21:29Z (over 1 year ago)
Reformat output section
  • Given a sequence of letters, omit those with the highest or lowest pop count.
  • ## Terminology
  • The pop count or [population count] of a binary string is the number of `1`s in it.
  • For this challenge, the pop count of a letter is the number of `1`s in its ASCII character code in binary.
  • For example, the letter "Z" has ASCII character code 90, which is `1011010` in binary. There are 4 `1`s in this binary string, so the pop count of "Z" is 4.
  • Here is the pop count of every letter, in the format `letter : pop count`:
  • ```text
  • A : 2
  • B : 2
  • C : 3
  • D : 2
  • E : 3
  • F : 3
  • G : 4
  • H : 2
  • I : 3
  • J : 3
  • K : 4
  • L : 3
  • M : 4
  • N : 4
  • O : 5
  • P : 2
  • Q : 3
  • R : 3
  • S : 4
  • T : 3
  • U : 4
  • V : 4
  • W : 5
  • X : 3
  • Y : 4
  • Z : 4
  • a : 3
  • b : 3
  • c : 4
  • d : 3
  • e : 4
  • f : 4
  • g : 5
  • h : 3
  • i : 4
  • j : 4
  • k : 5
  • l : 4
  • m : 5
  • n : 5
  • o : 6
  • p : 3
  • q : 4
  • r : 4
  • s : 5
  • t : 4
  • u : 5
  • v : 5
  • w : 6
  • x : 4
  • y : 5
  • z : 5
  • ```
  • ## Input
  • - A sequence of letters
  • - This may be a string or any ordered data structure of characters
  • - The letters may contain a mixture of upper and lower case
  • - The characters that count as letters for this challenge are A-Z and a-z, specifically `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`
  • - The input may be empty (it may have length zero)
  • ## Output
  • - A sequence of letters
  • - This may be a string or any ordered data structure of characters. It does not need to match the input format (provided it is consistent between inputs)
  • - For example, you may take input as an array of characters, and output as a string, provided this does not change for different inputs
  • - All of the letters from the input are included in the output in the same order, except for those with the highest or lowest pop count, which are omitted
  • - If all of the letters have either the highest or lowest pop count, the output is empty (a sequence of length zero)
  • - Case must be maintained - a letter that is lower case in the input must be lower case in the output (if present), and a letter that is upper case in the input must be upper case in the output (if present)
  • ## Test cases
  • Test cases are in the format `"input" : "output"`
  • ```text
  • "" : ""
  • "a" : ""
  • "ab" : ""
  • "abc" : ""
  • "abcd" : ""
  • "abcde" : ""
  • "abcdef" : ""
  • "abcdefg" : "cef"
  • "A" : ""
  • "AB" : ""
  • "ABC" : ""
  • "ABCD" : ""
  • "ABCDE" : ""
  • "ABCDEF" : ""
  • "ABCDEFG" : "CEF"
  • "oAPwSoeHcoDretMBBoesoBsagHDoew" : "SecretMessage"
  • "SecretMessage" : "SecretMee"
  • ```
  • > Explanations are optional, but I'm more likely to upvote answers that have one.
  • [population count]: https://en.wikipedia.org/wiki/Hamming_weight "Wikipedia page for 'Hamming weight' - a generalisation of pop count"
  • Given a sequence of letters, omit those with the highest or lowest pop count.
  • ## Terminology
  • The pop count or [population count] of a binary string is the number of `1`s in it.
  • For this challenge, the pop count of a letter is the number of `1`s in its ASCII character code in binary.
  • For example, the letter "Z" has ASCII character code 90, which is `1011010` in binary. There are 4 `1`s in this binary string, so the pop count of "Z" is 4.
  • Here is the pop count of every letter, in the format `letter : pop count`:
  • ```text
  • A : 2
  • B : 2
  • C : 3
  • D : 2
  • E : 3
  • F : 3
  • G : 4
  • H : 2
  • I : 3
  • J : 3
  • K : 4
  • L : 3
  • M : 4
  • N : 4
  • O : 5
  • P : 2
  • Q : 3
  • R : 3
  • S : 4
  • T : 3
  • U : 4
  • V : 4
  • W : 5
  • X : 3
  • Y : 4
  • Z : 4
  • a : 3
  • b : 3
  • c : 4
  • d : 3
  • e : 4
  • f : 4
  • g : 5
  • h : 3
  • i : 4
  • j : 4
  • k : 5
  • l : 4
  • m : 5
  • n : 5
  • o : 6
  • p : 3
  • q : 4
  • r : 4
  • s : 5
  • t : 4
  • u : 5
  • v : 5
  • w : 6
  • x : 4
  • y : 5
  • z : 5
  • ```
  • ## Input
  • - A sequence of letters
  • - This may be a string or any ordered data structure of characters
  • - The letters may contain a mixture of upper and lower case
  • - The characters that count as letters for this challenge are A-Z and a-z, specifically `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`
  • - The input may be empty (it may have length zero)
  • ## Output
  • - A sequence of letters
  • - This may be a string or any ordered data structure of characters. It does not need to match the input format (provided it is consistent between inputs)
  • - For example, you may take input as an array of characters, and output as a string, provided this does not change for different inputs
  • - All of the letters from the input are included in the output in the same order, except for those with the highest or lowest pop count, which are omitted
  • - If all of the letters have either the highest or lowest pop count, the output is empty (a sequence of length zero)
  • - Case must be maintained
  • - a letter that is lower case in the input must be lower case in the output (if present)
  • - a letter that is upper case in the input must be upper case in the output (if present)
  • ## Test cases
  • Test cases are in the format `"input" : "output"`
  • ```text
  • "" : ""
  • "a" : ""
  • "ab" : ""
  • "abc" : ""
  • "abcd" : ""
  • "abcde" : ""
  • "abcdef" : ""
  • "abcdefg" : "cef"
  • "A" : ""
  • "AB" : ""
  • "ABC" : ""
  • "ABCD" : ""
  • "ABCDE" : ""
  • "ABCDEF" : ""
  • "ABCDEFG" : "CEF"
  • "oAPwSoeHcoDretMBBoesoBsagHDoew" : "SecretMessage"
  • "SecretMessage" : "SecretMee"
  • ```
  • > Explanations are optional, but I'm more likely to upvote answers that have one.
  • [population count]: https://en.wikipedia.org/wiki/Hamming_weight "Wikipedia page for 'Hamming weight' - a generalisation of pop count"
#4: Post edited by user avatar trichoplax‭ · 2022-10-09T18:38:50Z (over 1 year ago)
Explicitly allow input and output to be in different formats
  • Given a sequence of letters, omit those with the highest or lowest pop count.
  • ## Terminology
  • The pop count or [population count] of a binary string is the number of `1`s in it.
  • For this challenge, the pop count of a letter is the number of `1`s in its ASCII character code in binary.
  • For example, the letter "Z" has ASCII character code 90, which is `1011010` in binary. There are 4 `1`s in this binary string, so the pop count of "Z" is 4.
  • Here is the pop count of every letter, in the format `letter : pop count`:
  • ```text
  • A : 2
  • B : 2
  • C : 3
  • D : 2
  • E : 3
  • F : 3
  • G : 4
  • H : 2
  • I : 3
  • J : 3
  • K : 4
  • L : 3
  • M : 4
  • N : 4
  • O : 5
  • P : 2
  • Q : 3
  • R : 3
  • S : 4
  • T : 3
  • U : 4
  • V : 4
  • W : 5
  • X : 3
  • Y : 4
  • Z : 4
  • a : 3
  • b : 3
  • c : 4
  • d : 3
  • e : 4
  • f : 4
  • g : 5
  • h : 3
  • i : 4
  • j : 4
  • k : 5
  • l : 4
  • m : 5
  • n : 5
  • o : 6
  • p : 3
  • q : 4
  • r : 4
  • s : 5
  • t : 4
  • u : 5
  • v : 5
  • w : 6
  • x : 4
  • y : 5
  • z : 5
  • ```
  • ## Input
  • - A sequence of letters
  • - This may be a string or any ordered data structure of characters
  • - The letters may contain a mixture of upper and lower case
  • - The characters that count as letters for this challenge are A-Z and a-z, specifically `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`
  • - The input may be empty (it may have length zero)
  • ## Output
  • - A sequence of letters
  • - This may be a string or any ordered data structure of characters
  • - All of the letters from the input are included in the output in the same order, except for those with the highest or lowest pop count, which are omitted
  • - If all of the letters have either the highest or lowest pop count, the output is empty (a sequence of length zero)
  • - Case must be maintained - a letter that is lower case in the input must be lower case in the output (if present), and a letter that is upper case in the input must be upper case in the output (if present)
  • ## Test cases
  • Test cases are in the format `"input" : "output"`
  • ```text
  • "" : ""
  • "a" : ""
  • "ab" : ""
  • "abc" : ""
  • "abcd" : ""
  • "abcde" : ""
  • "abcdef" : ""
  • "abcdefg" : "cef"
  • "A" : ""
  • "AB" : ""
  • "ABC" : ""
  • "ABCD" : ""
  • "ABCDE" : ""
  • "ABCDEF" : ""
  • "ABCDEFG" : "CEF"
  • "oAPwSoeHcoDretMBBoesoBsagHDoew" : "SecretMessage"
  • "SecretMessage" : "SecretMee"
  • ```
  • > Explanations are optional, but I'm more likely to upvote answers that have one.
  • [population count]: https://en.wikipedia.org/wiki/Hamming_weight "Wikipedia page for 'Hamming weight' - a generalisation of pop count"
  • Given a sequence of letters, omit those with the highest or lowest pop count.
  • ## Terminology
  • The pop count or [population count] of a binary string is the number of `1`s in it.
  • For this challenge, the pop count of a letter is the number of `1`s in its ASCII character code in binary.
  • For example, the letter "Z" has ASCII character code 90, which is `1011010` in binary. There are 4 `1`s in this binary string, so the pop count of "Z" is 4.
  • Here is the pop count of every letter, in the format `letter : pop count`:
  • ```text
  • A : 2
  • B : 2
  • C : 3
  • D : 2
  • E : 3
  • F : 3
  • G : 4
  • H : 2
  • I : 3
  • J : 3
  • K : 4
  • L : 3
  • M : 4
  • N : 4
  • O : 5
  • P : 2
  • Q : 3
  • R : 3
  • S : 4
  • T : 3
  • U : 4
  • V : 4
  • W : 5
  • X : 3
  • Y : 4
  • Z : 4
  • a : 3
  • b : 3
  • c : 4
  • d : 3
  • e : 4
  • f : 4
  • g : 5
  • h : 3
  • i : 4
  • j : 4
  • k : 5
  • l : 4
  • m : 5
  • n : 5
  • o : 6
  • p : 3
  • q : 4
  • r : 4
  • s : 5
  • t : 4
  • u : 5
  • v : 5
  • w : 6
  • x : 4
  • y : 5
  • z : 5
  • ```
  • ## Input
  • - A sequence of letters
  • - This may be a string or any ordered data structure of characters
  • - The letters may contain a mixture of upper and lower case
  • - The characters that count as letters for this challenge are A-Z and a-z, specifically `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`
  • - The input may be empty (it may have length zero)
  • ## Output
  • - A sequence of letters
  • - This may be a string or any ordered data structure of characters. It does not need to match the input format (provided it is consistent between inputs)
  • - For example, you may take input as an array of characters, and output as a string, provided this does not change for different inputs
  • - All of the letters from the input are included in the output in the same order, except for those with the highest or lowest pop count, which are omitted
  • - If all of the letters have either the highest or lowest pop count, the output is empty (a sequence of length zero)
  • - Case must be maintained - a letter that is lower case in the input must be lower case in the output (if present), and a letter that is upper case in the input must be upper case in the output (if present)
  • ## Test cases
  • Test cases are in the format `"input" : "output"`
  • ```text
  • "" : ""
  • "a" : ""
  • "ab" : ""
  • "abc" : ""
  • "abcd" : ""
  • "abcde" : ""
  • "abcdef" : ""
  • "abcdefg" : "cef"
  • "A" : ""
  • "AB" : ""
  • "ABC" : ""
  • "ABCD" : ""
  • "ABCDE" : ""
  • "ABCDEF" : ""
  • "ABCDEFG" : "CEF"
  • "oAPwSoeHcoDretMBBoesoBsagHDoew" : "SecretMessage"
  • "SecretMessage" : "SecretMee"
  • ```
  • > Explanations are optional, but I'm more likely to upvote answers that have one.
  • [population count]: https://en.wikipedia.org/wiki/Hamming_weight "Wikipedia page for 'Hamming weight' - a generalisation of pop count"
#3: Post edited by user avatar trichoplax‭ · 2022-10-08T10:01:58Z (over 1 year ago)
Clarify output section
  • Given a sequence of letters, omit those with the highest or lowest pop count.
  • ## Terminology
  • The pop count or [population count] of a binary string is the number of `1`s in it.
  • For this challenge, the pop count of a letter is the number of `1`s in its ASCII character code in binary.
  • For example, the letter "Z" has ASCII character code 90, which is `1011010` in binary. There are 4 `1`s in this binary string, so the pop count of "Z" is 4.
  • Here is the pop count of every letter, in the format `letter : pop count`:
  • ```text
  • A : 2
  • B : 2
  • C : 3
  • D : 2
  • E : 3
  • F : 3
  • G : 4
  • H : 2
  • I : 3
  • J : 3
  • K : 4
  • L : 3
  • M : 4
  • N : 4
  • O : 5
  • P : 2
  • Q : 3
  • R : 3
  • S : 4
  • T : 3
  • U : 4
  • V : 4
  • W : 5
  • X : 3
  • Y : 4
  • Z : 4
  • a : 3
  • b : 3
  • c : 4
  • d : 3
  • e : 4
  • f : 4
  • g : 5
  • h : 3
  • i : 4
  • j : 4
  • k : 5
  • l : 4
  • m : 5
  • n : 5
  • o : 6
  • p : 3
  • q : 4
  • r : 4
  • s : 5
  • t : 4
  • u : 5
  • v : 5
  • w : 6
  • x : 4
  • y : 5
  • z : 5
  • ```
  • ## Input
  • - A sequence of letters
  • - This may be a string or any ordered data structure of characters
  • - The letters may contain a mixture of upper and lower case
  • - The characters that count as letters for this challenge are A-Z and a-z, specifically `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`
  • - The input may be empty (it may have length zero)
  • ## Output
  • - A sequence of zero or more letters
  • - All of the letters from the input are included in the output in the same order, except for those with the highest or lowest pop count, which are omitted
  • - If all of the letters have either the highest or lowest pop count, the output is empty (a sequence of length zero)
  • - Case must be maintained - a letter that is lower case in the input must be lower case in the output (if present), and a letter that is upper case in the input must be upper case in the output (if present)
  • ## Test cases
  • Test cases are in the format `"input" : "output"`
  • ```text
  • "" : ""
  • "a" : ""
  • "ab" : ""
  • "abc" : ""
  • "abcd" : ""
  • "abcde" : ""
  • "abcdef" : ""
  • "abcdefg" : "cef"
  • "A" : ""
  • "AB" : ""
  • "ABC" : ""
  • "ABCD" : ""
  • "ABCDE" : ""
  • "ABCDEF" : ""
  • "ABCDEFG" : "CEF"
  • "oAPwSoeHcoDretMBBoesoBsagHDoew" : "SecretMessage"
  • "SecretMessage" : "SecretMee"
  • ```
  • > Explanations in answers are optional, but I'm more likely to upvote answers that have one.
  • [population count]: https://en.wikipedia.org/wiki/Hamming_weight "Wikipedia page for 'Hamming weight' - a generalisation of pop count"
  • Given a sequence of letters, omit those with the highest or lowest pop count.
  • ## Terminology
  • The pop count or [population count] of a binary string is the number of `1`s in it.
  • For this challenge, the pop count of a letter is the number of `1`s in its ASCII character code in binary.
  • For example, the letter "Z" has ASCII character code 90, which is `1011010` in binary. There are 4 `1`s in this binary string, so the pop count of "Z" is 4.
  • Here is the pop count of every letter, in the format `letter : pop count`:
  • ```text
  • A : 2
  • B : 2
  • C : 3
  • D : 2
  • E : 3
  • F : 3
  • G : 4
  • H : 2
  • I : 3
  • J : 3
  • K : 4
  • L : 3
  • M : 4
  • N : 4
  • O : 5
  • P : 2
  • Q : 3
  • R : 3
  • S : 4
  • T : 3
  • U : 4
  • V : 4
  • W : 5
  • X : 3
  • Y : 4
  • Z : 4
  • a : 3
  • b : 3
  • c : 4
  • d : 3
  • e : 4
  • f : 4
  • g : 5
  • h : 3
  • i : 4
  • j : 4
  • k : 5
  • l : 4
  • m : 5
  • n : 5
  • o : 6
  • p : 3
  • q : 4
  • r : 4
  • s : 5
  • t : 4
  • u : 5
  • v : 5
  • w : 6
  • x : 4
  • y : 5
  • z : 5
  • ```
  • ## Input
  • - A sequence of letters
  • - This may be a string or any ordered data structure of characters
  • - The letters may contain a mixture of upper and lower case
  • - The characters that count as letters for this challenge are A-Z and a-z, specifically `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`
  • - The input may be empty (it may have length zero)
  • ## Output
  • - A sequence of letters
  • - This may be a string or any ordered data structure of characters
  • - All of the letters from the input are included in the output in the same order, except for those with the highest or lowest pop count, which are omitted
  • - If all of the letters have either the highest or lowest pop count, the output is empty (a sequence of length zero)
  • - Case must be maintained - a letter that is lower case in the input must be lower case in the output (if present), and a letter that is upper case in the input must be upper case in the output (if present)
  • ## Test cases
  • Test cases are in the format `"input" : "output"`
  • ```text
  • "" : ""
  • "a" : ""
  • "ab" : ""
  • "abc" : ""
  • "abcd" : ""
  • "abcde" : ""
  • "abcdef" : ""
  • "abcdefg" : "cef"
  • "A" : ""
  • "AB" : ""
  • "ABC" : ""
  • "ABCD" : ""
  • "ABCDE" : ""
  • "ABCDEF" : ""
  • "ABCDEFG" : "CEF"
  • "oAPwSoeHcoDretMBBoesoBsagHDoew" : "SecretMessage"
  • "SecretMessage" : "SecretMee"
  • ```
  • > Explanations are optional, but I'm more likely to upvote answers that have one.
  • [population count]: https://en.wikipedia.org/wiki/Hamming_weight "Wikipedia page for 'Hamming weight' - a generalisation of pop count"
#2: Post edited by user avatar trichoplax‭ · 2022-10-06T01:41:22Z (over 1 year ago)
Make formatting of binary digits consistent
  • Given a sequence of letters, omit those with the highest or lowest pop count.
  • ## Terminology
  • The pop count or [population count] of a binary string is the number of `1`s in it.
  • For this challenge, the pop count of a letter is the number of `1`s in its ASCII character code in binary.
  • For example, the letter "Z" has ASCII character code 90, which is `1011010` in binary. There are 4 1s in this binary string, so the pop count of "Z" is 4.
  • Here is the pop count of every letter, in the format `letter : pop count`:
  • ```text
  • A : 2
  • B : 2
  • C : 3
  • D : 2
  • E : 3
  • F : 3
  • G : 4
  • H : 2
  • I : 3
  • J : 3
  • K : 4
  • L : 3
  • M : 4
  • N : 4
  • O : 5
  • P : 2
  • Q : 3
  • R : 3
  • S : 4
  • T : 3
  • U : 4
  • V : 4
  • W : 5
  • X : 3
  • Y : 4
  • Z : 4
  • a : 3
  • b : 3
  • c : 4
  • d : 3
  • e : 4
  • f : 4
  • g : 5
  • h : 3
  • i : 4
  • j : 4
  • k : 5
  • l : 4
  • m : 5
  • n : 5
  • o : 6
  • p : 3
  • q : 4
  • r : 4
  • s : 5
  • t : 4
  • u : 5
  • v : 5
  • w : 6
  • x : 4
  • y : 5
  • z : 5
  • ```
  • ## Input
  • - A sequence of letters
  • - This may be a string or any ordered data structure of characters
  • - The letters may contain a mixture of upper and lower case
  • - The characters that count as letters for this challenge are A-Z and a-z, specifically `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`
  • - The input may be empty (it may have length zero)
  • ## Output
  • - A sequence of zero or more letters
  • - All of the letters from the input are included in the output in the same order, except for those with the highest or lowest pop count, which are omitted
  • - If all of the letters have either the highest or lowest pop count, the output is empty (a sequence of length zero)
  • - Case must be maintained - a letter that is lower case in the input must be lower case in the output (if present), and a letter that is upper case in the input must be upper case in the output (if present)
  • ## Test cases
  • Test cases are in the format `"input" : "output"`
  • ```text
  • "" : ""
  • "a" : ""
  • "ab" : ""
  • "abc" : ""
  • "abcd" : ""
  • "abcde" : ""
  • "abcdef" : ""
  • "abcdefg" : "cef"
  • "A" : ""
  • "AB" : ""
  • "ABC" : ""
  • "ABCD" : ""
  • "ABCDE" : ""
  • "ABCDEF" : ""
  • "ABCDEFG" : "CEF"
  • "oAPwSoeHcoDretMBBoesoBsagHDoew" : "SecretMessage"
  • "SecretMessage" : "SecretMee"
  • ```
  • > Explanations in answers are optional, but I'm more likely to upvote answers that have one.
  • [population count]: https://en.wikipedia.org/wiki/Hamming_weight "Wikipedia page for 'Hamming weight' - a generalisation of pop count"
  • Given a sequence of letters, omit those with the highest or lowest pop count.
  • ## Terminology
  • The pop count or [population count] of a binary string is the number of `1`s in it.
  • For this challenge, the pop count of a letter is the number of `1`s in its ASCII character code in binary.
  • For example, the letter "Z" has ASCII character code 90, which is `1011010` in binary. There are 4 `1`s in this binary string, so the pop count of "Z" is 4.
  • Here is the pop count of every letter, in the format `letter : pop count`:
  • ```text
  • A : 2
  • B : 2
  • C : 3
  • D : 2
  • E : 3
  • F : 3
  • G : 4
  • H : 2
  • I : 3
  • J : 3
  • K : 4
  • L : 3
  • M : 4
  • N : 4
  • O : 5
  • P : 2
  • Q : 3
  • R : 3
  • S : 4
  • T : 3
  • U : 4
  • V : 4
  • W : 5
  • X : 3
  • Y : 4
  • Z : 4
  • a : 3
  • b : 3
  • c : 4
  • d : 3
  • e : 4
  • f : 4
  • g : 5
  • h : 3
  • i : 4
  • j : 4
  • k : 5
  • l : 4
  • m : 5
  • n : 5
  • o : 6
  • p : 3
  • q : 4
  • r : 4
  • s : 5
  • t : 4
  • u : 5
  • v : 5
  • w : 6
  • x : 4
  • y : 5
  • z : 5
  • ```
  • ## Input
  • - A sequence of letters
  • - This may be a string or any ordered data structure of characters
  • - The letters may contain a mixture of upper and lower case
  • - The characters that count as letters for this challenge are A-Z and a-z, specifically `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`
  • - The input may be empty (it may have length zero)
  • ## Output
  • - A sequence of zero or more letters
  • - All of the letters from the input are included in the output in the same order, except for those with the highest or lowest pop count, which are omitted
  • - If all of the letters have either the highest or lowest pop count, the output is empty (a sequence of length zero)
  • - Case must be maintained - a letter that is lower case in the input must be lower case in the output (if present), and a letter that is upper case in the input must be upper case in the output (if present)
  • ## Test cases
  • Test cases are in the format `"input" : "output"`
  • ```text
  • "" : ""
  • "a" : ""
  • "ab" : ""
  • "abc" : ""
  • "abcd" : ""
  • "abcde" : ""
  • "abcdef" : ""
  • "abcdefg" : "cef"
  • "A" : ""
  • "AB" : ""
  • "ABC" : ""
  • "ABCD" : ""
  • "ABCDE" : ""
  • "ABCDEF" : ""
  • "ABCDEFG" : "CEF"
  • "oAPwSoeHcoDretMBBoesoBsagHDoew" : "SecretMessage"
  • "SecretMessage" : "SecretMee"
  • ```
  • > Explanations in answers are optional, but I'm more likely to upvote answers that have one.
  • [population count]: https://en.wikipedia.org/wiki/Hamming_weight "Wikipedia page for 'Hamming weight' - a generalisation of pop count"
#1: Initial revision by user avatar trichoplax‭ · 2022-10-06T01:39:54Z (over 1 year ago)
Mediocre pop count
Given a sequence of letters, omit those with the highest or lowest pop count.

## Terminology
The pop count or [population count] of a binary string is the number of `1`s in it.

For this challenge, the pop count of a letter is the number of `1`s in its ASCII character code in binary.

For example, the letter "Z" has ASCII character code 90, which is `1011010` in binary. There are 4 1s in this binary string, so the pop count of "Z" is 4.

Here is the pop count of every letter, in the format `letter : pop count`:

```text
A : 2
B : 2
C : 3
D : 2
E : 3
F : 3
G : 4
H : 2
I : 3
J : 3
K : 4
L : 3
M : 4
N : 4
O : 5
P : 2
Q : 3
R : 3
S : 4
T : 3
U : 4
V : 4
W : 5
X : 3
Y : 4
Z : 4
a : 3
b : 3
c : 4
d : 3
e : 4
f : 4
g : 5
h : 3
i : 4
j : 4
k : 5
l : 4
m : 5
n : 5
o : 6
p : 3
q : 4
r : 4
s : 5
t : 4
u : 5
v : 5
w : 6
x : 4
y : 5
z : 5
```
## Input
- A sequence of letters
- This may be a string or any ordered data structure of characters
- The letters may contain a mixture of upper and lower case
- The characters that count as letters for this challenge are A-Z and a-z, specifically `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`
- The input may be empty (it may have length zero)

## Output
- A sequence of zero or more letters
- All of the letters from the input are included in the output in the same order, except for those with the highest or lowest pop count, which are omitted
- If all of the letters have either the highest or lowest pop count, the output is empty (a sequence of length zero)
- Case must be maintained - a letter that is lower case in the input must be lower case in the output (if present), and a letter that is upper case in the input must be upper case in the output (if present)

## Test cases
Test cases are in the format `"input" : "output"`

```text
"" : ""
"a" : ""
"ab" : ""
"abc" : ""
"abcd" : ""
"abcde" : ""
"abcdef" : ""
"abcdefg" : "cef"
"A" : ""
"AB" : ""
"ABC" : ""
"ABCD" : ""
"ABCDE" : ""
"ABCDEF" : ""
"ABCDEFG" : "CEF"
"oAPwSoeHcoDretMBBoesoBsagHDoew" : "SecretMessage"
"SecretMessage" : "SecretMee"
```

> Explanations in answers are optional, but I'm more likely to upvote answers that have one.



[population count]: https://en.wikipedia.org/wiki/Hamming_weight "Wikipedia page for 'Hamming weight' - a generalisation of pop count"