Omid - Challenge 82

data-challenges
advanced-exercises
🔰 In the question table, supervisors’ attendance dates are provided.
Published

March 24, 2026

Illustration for Omid - Challenge 82

Challenge Description

🔰 In the question table, supervisors’ attendance dates are provided.

Solutions

library(tidyverse)
library(readxl)

path = "files/CH-082 Attendance Date.xlsx"
input = read_excel(path, range = "B2:D7")
test  = read_excel(path, range = "F2:G14")

result = input %>%
  mutate(Date = map2(From, To, seq, by = "days")) %>%
  unnest(Date) %>%
  summarise(Supervisors = str_c(Supervisor, collapse = ", "), .by = "Date") 

identical(result, test)
#> [1] TRUE
  • 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

    • Parses the text patterns directly instead of relying on manual cleanup

  • 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 = "CH-082 Attendance Date.xlsx"
input = pd.read_excel(path, usecols="B:D", skiprows=1, nrows = 5)
test = pd.read_excel(path, usecols="F:G", skiprows=1)

result = input.assign(Date=input.apply(lambda row: pd.date_range(row['From'], row['To'], freq='D'), axis=1)) \
    .explode('Date') \
    .groupby('Date') \
    .agg({'Supervisor': lambda x: ', '.join(x)}) \
    .reset_index()
result.rename(columns={'Supervisor': 'Supervisors'}, inplace=True)

print(result.equals(test)) # True
  • 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.