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

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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