This repository has been archived by the owner on Jun 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 74
Add basic code generation challenge #98
Merged
SilenNaihin
merged 3 commits into
Significant-Gravitas:master
from
waynehamadi:add-basic-code-challenge
Jul 14, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# mypy: ignore-errors | ||
from typing import List, Optional | ||
|
||
|
||
def two_sum(nums: List, target: int) -> Optional[List[int]]: | ||
seen = {} | ||
for i, num in enumerate(nums): | ||
complement = target - num | ||
if complement in seen: | ||
return [seen[complement], i] | ||
seen[num] = i | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "TestBasicCodeGeneration", | ||
"category": ["code", "iterate"], | ||
"task": "Create a two_sum function in a file called code.py. Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice. Example: Given nums = [2, 7, 11, 15], target = 9, Because nums[0] + nums[1] = 2 + 7 = 9, return [0, 1].", | ||
"dependencies": ["TestWriteFile"], | ||
"ground": { | ||
"answer": "The two_sum function coded properly.", | ||
"should_contain": ["[0, 1]", "[2, 5]", "[0, 3]"], | ||
"should_not_contain": [], | ||
"files": ["test.py"], | ||
"type": "execute_python_code" | ||
}, | ||
"info": { | ||
"difficulty": "novice", | ||
"description": "Tests ability for the agent to create the two_sum function.", | ||
"side_effects": [] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# mypy: ignore-errors | ||
from code import two_sum | ||
from typing import List | ||
|
||
|
||
def test_two_sum(nums: List, target: int, expected_result: List[int]) -> None: | ||
result = two_sum(nums, target) | ||
print(result) | ||
assert ( | ||
result == expected_result | ||
), f"AssertionError: Expected the output to be {expected_result}" | ||
|
||
|
||
if __name__ == "__main__": | ||
# test the trivial case with the first two numbers | ||
nums = [2, 7, 11, 15] | ||
target = 9 | ||
expected_result = [0, 1] | ||
test_two_sum(nums, target, expected_result) | ||
|
||
# test for ability to use zero and the same number twice | ||
nums = [2, 7, 0, 15, 12, 0] | ||
target = 0 | ||
expected_result = [2, 5] | ||
test_two_sum(nums, target, expected_result) | ||
|
||
# test for first and last index usage and negative numbers | ||
nums = [-6, 7, 11, 4] | ||
target = -2 | ||
expected_result = [0, 3] | ||
test_two_sum(nums, target, expected_result) |
Submodule gpt-engineer
updated
from 521d62 to bca191
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you write what these hidden_files are in the read me? doesnt have to be structured but for my own understanding what the difference between these and artifacts_out