All problems
Soundex Code Generation
Problem
Soundex maps a name to its first letter plus digits for the consonant groups (BFPV=1, CGJKQSXZ=2, DT=3, L=4, MN=5, R=6), skipping vowels and H/W/Y, merging adjacent equal codes, and zero-padding to length four.
Given a name, return its four-character Soundex code.
Hint
Merge repeated codes and let H/W fail to reset the previous code.
Test cases
case 1
in: ["Robert"]
expected: "R163"
case 2
in: ["Rupert"]
expected: "R163"
case 3
in: ["Ashcraft"]
expected: "A261"
Starter codePython
def soundex_code_generation(name):
# Your code here
pass3 test cases · run your code against them in the editor