Problem 1.2: consecutive four equal numbers Problem Description: Write a GUI program for the consecutive four equal numbers problem, as shown in the following figure. Let the user enter the numbers in...

1 answer below »
Have completed most of the problem just have a little left


Problem 1.2: consecutive four equal numbers Problem Description: Write a GUI program for the consecutive four equal numbers problem, as shown in the following figure. Let the user enter the numbers in the text fields in a grid of 6 rows and 7 columns. The user can click the Solve button to highlight a sequence of four equal numbers, if it exists. import tkinter from tkinter import * boxes= [] refs =[] #create the main window root = Tk() root.geometry("800x800") root.configure(bg='white') x = Label(root, anchor = CENTER, text = " ", bg= 'white') x.grid(row=1, column=1) total_rows = 6 total_columns = 7 #create table i = 0 x = 0 for i in range(total_rows): currentrow = [] x = i for j in range(total_columns): e = Entry(root, width=4, fg='black') e.grid(row = i + 10, column=j+10) info = e.grid_info() currentrow.append((info["row"], info["column"])) # create function and button to print the coordinates of each data field def solve(): for r in currentrow: print(currentrow) Solve = Button(root, anchor = S, command = solve) Solve.grid(row = 100, column = 7) root.mainloop
Answered 2 days AfterSep 05, 2021

Answer To: Problem 1.2: consecutive four equal numbers Problem Description: Write a GUI program for the...

Karthi answered on Sep 05 2021
145 Votes
updated/tkin_update1.py
import random
from tkinter import *
def isConsecutiveFour(values):
r
es = []
for i in range(len(values)):
for j in range(len(values[i])):
val = values[i][j]
# search horizontally
if j <= len(values[i]) - 4:
v1 = values[i][j + 1]
v2 = values[i][j + 2]
v3 = values[i][j + 3]
if val == v1 == v2 == v3:
res.append([i, j])
res.append([i, j + 1])
res.append([i, j + 2])
res.append([i, j + 3])
return res
# search vertically
if i <= len(values) - 4:
v1 = values[i + 1][j]
v2 = values[i + 2][j]
v3 = values[i + 3][j]
if val == v1 == v2 == v3:
res.append([i, j])
res.append([i + 1, j])
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here