The instructions for the coding test are as follows:" Votee would like to conduct the…
- User
The instructions for the coding test are as follows:"
Votee would like to conduct the coding test in a recorded live session. The idea is to connect to an API that plays a Wordle-like puzzle. You can find the API documentation at the following link: https://wordle.votee.dev:8000/redoc
Developers are allowed to use any frameworks, IDEs, chatbots, LLMs, or other resources to write their program and showcase their skill set. However, if you take references from other open-source projects or tutorials, please ensure that proper credit is given. Plagiarism will not be tolerated, and it may affect the evaluation of your application.
Your task is to write a program that automatically guesses random words against the API, using the following command as an example: curl -v ‘https://wordle.votee.dev:8000/random?guess=theft&seed=1234'" If I run curl -v ‘https://wordle.votee.dev:8000/random?guess=theft&seed=1234 in the terminal, the output: StatusCode : 200 StatusDescription : OK Content : [{"slot":0,"guess":"t","result":"correct"},{"slot":1,"guess":"h","result":"correct"},{"slot":2,"guess":"e","result":"correct"}, {"slot":3,"guess":"f","result":"correct"},{"slot":4,"guess":"t","result":... RawContent : HTTP/1.1 200 OK Content-Length: 211 Content-Type: application/json Date: Sun, 26 May 2024 08:27:33 GMT Server: uvicorn
[{"slot":0,"guess":"t","result":"correct"},{"slot":1,"guess":"h","result":...Forms : {} Headers : {[Content-Length, 211], [Content-Type, application/json], [Date, Sun, 26 May 2024 08:27:33 GMT], [Server, uvicorn]} Images : {} InputFields : {} Links : {} ParsedHtml : mshtml.HTMLDocumentClass RawContentLength : 211
Help me to write this Python program that can always guess the words. You can refer to this algorithm :"It all starts with a dictionary. Each letter of the alphabet is included as a key and maps to a list with five numbers. These numbers represent each position in a five-letter word. We then iterate over all the letters in the dictionary and all the possible words left, recording the frequencies of occurrence of each letter in each position into the dictionary. Here’s an example: let’s say we have a word consisting of five 'a’s. Since this word only contains ‘a’, we will only need to update the frequencies in the dictionary for ‘a’. The frequency for each position is increased by one.
Let’s now consider a second word, ‘x y z a a’. For letter ‘a’, we need to update the dictionary; we now have 1, 1, 1, 2, 2. We must also update the values for ‘x’ and the other occurring letters. Once we have iterated over all words, we have frequencies for each letter. Next, we find the maximum frequency for each position from 0 to 4 for the whole alphabet. This happens in the first for loop of the code shown. The second for loop calculates a score for each word. This score is calculated by multiplying the frequency differences from the maximum for each letter and position in a given word. The word with the lowest score is best.
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.