Minimize the use of compact commands

Assignment Help Computer Engineering
Reference no: EM133699530

1.Please, provide the solution based on the "def" blocks of the assignment and according to the specified instructions, otherwise I will not be able to use the solution.

2. Could you please comment on basic actions of the code you are implementing

3. All the comments and explanations provided in the code below came with the assignment

4. We are given a dictionary.txt as input, that has a list of words in lines (one word per line) which corresponds to the words_file of the first def function below

5. My main request is if you could please stick to the instructions and implement based on these instructions. I have received another two solutions but I was not able to use them.

6. Also, I would like to ask if you could minimize the use of compact commands (e.g. i for i, ....), if applicable, or, if you need to use them, if you could comment on what exactly they do.


My goal is to mainly learn the topic and work on it by myself, but it is complicated and I am new, so I really count on comments and explanations.

Thank you very much for your time and help :)

class WordMakerAI():
def __init__(self, words_file, debug):
# read in the words into any data structures you see fit
# input format is a file of words separated by newlines
# use open() to open the file, and remember to split up words by word length!
# DO NOT print anything unless debug is set to true

# You can optionally save and use the `debug` parameter to control your own print statements within the game loop.

# Use this code if you like.
"""
with open(words_file) as file_obj:
for line in file_obj:
word = line.strip()
# Use word
"""

pass # TODO: implement this

def reset(self, word_length):
# start a new game with a word length of `word_length`. This will always be called before guess() or getValidWord() are called.
# this function should be O(1). That is, you shouldn't have to process over the entire dictionary here (find somewhere else to preprocess it)
# DO NOT print anything unless debug is set to true on object initialization

pass # TODO: implement this

def getValidWord(self):
# get a valid word in the active dictionary, to return when you lose
# can return any word, as long as it satisfies the previous guesses
# DO NOT print anything unless debug is set to true on object initialization

pass # TODO: implement this

def getAmountOfValidWords(self):
# get the total amount of words that satisfy all the guesses since self.reset was called
# should be O(1)
# Note: Make sure this works! Here's an example input to verify:
# With a word length of 5, after guessing "a, e, i, o, u", you should see 301 remaining words.
# You can see this number by running with the debug flag, i.e. `python3 evil_hangman.py --debug`
# DO NOT print anything unless debug is set to true on object initialization

pass # TODO: implement this

def get_letter_positions_in_word(self, word: str, guess_letter: str) -> tuple[int, ...]:
# This function should return the positions of guess_letter in word. For instance:
# get_letter_positions_in_word("hello", "l") should return (2, 3). The list should
# be sorted ascending and 0-indexed.
# You can assume that word is lowercase with at least length 1 and guess_letter has exactly length 1 and is a lowercase a-z letter.

# Note: to convert from a list to a tuple, call tuple() on the list. For instance:
result = []

#pass TODO:add letter positions to result

return tuple(result)

def guess(self, guess_letter):
# update your data structures and find the longest set of words with the given guess
# should return the list of positions in which the letter was found
# That is, if the guess is "a" and the words left are ["ah", "ai", "bo"], then we should return [0], because
# we are picking the family of words with an "a" in the 0th position. If this function decides that the biggest family
# has no a's, then we'd return [].

# in the case of a tie (multiple families have the same amount of words), should pick the set of words with fewer guess_letter's
# That is, if the guess is "a" and the words left are ["ah", "hi"], we should return [] (picking the set ["hi"]),
# since ["hi"] and ["ah"] are equal length and "hi" has fewer a's than "ah".
# if both sets have an equal number of guess_letter's, then it is ok to pick either.
# For example, if the guess is "a" and the words left are ["aha", "haa"], you can return either [0, 2] or [1, 2].

# The order of the returned list does not matter. You can assume that 'guess_letter' has not been seen yet since the last call to self.reset(),
# and that guess_letter has len of 1 and is a lowercase a-z letter.
# DO NOT print anything unless debug is set to true on object initialization

pass # TODO: implement this

Reference no: EM133699530

Questions Cloud

Analyzes various types of unstructured data : Analyzes various types of unstructured data to enhance their user experience and refine their recommendation algorithms
Explain how the four major agents of socialization teach us : Explain how the four major agents of socialization teach us what constitutes masculinity and femininity in U.S. society.
How does religion influence health behaviors : How does religion influence health behaviors? Who has larger social networks - religious or non-religious people?
What is the software version and the number of exploits : brief amount of time for msfconsole to start up. Be patient. What is the software version, the number of exploits, and the number of payloads
Minimize the use of compact commands : Minimize the use of compact commands (e.g. i for i, ....), if applicable, or, if you need to use them, if you could comment on what exactly they do
Why is developing new products so difficult : Why is developing new products so difficult and What are some other applications you can think of for this technology
What types of obstacles prevent solving this public health : What types of obstacles prevent solving this public health issue? What types of solutions have been attempted or suggested?
What are some ways society can create cultures of solidarity : How does the term Others contribute to the rigged game? What are some ways society can create cultures of solidarity in our current political climate?
Which theory best explains the phenomenon : People become mafia members by growing up in its culture and passing on its traditions. Which theory best explains this phenomenon?

Reviews

Write a Review

Computer Engineering Questions & Answers

  How is the material standard developed

How is the material standard developed? Why are the quantities shown in the bill of materials not always the same quantities should in the standard cost card

  Calculate the speedups assuming the matrices grow

Calculate the speedups assuming the matrices grow to 100 by 100. Which are strong scaling and which are weak scaling in this exercise?

  Write a program to calculate student final letter grades

Write a program to calculate student final letter grades as well as the average and highest scores of CLA, OLA, quizzes, exams.

  Discuss the different needs of two c-level leadership roles

Discuss the different needs of two C-level (CIO, CEO, COO, CFO, CMO, or CSO) leadership roles regarding information systems and why each C-level leader would

  Create pseudo code to represent the logic of a program

Draw a flow chart or create pseudo code to represent the logic of a program that allows the user to enter three values.

  Research the boot process as it was used for a dos

Research the boot process as it was used for a DOS (Disk Operating System) computer. How did it differ from a Windows-based system?

  Discuss convergence

Discuss convergence and post an example you are familiar with or rely on.

  What the appeal would be to outsource it functions

According to recent surveys, China, India, and the Philippines are the three most popular countries for IT outsourcing. Write a short paper.

  Write a program to assist in design of a hydro-electric dam

Prompt the user for the height of the dam and for the number of cubic meters of water that are projected to flow top to the bottom of the dam each second.

  Answer the following

What is final value of y after executing the following code.

  Determine the stakeholder involved

Determine the stakeholder involved - What is the right action that should have been done by the stakeholder

  Discuss how a cio might handle schrage scenarios

Must businesses choose between good ethics and financial benefits? Explain your answer using Schrage's scenarios or your own examples.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd