Crispo - Excel Challenge 12 2025

excel-challenges
weekly-exercises
Easy Sunday Excel Challenge
Published

March 17, 2025

Illustration for Crispo - Excel Challenge 12 2025

Challenge Description

Easy Sunday Excel Challenge

⭐ Easy Sunday Excel Challenge

Solutions

library(tidyverse)
library(readxl)

path = "files/CHALLENGE 1205.xlsx"
input = read_excel(path, range = "B3:B13")
test  = read_excel(path, range = "D3:G7")

result = input %>%
  separate(`SUB-DEPARTMENT NAMES`, into = c("sub_department", "department"), sep = "-", extra = "merge", remove = F) %>%
  mutate(rn = row_number(), .by = sub_department) %>%
  select(-department) %>%
  pivot_wider(names_from = sub_department, values_from = `SUB-DEPARTMENT NAMES`) %>%
  select(-rn)

all.equal(result, test, check.attributes = FALSE)
#> [1] TRUE
  • Logic:

    • Reads the workbook range needed for the challenge

    • Reshapes the data to the grain required by the task

    • Builds the intermediate helper columns that drive the final answer

  • Strengths:

    • The R solution stays compact and mirrors the workbook logic closely.
  • Areas for Improvement:

    • The code assumes the workbook layout and named ranges remain stable.
  • Gem:

    • The best part of the solution is choosing a tidy intermediate shape before producing the final answer.
import pandas as pd

path = "CHALLENGE 1205.xlsx"
input_data = pd.read_excel(path, usecols="B", skiprows=2, nrows=11)
test = pd.read_excel(path, usecols="D:G", skiprows=2, nrows=5)

result = (
    input_data["SUB-DEPARTMENT NAMES"]
    .str.split("-", n=1, expand=True)
    .rename(columns={0: "sub_department", 1: "department"})
)
result["SUB-DEPARTMENT NAMES"] = input_data["SUB-DEPARTMENT NAMES"]
result["rn"] = result.groupby("sub_department").cumcount() + 1
result = result.drop(columns=["department"]).pivot(index="rn", columns="sub_department", values="SUB-DEPARTMENT NAMES").reset_index(drop=True)

print(result.equals(test))
  • Logic:

    • Reads the workbook range needed for the challenge

    • Reshapes the data to the grain required by the task

    • Aggregates or ranks values at the correct grouping level

  • Strengths:

    • The Python version keeps the same rule in a direct pandas-oriented workflow.
  • Areas for Improvement:

    • As with the R version, any workbook layout change would require small adjustments.
  • Gem:

    • The implementation stays close to the stated challenge instead of adding unnecessary complexity.

Difficulty Level

This task is moderate:

  • It combines familiar Excel-style logic with at least one non-trivial reshape, grouping, or parsing step.

  • The answer depends on getting the output layout exactly right.