Excel BI - Excel Challenge 658

excel-challenges
excel-formulas
🔰 Populate Yes, if it is a valid Word Square.
Published

March 24, 2026

Illustration for Excel BI - Excel Challenge 658

Challenge Description

🔰 Populate Yes, if it is a valid Word Square. If invalid, populate No.

Solutions

library(tidyverse)
library(readxl)

path = "Excel/658 Word Square Validation.xlsx"

M1 = read_excel(path, range = "B2:C3", col_names = F) %>% as.matrix()
test1  = read_excel(path, range = "J2", col_names = F) %>% pull()
A1 = if(all(M1 == t(M1))) "Yes" else "No"
A1 == test1 # TRUE

M2 = read_excel(path, range = "B5:D7", col_names = F) %>% as.matrix()
test2  = read_excel(path, range = "J5", col_names = F) %>% pull()
A2 = if(all(M2 == t(M2))) "Yes" else "No"
A2 == test2 # TRUE

M3 = read_excel(path, range = "B9:E12", col_names = F) %>% as.matrix()
test3  = read_excel(path, range = "J9", col_names = F) %>% pull()
A3 = if(all(M3 == t(M3))) "Yes" else "No"
A3 == test3 # TRUE

M4 = read_excel(path, range = "B14:F18", col_names = F) %>% as.matrix()
test4  = read_excel(path, range = "J14", col_names = F) %>% pull()
A4 = if(all(M4 == t(M4))) "Yes" else "No"
A4 == test4 # TRUE

M5 = read_excel(path, range = "B20:G25", col_names = F) %>% as.matrix()
test5  = read_excel(path, range = "J20", col_names = F) %>% pull()
A5 = if(all(M5 == t(M5))) "Yes" else "No"
A5 == test5 # TRUE

M6 = read_excel(path, range = "B27:H33", col_names = F) %>% as.matrix()
test6  = read_excel(path, range = "J27", col_names = F) %>% pull()
A6 = if(all(M6 == t(M6))) "Yes" else "No"
A6 == test6 # TRUE

M7 = read_excel(path, range = "B35:I42", col_names = F) %>% as.matrix()
test7  = read_excel(path, range = "J35", col_names = F) %>% pull()
A7 = if(all(M7 == t(M7))) "Yes" else "No"
A7 == test7 # TRUE
  • Logic: Read the workbook ranges needed for the challenge.
  • Strengths: The code maps the workbook rule into a compact, reproducible pipeline.
  • Areas for Improvement: The solution assumes the workbook layout and selected ranges remain stable, so any structural change in the sheet would require small adjustments.
  • Gem: The elegant part is how little code is needed once the correct intermediate representation is chosen.
import pandas as pd

path = "658 Word Square Validation.xlsx"

M1 = pd.read_excel(path, usecols="B:C", nrows = 2, skiprows= 1, header=None).values
test1 = pd.read_excel(path, usecols="J", nrows=1, skiprows=1, header=None).values[0][0]
A1 = "Yes" if (M1 == M1.T).all() else "No"
print(A1 == test1) # True

M2 = pd.read_excel(path, usecols="B:D", nrows = 3, skiprows= 4, header=None).values
test2 = pd.read_excel(path, usecols="J", nrows=1, skiprows=4, header=None).values[0][0]
A2 = "Yes" if (M2 == M2.T).all() else "No"
print(A2 == test2) # True

M3 = pd.read_excel(path, usecols="B:E", nrows = 4, skiprows= 8, header=None).values
test3 = pd.read_excel(path, usecols="J", nrows=1, skiprows=8, header=None).values[0][0]
A3 = "Yes" if (M3 == M3.T).all() else "No"
print(A3 == test3) # True

M4 = pd.read_excel(path, usecols="B:F", nrows = 5, skiprows= 13, header=None).values
test4 = pd.read_excel(path, usecols="J", nrows=1, skiprows=13, header=None).values[0][0]
A4 = "Yes" if (M4 == M4.T).all() else "No"
print(A4 == test4) # True

M5 = pd.read_excel(path, usecols="B:G", nrows = 6, skiprows= 19, header=None).values
test5 = pd.read_excel(path, usecols="J", nrows=1, skiprows=19, header=None).values[0][0]
A5 = "Yes" if (M5 == M5.T).all() else "No"
print(A5 == test5) # True

M6 = pd.read_excel(path, usecols="B:H", nrows = 7, skiprows= 26, header=None).values
test6 = pd.read_excel(path, usecols="J", nrows=1, skiprows=26, header=None).values[0][0]
A6 = "Yes" if (M6 == M6.T).all() else "No"
print(A6 == test6) # True

M7 = pd.read_excel(path, usecols="B:I", nrows = 8, skiprows= 34, header=None).values
test7 = pd.read_excel(path, usecols="J", nrows=1, skiprows=34, header=None).values[0][0]
A7 = "Yes" if (M7 == M7.T).all() else "No"
print(A7 == test7) # True

The Python version mirrors the same workbook logic with a concise, direct implementation.

Difficulty Level

Easy / Medium

The business rule is clear, though the workbook still needs a few transformation steps to reach the expected output.