library(tidyverse)
library(readxl)
path = "files/Excel Challange 28th July.xlsx"
input = read_excel(path, range = "B3:D11", col_types = "text")
test = read_excel(path, range = "F3:J6", col_types = "text")
colnames(test) = c("Student", "t1", "t2", "t3", "t4")
result = input %>%
pivot_wider(names_from = "Test", values_from = "Result", values_fill = "exempt")
identical(result, test)
# [1] TRUECrispo - Excel Challenge 30 2024
excel-challenges
weekly-exercises
Easy Sunday Excel Challenge

Challenge Description
Easy Sunday Excel Challenge
⭐ Problem Solution Student Test Result t1
Solutions
Logic:
Reads the workbook range needed for the challenge
Reshapes the data to the grain required by the task
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 = "files/Excel Challange 28th July.xlsx"
input = pd.read_excel(path, usecols="B:D", skiprows=2, dtype=str)
test = pd.read_excel(path, usecols="F:J", skiprows=2, nrows=3, dtype=str)
test.columns = ["Student", "t1", "t2", "t3", "t4"]
test = test.sort_values(by="Student").reset_index(drop=True)
result = input.pivot(index="Student", columns="Test", values="Result").fillna("exempt").reset_index()
result.columns.name = None
print(result.equals(test)) # TrueLogic:
Reads the workbook range needed for the challenge
Reshapes the data to the grain required by the task
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.