Crispo - Excel Challenge 23 2024

excel-challenges
weekly-exercises
Easy Sunday Excel Challenge
Published

June 3, 2024

Illustration for Crispo - Excel Challenge 23 2024

Challenge Description

Easy Sunday Excel Challenge

⭐ Easy Sunday Excel Challenge

Solutions

  • Logic:

    • Applies the workbook rule directly and shapes the expected output
  • 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
import re
import numpy as np

input = pd.read_excel('files/Excel Challenge 2nd June.xlsx', usecols='C', skiprows=1, nrows = 6)
test  = pd.read_excel('files/Excel Challenge 2nd June.xlsx', usecols='D', skiprows=1, nrows = 6)

test['Last Correct Order'] = test['Last Correct Order'].replace(np.nan, '', regex=True)

def extract_after_last_letter(s):
    match = list(re.finditer(r'[A-Za-z]', s))
    if match:
        last_letter_pos = match[-1].end()
        return s[last_letter_pos:] if last_letter_pos < len(s) else ''
    return ''

input['answer'] = input['Customers & Orders'].apply(extract_after_last_letter)

print(input.merge(test, left_index=True, right_index=True))

#                     Customers & Orders  answer Last Correct Order
# 0                  Emily15423Jake56243   56243              56243
# 1       Adrian Order not yet confirmed
# 2                           Amani#2546   #2546              #2546
# 3   25698 -To confirm if correct Order
# 4        Sean235Tyler58614Manito015236  015236             015236
# 5  Orders #564 and #5862 were rejected
  • Logic:

    • Reads the workbook range needed for the challenge

    • Uses direct text-pattern extraction instead of manual cleanup

  • 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 easy to moderate:

  • The business rule is readable, but the workbook still needs a few careful transformation steps.