6 kyu
The Arithmetic Progression Detective
71 of 97iedayan03
Description:
Imagine you're a master codebreaker or an archaeologist of ancient math puzzles. You've stumbled upon an arithmetic sequence, a harmonious string of numbers where each term follows a fixed step. But something is wrong—one number has been corrupted, disturbing the pattern.
Your mission: identify the intruder and restore the sequence to its original perfection.
Task
Write a function that takes a nearly correct arithmetic sequence with exactly one corrupted value and fixes the sequence by replacing the incorrect number with the correct one.
Rules
- The sequence contains exactly one incorrect value.
- The repaired sequence must be a valid arithmetic progression.
- The input sequence will always have at least one solution.
Edge Cases
- If the sequence has 1, 2, or 3 elements, return it unchanged (since there is no definitive way to detect corruption).
Similar Kata:
Stats:
Created | Jan 16, 2025 |
Published | Jan 25, 2025 |
Warriors Trained | 362 |
Total Skips | 6 |
Total Code Submissions | 1450 |
Total Times Completed | 97 |
Python Completions | 71 |
Java Completions | 26 |
Go Completions | 7 |
Total Stars | 8 |
% of votes with a positive feedback rating | 92% of 30 |
Total "Very Satisfied" Votes | 26 |
Total "Somewhat Satisfied" Votes | 3 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 10 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |