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
My Python program that guess the words: " import random import requests import json from collections import Counter
Load the word list
with open("C:/Users/a/Desktop/valid-wordle-words.txt", 'r') as file: word_list = [line.strip() for line in file.readlines()]
API base URL
base_url = 'https://wordle.votee.dev:8000/random'
Function to make a guess
def make_guess(guess, seed): response = requests.get(f"{base_url}?guess={guess}&seed={seed}") if response.status_code == 200: return response.json() else: print("Failed to make a guess.") return None
Function to filter the word list based on feedback
- Assistant
- User
In "def choose_initial_guess(word_list): # Combine all words into a single string to count letter frequency all_letters = ‘’.join(word_list) letter_freq = Counter(all_letters)
# Sort words by the sum of their letter frequencies words_sorted_by_freq = sorted(word_list, key=lambda word: sum(letter_freq[char] for char in set(word)), reverse=True) # Choose the first word that has no repeating letters for word in words_sorted_by_freq: if len(set(word)) == len(word): return word # As a fallback, return the first word in the original list return word_list[0]"What is the meaning of ‘’.join(word_list)? What is Counter?
- Assistant
- User
What is the meaning of "words_sorted_by_freq = sorted(word_list, key=lambda word: sum(letter_freq[char] for char in set(word)), reverse=True)" ?
- Assistant
- User
What is sorted() ? What is key=lambda ? What is word: sum(letter_freq[char] for char in set(word))? What is reverse=True?
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.