편집 기록

편집 기록
  • 프로필 nowp님의 편집
    날짜2020.02.11

    파이썬 질문. 주어진 문자열에서 가장 작은 알파벳, 세번째 작은 알파벳, 가장 많이 나온 알파벳 구하기.


    학교 수업에서 파이썬 3을 배우고 있는 학생입니다. 학교 숙제를 받았는데 어떻게 시작할지를 모르겠어서 여기에다가 질문 올려요.

    1. Write a function, q2(inputString, minLetter), that takes as input a string of letters and returns six things: the lexicographically smallest letter (z/Z > y/Y > ... > a/A) greater or equal to minLetter, the smallest index at which that letter occurs, the third smallest letter greater than minLetter, the smallest index at which that letter occurs, the most common letter, and how many times the most common letter occurs. The third smallest letter must be distinct from the second smallest which must be distinct from the smallest. E.g. 'b' is the second smallest and 'c' is the third smallest in 'ababdc'

    Ignore case during computation. E.g. 'z' and 'Z' are considered the same letter. Use lower case when returning letters.

    Return None for smallest and thirdSmallest letters and corresponding indices when appropriate.

    You may not assume that the input string contains at least three different characters (or even any characters at all). Make sure to recognize various situations where fewer than three different letters appear in the string, and where there is no third smallest or smallest greater than minLetter.

    If two or more letters tie for most common, return the lexicographically smallest one.

    For example:

    >>> q2('aacyYcqyQQqyqc', 'b')
    ('c', 2, 'y', 3, 'q', 5)
    
    >>> q2('aacyYcqyQQqyqc', 'r')
    ('y', 3, None, None, 'q', 5)
    

    질문은 이건데 학교에서 list 나 sort 는 아직 안배웠다고 쓰지말라고 하셔서 어떻게 해야할지 모르겠어요. 파이썬 처음 배우는거라 뭐가 뭔지도 모르겠는데 수업에서 잘 알려주지도 않아서 걱정입니다. 파이썬 고수분들 제발 도움좀 주세요.

    지금 당장 코드 두줄밖에 못짰는데 어떻게 접근해야할지를 모르겠어요.

  • 프로필 엽토군님의 편집
    날짜2020.02.11

    파이썬 질문이요ㅠㅠ 도움 절실하게 필요합니다


    학교 수업에서 파이썬 3을 배우고 있는 학생입니다. 학교 숙제를 받았는데 어떻게 시작할지를 모르겠어서 여기에다가 질문 올려요ㅠ.

    1. Write a function, q2(inputString, minLetter), that takes as input a string of letters and returns six things: the lexicographically smallest letter (z/Z > y/Y > ... > a/A) greater or equal to minLetter, the smallest index at which that letter occurs, the third smallest letter greater than minLetter, the smallest index at which that letter occurs, the most common letter, and how many times the most common letter occurs. The third smallest letter must be distinct from the second smallest which must be distinct from the smallest. E.g. 'b' is the second smallest and 'c' is the third smallest in 'ababdc'

    Ignore case during computation. E.g. 'z' and 'Z' are considered the same letter. Use lower case when returning letters.

    Return None for smallest and thirdSmallest letters and corresponding indices when appropriate.

    You may not assume that the input string contains at least three different characters (or even any characters at all). Make sure to recognize various situations where fewer than three different letters appear in the string, and where there is no third smallest or smallest greater than minLetter.

    If two or more letters tie for most common, return the lexicographically smallest one.

    For example:

    >>> q2('aacyYcqyQQqyqc', 'b')
    ('c', 2, 'y', 3, 'q', 5)
    
    >>> q2('aacyYcqyQQqyqc', 'r')
    ('y', 3, None, None, 'q', 5)
    

    질문은 이건데 학교에서 list 나 sort 는 아직 안배웠다고 쓰지말라고 하셔서 어떻게 해야할지 모르겠어요.. 파이썬 처음 배우는거라 뭐가 뭔지도 모르겠는데 수업에서 잘 알려주지도 않아서 걱정입니다ㅠ 파이썬 고수분들 제발 도움좀 주세요ㅜㅜㅜ

    지금 당장 코드 두줄밖에 못짰는데 어떻게 접근해야할지를 모르겠어요

  • 프로필 알 수 없는 사용자님의 편집
    날짜2020.02.11

    파이썬 질문이요ㅠㅠ 도움 절실하게 필요합니다


    학교 수업에서 파이썬 3을 배우고 있는 학생입니다. 학교 숙제를 받았는데 어떻게 시작할지를 모르겠어서 여기에다가 질문 올려요ㅠ.

    1. Write a function, q2(inputString, minLetter), that takes as input a string of letters and returns six things: the lexicographically smallest letter (z/Z > y/Y > ... > a/A) greater or equal to minLetter, the smallest index at which that letter occurs, the third smallest letter greater than minLetter, the smallest index at which that letter occurs, the most common letter, and how many times the most common letter occurs. The third smallest letter must be distinct from the second smallest which must be distinct from the smallest. E.g. 'b' is the second smallest and 'c' is the third smallest in 'ababdc'

    Ignore case during computation. E.g. 'z' and 'Z' are considered the same letter. Use lower case when returning letters.

    Return None for smallest and thirdSmallest letters and corresponding indices when appropriate.

    You may not assume that the input string contains at least three different characters (or even any characters at all). Make sure to recognize various situations where fewer than three different letters appear in the string, and where there is no third smallest or smallest greater than minLetter.

    If two or more letters tie for most common, return the lexicographically smallest one.

    For example:

    q2('aacyYcqyQQqyqc', 'b') ('c', 2, 'y', 3, 'q', 5)

    q2('aacyYcqyQQqyqc', 'r') ('y', 3, None, None, 'q', 5)

    질문은 이건데 학교에서 list 나 sort 는 아직 안배웠다고 쓰지말라고 하셔서 어떻게 해야할지 모르겠어요.. 파이썬 처음 배우는거라 뭐가 뭔지도 모르겠는데 수업에서 잘 알려주지도 않아서 걱정입니다ㅠ 파이썬 고수분들 제발 도움좀 주세요ㅜㅜㅜ

    지금 당장 코드 두줄밖에 못짰는데 어떻게 접근해야할지를 모르겠어요