Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Feel free to explore, learn, and share your own approaches.
- [x] **3/21:** First Tweet 🐦
- [x] **3/22:** Water Day 💧
- [x] **3/23:** Cuddly Kittens 🐈
- [ ] **3/24:** Earthquake Anomaly 🌏
- [x] **3/24:** [Earthquake Anomaly](https://github.com/codedex-io/daily-challenges/tree/main/march-2026/3-24-earthquake-anomaly) 🌏
- [ ] **3/25:** ❓❓❓
- [ ] **3/26:** ❓❓❓
- [ ] **3/26:** ❓❓❓
Expand Down
19 changes: 19 additions & 0 deletions march-2026/3-24-earthquake-anomaly/earthquake-anomaly.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
def earthquake_anomaly(readings):
# if no readings we simply return an empty array
if not readings:
return []

# first we sort the readings
sorted_readings = sorted(readings)
n = len(sorted_readings)

# find the median
if n % 2 == 1:
median = sorted_readings[n // 2]
else:
median = (sorted_readings[n // 2 - 1] + sorted_readings[n // 2]) / 2

# now let's find the threshold
threshold = median * 1.5

return [i for i, thresh in enumerate(readings) if thresh > threshold]