An Interest In:
Web News this Week
- April 1, 2024
- March 31, 2024
- March 30, 2024
- March 29, 2024
- March 28, 2024
- March 27, 2024
- March 26, 2024
Daily Challenge 244 - Search for Letters
Create a function which accepts one arbitrary string as an argument, and return a string of length 26. The objective is to set each of the 26 characters of the output string to either '1' or '0' based on the fact whether the Nth letter of the alphabet is present in the input (independent of its case).
So if an 'a' or an 'A' appears anywhere in the input string (any number of times), set the first character of the output string to '1', otherwise to '0'. if 'b' or 'B' appears in the string, set the second character to '1', and so on for the rest of the alphabet.
For instance:"a **& cZ"
=> "10100000000000000000000001"
'Abc e $$ z'
=> "11101000000000000000000001"
Tests
change("!!a$%&RgTT")
change("")
change("abcdefghijklmnopqrstuvwxyz")
change("aaaaaaaaaaa")
Good luck!
This challenge comes from Roy Gardiner on CodeWars. Thank you to CodeWars, who has licensed redistribution of this challenge under the 2-Clause BSD License!
Want to propose a challenge idea for a future post? Email [email protected] with your suggestions!
Original Link: https://dev.to/thepracticaldev/daily-challenge-244-search-for-letters-2h4b
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To