ChatGPT. Можна поки не хвилюваться
Я провів експеремент з ChatGPT 3.5 з такою постановкою задачі яку придумав.
Я думаю що середнього рівня программіст повинен справитись з такою задачою без проблем.
Ось опис задачі як я її і запропонував ChatGPT 3.5:
Problem Statement:
There is a range of numbers from 1 to 100 000 000.
There is a program test.exe that accepts arguments beginning and end of the interval.
Need to: Write a Python code that selects a random number in this interval and some random length from 5 to 10,000
and runs the program test.exe with the arguments start of interval and length.
Additional conditions:
The program must work in a loop and use some repository on disk to remember which intervals have already been processed.
At the first run, the repository may not exist.
The repository records should have the following format:
S L C
Where:
S — is the start value from the initial range.
L — length
C — The condition flag can be True (if the interval was processed by test.exe i.e. test.exe return code was 0) or False (if not processed or test.exe return non-zero code)
I.e. the algorithm is as follows:
At the start of a program run it should read the repository and check if it contains not processed intervals (i.e. intervals with C = False).
If the program found not processed intervals it should process it by test.exe.
If not it generates a new interval and processes it.
The program should work continuously while the user does not interrupt it or test.exe return non-zero code.
Rules about the interval generation:
After the new correct interval generation, it should be saved in the repository with C = False.
After successful interval processing, it should be updated in repository C = True.
The interval is correct if it does not intersect with another interval from the repository.
The interval is not correct if it intersects with any interval or intervals from the repository.
If the generated interval intersects with intervals in the repository it should be corrected or regenerated depending on the case.
Case 1:
For example, the repository contains records:
50 100 True
The program generated S = 1 L = 100.
As we can see the newly generated interval intersects with an interval in the repository. It should be corrected as S = 1 L = 49 to avoid intersections.
Case 2:
For example, the repository contains records:
50 100 True
The program generated S = 100 L = 100.
As we can see the newly generated interval intersects with an interval in the repository. It should be corrected as S = 150 L = 100 to avoid intersections.
Case 3:
For example, the repository contains records:
50 100 True
160 100 True
The program generated S = 100 L = 100.
As we can see the newly generated interval intersects with an intervals in the repository. It should be corrected as S = 150 L = 9 to avoid intersections with existing intervals.
Case 4:
For example, the repository contains records:
50 100 True
The program generated S = 60 L = 10.
As we can see the newly generated interval contains an already existing interval, it should be regenerated again.
Case 5:
For example, the repository contains records:
50 100 True
The program generated S = 1 L = 200.
As we can see the newly generated interval overlap an already existing interval or intervals, it should be regenerated again.
When the interval is generated correctly it should be recorded in the repository.
To avoid repository fragmentation the intervals that are close to each other values should be merged to one.
Consider a case:
Case 1:
For example, the repository contains records:
50 100 True
1 49 False
After successfully processing the interval should be merged
i.e. repository should modified as:
1 100 True
Case 2:
For example, the repository contains records:
50 100 True
150 100 False
After successfully processing the interval should be merged
i.e. repository should modified as:
50 200 True
Case 3:
For example, the repository contains records:
50 100 True
160 100 True
150 9 False
After successfully processing the intervals should be merged
i.e. repository should modified as:
50 210 True
The repository should be modified and saved:
— when the program generated a new interval correctly according to conditions
— when the interval was successfully processed.
Частково ChatGPT 3.5 зміг сгенерувати необхідний код, але тільки самі прості моменти.
Перший же затик виник на методі який він назвав generate_interval() - метод який генерує наступний інтервал уникаючи перетин з уже існуючими. Як я не пробував донести йому суть (яка як на мене довосить детально описана) він генерує не корректно працюючий код.
Загалом я витратив на те шоб пояснити йому де він не правий десь час і так і не отримав бажаного результату.
Можливо я погано описав задачу.
17 коментарів
Додати коментар Підписатись на коментаріВідписатись від коментарів