Excel BI - Excel Challenge 688

excel-challenges
excel-formulas
🔰 Sum all the
Published

March 24, 2026

Illustration for Excel BI - Excel Challenge 688

Challenge Description

🔰 Sum all the

Solutions

library(tidyverse)
library(readxl)

path = "Excel/688 Sum of All Except First and Last Numbers.xlsx"
input = read_excel(path, range = "A1:A10")
test  = read_excel(path, range = "B1:B2") %>%
  pull()

result = input %>%
  mutate(numbers = str_extract_all(Strings, "\\d+"),
         numbers = map(numbers, ~ as.numeric(.x)),
         sum = map_dbl(numbers, ~ sum(.x[-c(1, length(.x))]))) %>%
  summarise(sum = sum(sum)) %>%
  pull()

test == result #> True
  • Logic: Read the workbook ranges needed for the challenge; Derive the required intermediate columns; Parse the packed text or string structure; Aggregate or rank the data at the required grouping level.
  • Strengths: The solution stays close to the text pattern itself, which makes the extraction logic easy to audit.
  • Areas for Improvement: The solution assumes the workbook layout and selected ranges remain stable, so any structural change in the sheet would require small adjustments.
  • Gem: A small number of well-targeted text patterns does most of the heavy lifting.
import pandas as pd
import re

path = "688 Sum of All Except First and Last Numbers.xlsx"
input = pd.read_excel(path, usecols="A", nrows=10)
test = pd.read_excel(path, usecols="B", nrows=1).squeeze().tolist()

input['cell_sum'] = input['Strings'].apply(lambda x: sum(int(num) for num in re.findall(r'\d+', str(x))[1:-1]))
result = input['cell_sum'].sum()

print(result == test) # True

The Python version expresses the core extraction rule directly and keeps the pattern matching easy to review.

Difficulty Level

Medium

The individual steps are manageable, but the correct transformation pattern is not obvious from the raw data.