library(tidyverse)
library(readxl)
input = read_excel("files/CH-014.xlsx", range = "B2:D133")
test = read_excel("files/CH-014.xlsx", range = "K2:K5")
result = input %>%
mutate(month = month(Date)) %>%
group_by(Product) %>%
summarise(nm = n_distinct(month)) %>%
filter(nm == 12) %>%
ungroup() %>%
select(Products = Product)
identical(result, test)
# [1] TRUEOmid - Challenge 14
data-challenges
advanced-exercises
🔰 Create a list of products sold in all the months throughout the year.

Challenge Description
🔰 Create a list of products sold in all the months throughout the year.
Solutions
Logic:
Reads the workbook ranges needed for the challenge
Aggregates or ranks values at the relevant grouping level
Builds the intermediate columns that drive the final result
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
input_data = pd.read_excel("CH-014.xlsx", usecols="B:D", skiprows=1, nrows=132)
test = pd.read_excel("CH-014.xlsx", usecols="K", skiprows=1, nrows=4)
input_data["Date"] = pd.to_datetime(input_data["Date"])
result = (
input_data.assign(month=input_data["Date"].dt.month)
.groupby("Product", as_index=False)["month"]
.nunique()
)
result = result.loc[result["month"] == 12, ["Product"]].rename(columns={"Product": "Products"})
print(result.equals(test))Logic:
Reads the workbook ranges needed for the challenge
Aggregates or ranks values at the relevant grouping level
Builds the intermediate columns that drive the final result
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 core logic is clear, but the correct transformation pattern is not obvious from the raw input.
The challenge combines multiple reshaping, grouping, or parsing steps.