library(tidyverse)
library(readxl)
path = "files/200-299/272/CH-272 Find Value.xlsx"
input = read_excel(path, range = "B2:D9")
test = read_excel(path, range = "F2:F13") %>% pull() %>% sort()
result = map2(
row(input), col(input),
~ {
val = input[[.y]][.x]
is_unique_row = sum(input[.x, ] == val) == 1
is_unique_col = sum(input[[.y]] == val) == 1
if (is_unique_row && is_unique_col) val else NULL
}
) %>%
compact() %>%
unlist() %>%
sort()
all.equal(result, test)
# [1] TRUEOmid - Challenge 272
data-challenges
advanced-exercises
🔰 : Find the Unique Value!

Challenge Description
🔰 : Find the Unique Value!
Solutions
Logic:
- Reads the workbook ranges needed for the challenge
Strengths:
- The R solution stays close to the workbook rule and keeps the transformation compact.
Areas for Improvement:
- The code assumes the sheet structure and source ranges remain stable.
Gem:
- The strongest part of the solution is choosing the right intermediate representation before shaping the final output.
import pandas as pd
path = "200-299/272/CH-272 Find Value.xlsx"
df = pd.read_excel(path, usecols="B:D", skiprows=1, nrows=7)
test = sorted(pd.read_excel(path, usecols="F", skiprows=1, nrows=12).iloc[:, 0].tolist())
unique = sorted(
v for c in df for i, v in df[c].items()
if (df[c] == v).sum() == 1 and (df.loc[i] == v).sum() == 1
)
print(unique == test) # TrueLogic:
Reads the workbook ranges needed for the challenge
Applies the rule iteratively until the output stabilizes
Strengths:
- The Python version follows the same rule in a direct dataframe-oriented implementation.
Areas for Improvement:
- The code assumes the workbook layout remains stable, so any sheet redesign would require small adjustments.
Gem:
- The implementation stays close to the original workbook rule instead of adding unnecessary abstraction.
Difficulty Level
This task is moderate:
- The business rule is readable, but the workbook still requires careful implementation to reach the expected layout.