Skip to content

Latest commit

 

History

History
197 lines (194 loc) · 5.32 KB

File metadata and controls

197 lines (194 loc) · 5.32 KB

Results of GPT-3.5 on HumanEval/86

Date: 18 July, 2023
Model: gpt-3.5-turbo
Temperature: 0.2
Passing runs: 10
Total runs: 10
Success rate: 100%

Prompt

Tokens: 156

def anti_shuffle(s):
    """
    Write a function that takes a string and returns an ordered version of it.
    Ordered version of string, is a string where all words (separated by space)
    are replaced by a new word where all the characters arranged in
    ascending order based on ascii value.
    Note: You should keep the order of words and blank spaces in the sentence.

    For example:
    anti_shuffle('Hi') returns 'Hi'
    anti_shuffle('hello') returns 'ehllo'
    anti_shuffle('Hello World!!!') returns 'Hello !!!Wdlor'
    """

The above is an incomplete Python code fragment. Return the complete and correct code with no additional text.

Correct solution

def anti_shuffle(s):
    """
    Write a function that takes a string and returns an ordered version of it.
    Ordered version of string, is a string where all words (separated by space)
    are replaced by a new word where all the characters arranged in
    ascending order based on ascii value.
    Note: You should keep the order of words and blank spaces in the sentence.

    For example:
    anti_shuffle('Hi') returns 'Hi'
    anti_shuffle('hello') returns 'ehllo'
    anti_shuffle('Hello World!!!') returns 'Hello !!!Wdlor'
    """return ' '.join([''.join(sorted(list(i))) for i in s.split(' ')])

Unit tests

def check(candidate):

    # Check some simple cases
    assert candidate('Hi') == 'Hi'
    assert candidate('hello') == 'ehllo'
    assert candidate('number') == 'bemnru'
    assert candidate('abcd') == 'abcd'
    assert candidate('Hello World!!!') == 'Hello !!!Wdlor'
    assert candidate('') == ''
    assert candidate('Hi. My name is Mister Robot. How are you?') == '.Hi My aemn is Meirst .Rboot How aer ?ouy'
    # Check some edge cases that are easy to work out by hand.
    assert True

Runs

✅ Run 1

Start time: 2023-07-18 17:14:44
Duration: 2.43s
Completion tokens: 48
Result: Pass

def anti_shuffle(s):
    words = s.split()
    ordered_words = []
    for word in words:
        ordered_word = ''.join(sorted(word))
        ordered_words.append(ordered_word)
    return ' '.join(ordered_words)

✅ Run 2

Start time: 2023-07-18 17:14:42
Duration: 2.26s
Completion tokens: 48
Result: Pass

def anti_shuffle(s):
    words = s.split()
    ordered_words = []
    for word in words:
        ordered_word = ''.join(sorted(word))
        ordered_words.append(ordered_word)
    return ' '.join(ordered_words)

✅ Run 3

Start time: 2023-07-18 17:14:39
Duration: 2.34s
Completion tokens: 48
Result: Pass

def anti_shuffle(s):
    words = s.split()
    ordered_words = []
    for word in words:
        ordered_word = ''.join(sorted(word))
        ordered_words.append(ordered_word)
    return ' '.join(ordered_words)

✅ Run 4

Start time: 2023-07-18 17:14:37
Duration: 2.54s
Completion tokens: 48
Result: Pass

def anti_shuffle(s):
    words = s.split()
    ordered_words = []
    for word in words:
        ordered_word = ''.join(sorted(word))
        ordered_words.append(ordered_word)
    return ' '.join(ordered_words)

✅ Run 5

Start time: 2023-07-18 17:14:34
Duration: 2.67s
Completion tokens: 48
Result: Pass

def anti_shuffle(s):
    words = s.split()
    ordered_words = []
    for word in words:
        ordered_word = ''.join(sorted(word))
        ordered_words.append(ordered_word)
    return ' '.join(ordered_words)

✅ Run 6

Start time: 2023-07-18 17:14:32
Duration: 2.28s
Completion tokens: 48
Result: Pass

def anti_shuffle(s):
    words = s.split()
    ordered_words = []
    for word in words:
        ordered_word = ''.join(sorted(word))
        ordered_words.append(ordered_word)
    return ' '.join(ordered_words)

✅ Run 7

Start time: 2023-07-18 17:14:29
Duration: 2.51s
Completion tokens: 48
Result: Pass

def anti_shuffle(s):
    words = s.split()
    ordered_words = []
    for word in words:
        ordered_word = ''.join(sorted(word))
        ordered_words.append(ordered_word)
    return ' '.join(ordered_words)

✅ Run 8

Start time: 2023-07-18 17:14:27
Duration: 2.31s
Completion tokens: 48
Result: Pass

def anti_shuffle(s):
    words = s.split()
    ordered_words = []
    for word in words:
        ordered_word = ''.join(sorted(word))
        ordered_words.append(ordered_word)
    return ' '.join(ordered_words)

✅ Run 9

Start time: 2023-07-18 17:14:24
Duration: 2.37s
Completion tokens: 49
Result: Pass

def anti_shuffle(s):
    words = s.split(" ")
    ordered_words = []
    for word in words:
        ordered_word = "".join(sorted(word))
        ordered_words.append(ordered_word)
    return " ".join(ordered_words)

✅ Run 10

Start time: 2023-07-18 17:14:22
Duration: 2.29s
Completion tokens: 48
Result: Pass

def anti_shuffle(s):
    words = s.split()
    ordered_words = []
    for word in words:
        ordered_word = ''.join(sorted(word))
        ordered_words.append(ordered_word)
    return ' '.join(ordered_words)