maketrans2 1225. Switcheroo Given a string made up of letters a, b, and/or c, switch the position of letters a and b (change a to b and vice versa). Leave any incidence of c untouched. Example: 'acb' --> 'bca' 'aabacbaa' --> 'bbabcabb' Solution: def switcheroo(s): return s.translate(str.maketrans("ab", "ba")) def switcheroo(s): return s.translate({ord('a'): 'b', ord('b'): 'a'}) 2022. 12. 25. Complementary DNA Description: Deoxyribonucleic acid (DNA) is a chemical found in the nucleus of cells and carries the "instructions" for the development and functioning of living organisms. If you want to know more: http://en.wikipedia.org/wiki/DNA In DNA strings, symbols "A" and "T" are complements of each other, as "C" and "G". You function receives one side of the DNA (string, except for Haskell); you need to.. 2022. 3. 31. 이전 1 다음