library(tidyverse)
library(readxl)
path = "Excel/694 Repeat Characters Except Consecutives.xlsx"
input = read_excel(path, range = "A1:A9")
test = read_excel(path, range = "B1:B9")
result = input %>%
mutate(rn = row_number()) %>%
separate_rows(Data, sep = "") %>%
filter(Data != "") %>%
mutate(rn2 = consecutive_id(Data), .by = c(rn)) %>%
mutate(rn3 = n(), .by = c(rn, rn2)) %>%
mutate(Data = ifelse(rn3 == 1, paste0(Data, Data), Data)) %>%
summarise(Data = paste0(Data, collapse = ""), .by = c(rn))Excel BI - Excel Challenge 694
excel-challenges
excel-formulas
🔰 Data Answer Expected jqum jjqquumm beeaao beeaaoo xyzxyz xxyyzzxxyyzz wreeemccc wwrreeemmccc

Challenge Description
🔰 Data Answer Expected jqum jjqquumm beeaao beeaaoo xyzxyz xxyyzzxxyyzz wreeemccc wwrreeemmccc
Solutions
- 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 code maps the workbook rule into a compact, reproducible pipeline.
- 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: The elegant part is how little code is needed once the correct intermediate representation is chosen.
import pandas as pd
from itertools import groupby
path = "694 Repeat Characters Except Consecutives.xlsx"
input = pd.read_excel(path, usecols="A", nrows=9)
test = pd.read_excel(path, usecols="B", nrows=9)
def double_single_chars(s):
return ''.join(g*2 if len(g)==1 else g for g in (''.join(list(grp)) for _, grp in groupby(s)))
input["Transformed"] = input["Data"].apply(double_single_chars)
print(input['Transformed'] == test['Answer Expected'])The Python version follows the same grouped logic and keeps the transformation explicit in a dataframe pipeline.
Difficulty Level
Easy / Medium
The business rule is clear, though the workbook still needs a few transformation steps to reach the expected output.