Omid - Challenge 345

data-challenges
advanced-exercises
๐Ÿ”ฐ Question Result ๐Ÿงฉ Adding Explanations If you want to include explanations or extra notes: ๐ŸŒ Sharing External Content ๐Ÿ—ฃ Feedback I always appreciate your feedback โ€” feelโ€ฆ
Published

March 24, 2026

Illustration for Omid - Challenge 345

Challenge Description

๐Ÿ”ฐ Question Result ๐Ÿงฉ Adding Explanations If you want to include explanations or extra notes: ๐ŸŒ Sharing External Content ๐Ÿ—ฃ Feedback I always appreciate your feedback โ€” feelโ€ฆ

Solutions

library(tidyverse)
library(readxl)
library(charcuterie)

path <- "300-399/345/CH-345 Pattern Recongnition.xlsx"
input <- read_excel(path, range = "B3:B8")
test <- read_excel(path, range = "C3:C8")

result = input %>%
  mutate(Pattern = map(Pattern, chars)) %>%
  mutate(Count = map_int(Pattern, ~ sum(.x[-length(.x)] != .x[-1])))

# difference in 3 example.
  • Logic:

    • Reads the workbook ranges needed for the challenge

    • 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
import numpy as np

path = "300-399/345/CH-345 Pattern Recongnition.xlsx"
input = pd.read_excel(path, usecols="B", skiprows=2, nrows=6)
test = pd.read_excel(path, usecols="C", skiprows=2, nrows=6)

input["Count"] = input["Pattern"].apply(
    lambda x: sum(a != b for a, b in zip(x, x[1:]))
)
  • Logic:

    • 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.