Interview Question
Country: United States
mapping = { "p" : [ "$", "P" ],
"a" : [ "A" ],
"s" : [ "/" ,"S" , "&" ] }
def solutions(word, mapping){
arg = list( word.value ) -> { mapping[str($.o)] }
join(@ARGS=arg) -> { str($.o,'') }
}
println( solutions('pass', mapping) )
and the result:
careercup git:(master) ✗ zmb tmp.zm
[ $A//,$A/S,$A/&,$AS/,$ASS,$AS&,$A&/,$A&S,$A&&,PA//,PA/S,PA/&,PAS/,PASS,PAS&,PA&/,PA&S,PA&& ]
➜ careercup git:(master) ✗
Here is a working solution in python
- Fernando May 17, 2017