![]() ![]() If(((rows-row_start) >= len(word)) & ((columns - column_start) >= len(word))):ĭef random_alpha(): # Returns a random alphabet ![]() Raise Exception("Oh the letter is already there")ĭef add_diagonally(word,array,row,column,backwards=False): #Same as add_vertically except increase both row and cloumn by 1ĭef random_condition(rows,columns,backwards=True,diagonals=True): # Generate a random condition for the placement of wordīackward = backwards if not backwards else #If backwards is false let it remain so else generate a random valueĭiagonal = diagonals if not diagonals else #Same as aboveĭef check(condition,word): # Check ifthe provided condition is fitting i.e. Raise Exception("Oh the letter is already there") #Throw a errorĪrr = c #Else add the letter to the correct row and columnĭef add_vertically(word,array,row,column,backwards=False): #Same as add horizontally except it increases row by 1 If((arr != '_') & (arr != c)): #If there already exists a character and it is not same as c then Word = word if backwards else word #If backwards is true reverse the word Return for a in range(row)] # Generates a empty array of specified width(column) and height(row)ĭef add_horizontally(word,array,row,column,backwards=False):Īrr = deepcopy(array) #Copy the array because we may make unwanted mutations I have tried my best to write helpful comments. Can you please tell me if what I have done is done in the right way? Also, please tell me how the code is performance-wise. I have made a word-search-generator with Python 3 and it works perfectly. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |