취미생활/CheckIO

[checkIO]Element 10.Right to Left

우주먼지의하루 2020. 3. 21. 03:05
728x90

"For centuries, left-handers have suffered unfair discrimination in a world designed for right-handers."
Santrock, John W. (2008). Motor, Sensory, and Perceptual Development.

"Most humans (say 70 percent to 95 percent) are right-handed, a minority (say 5 percent to 30 percent) are left-handed, and an indeterminate number of people are probably best described as ambidextrous."
Scientific American. www.scientificamerican.com

One of the robots is charged with a simple task: to join a sequence of strings into one sentence to produce instructions on how to get around the ship. But this robot is left-handed and has a tendency to joke around and confuse its right-handed friends.

You are given a sequence of strings. You should join these strings into chunk of text where the initial strings are separated by commas. As a joke on the right handed robots, you should replace all cases of the words "right" with the word "left", even if it's a part of another word. All strings are given in lowercase.

 

Input: A sequence of strings as a tuple of strings (unicode).

Output: The text as a string.

 

Example:

left_join(("left", "right", "left", "stop")) == "left,left,left,stop"

left_join(("bright aright", "ok")) == "bleft aleft,ok"

left_join(("brightness wright",)) == "bleftness wleft"

left_join(("enough", "jokes")) == "enough,jokes"

 

* 모든 right를 left로 바꿔라

* 오늘 예시 문장 너무 웃긴듯.

* CheckIO에서 힌트도 줬다. (Join strings and replace "right" to "left")

 

- 풀이

 

def left_join(phrases):
    """
        Join strings and replace "right" to "left"
    """
    return ",".join(phrases).replace("right","left")

 

반응형

'취미생활 > CheckIO' 카테고리의 다른 글

[checkIO]Element 09.Correct Sentence  (0) 2020.03.18
[checkIO]Element 08.Best Stock  (0) 2020.03.14
[checkIO]Element 07.Even the Last  (0) 2020.03.07
[checkIO]Element 06.Fizz Buzz  (0) 2020.03.03
[checkIO]Element 05.Secret Message  (0) 2020.03.01