Skip to content

Commit 46db41f

Browse files
committed
Update README.md with latest statistics and improve file encoding handling in update_readme.py
1 parent 8408de1 commit 46db41f

2 files changed

Lines changed: 31 additions & 16 deletions

File tree

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
# 🏆 Problem Solving Statistics
44

5-
[![Last Updated](https://img.shields.io/badge/Last%20Updated-14%20January%202026-blue?style=for-the-badge)](https://github.com/MishkatIT/ProblemSolvingStats)
6-
[![Total Problems](https://img.shields.io/badge/Total%20Solved-2838-success?style=for-the-badge&logo=leetcode)](https://github.com/MishkatIT/ProblemSolvingStats)
5+
[![Last Updated](https://img.shields.io/badge/Last%20Updated-15%20January%202026-blue?style=for-the-badge)](https://github.com/MishkatIT/ProblemSolvingStats)
6+
[![Total Problems](https://img.shields.io/badge/Total%20Solved-2600-success?style=for-the-badge&logo=leetcode)](https://github.com/MishkatIT/ProblemSolvingStats)
77
[![Platforms](https://img.shields.io/badge/Platforms-12-orange?style=for-the-badge)](https://github.com/MishkatIT/ProblemSolvingStats)
88

99
### 💻 Competitive Programming Journey
@@ -31,14 +31,14 @@
3131
<tr>
3232
<td><strong>🔴 Codeforces</strong></td>
3333
<td><a href="https://codeforces.com/profile/MishkatIT">MishkatIT</a></td>
34-
<td align="center"><strong>2386</strong></td>
35-
<td><img src="https://img.shields.io/badge/Progress-84.1%25-red?style=flat-square" alt="Codeforces Progress"/></td>
34+
<td align="center"><strong>2600</strong></td>
35+
<td><img src="https://img.shields.io/badge/Progress-100.0%25-red?style=flat-square" alt="Codeforces Progress"/></td>
3636
</tr>
3737
<tr>
3838
<td><strong>🟢 LeetCode</strong></td>
3939
<td><a href="https://leetcode.com/MishkatIT/">MishkatIT</a></td>
40-
<td align="center"><strong>412</strong></td>
41-
<td><img src="https://img.shields.io/badge/Progress-14.5%25-yellow?style=flat-square" alt="LeetCode Progress"/></td>
40+
<td align="center"><strong>412 <br/><small>(last updated: unknown)</small></strong></td>
41+
<td><img src="https://img.shields.io/badge/Progress-100.0%25-yellow?style=flat-square" alt="LeetCode Progress"/></td>
4242
</tr>
4343
<tr>
4444
<td><strong>🟣 Vjudge</strong></td>
@@ -55,7 +55,7 @@
5555
<tr>
5656
<td><strong>🟤 CodeChef</strong></td>
5757
<td><a href="https://www.codechef.com/users/MishkatIT">MishkatIT</a></td>
58-
<td align="center"><strong>3</strong></td>
58+
<td align="center"><strong>3 <br/><small>(last updated: unknown)</small></strong></td>
5959
<td><img src="https://img.shields.io/badge/Progress-0.1%25-brown?style=flat-square" alt="CodeChef Progress"/></td>
6060
</tr>
6161
<tr>
@@ -73,7 +73,7 @@
7373
<tr>
7474
<td><strong>🟡 LightOJ</strong></td>
7575
<td><a href="https://lightoj.com/user/mishkatit">MishkatIT</a></td>
76-
<td align="center"><strong>31</strong></td>
76+
<td align="center"><strong>31 <br/><small>(last updated: unknown)</small></strong></td>
7777
<td><img src="https://img.shields.io/badge/Progress-1.1%25-yellow?style=flat-square" alt="LightOJ Progress"/></td>
7878
</tr>
7979
<tr>
@@ -91,7 +91,7 @@
9191
<tr>
9292
<td><strong>🔷 UVa</strong></td>
9393
<td><a href="https://uhunt.onlinejudge.org/id/1615470">MishkatIT</a></td>
94-
<td align="center"><strong>6</strong></td>
94+
<td align="center"><strong>6 <br/><small>(last updated: unknown)</small></strong></td>
9595
<td><img src="https://img.shields.io/badge/Progress-0.2%25-blue?style=flat-square" alt="UVa Progress"/></td>
9696
</tr>
9797
<tr>
@@ -104,7 +104,7 @@
104104
<tfoot>
105105
<tr>
106106
<td colspan="2" align="center"><strong>🎖️ TOTAL</strong></td>
107-
<td align="center"><strong style="font-size: 1.2em;">2838</strong></td>
107+
<td align="center"><strong style="font-size: 1.2em;">2600</strong></td>
108108
<td align="center"><strong>100%</strong></td>
109109
</tr>
110110
</tfoot>
@@ -119,7 +119,7 @@
119119
| 🥇 Top Platform | 🎯 Main Focus | 📚 Platforms Active |
120120
|:---------------:|:-------------:|:------------------:|
121121
| **Codeforces** | **Competitive Programming** | **12** |
122-
| 2386 Problems | Algorithm Mastery | Multi-Platform |
122+
| 2600 Problems | Algorithm Mastery | Multi-Platform |
123123

124124
</div>
125125

update_readme.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
def load_stats():
1313
"""Load statistics from stats.json file."""
1414
try:
15-
with open('stats.json', 'r') as f:
15+
with open('stats.json', 'r', encoding='utf-8') as f:
1616
return json.load(f)
1717
except FileNotFoundError:
1818
print("stats.json not found. Please run update_stats.py first.")
@@ -26,13 +26,29 @@ def load_last_known_info():
2626
"""Load last known counts and dates."""
2727
try:
2828
if os.path.exists('last_known_counts.json'):
29-
with open('last_known_counts.json', 'r') as f:
29+
with open('last_known_counts.json', 'r', encoding='utf-8') as f:
3030
return json.load(f)
3131
except Exception as e:
3232
print(f"Warning: Could not load last known counts: {e}")
3333
return {'counts': {}, 'dates': {}}
3434

3535

36+
def _read_text_file(path):
37+
"""Read a text file using UTF-8 (with BOM support).
38+
39+
On Windows, the default encoding can be cp1252 which may fail for UTF-8 files.
40+
"""
41+
for encoding in ('utf-8', 'utf-8-sig'):
42+
try:
43+
with open(path, 'r', encoding=encoding) as f:
44+
return f.read()
45+
except UnicodeDecodeError:
46+
continue
47+
# Last resort: replace undecodable bytes so the update can proceed.
48+
with open(path, 'r', encoding='utf-8', errors='replace') as f:
49+
return f.read()
50+
51+
3652
def calculate_total(stats):
3753
"""Calculate total solved problems."""
3854
total = 0
@@ -59,8 +75,7 @@ def update_readme(stats, last_known_info=None):
5975

6076
# Read current README
6177
try:
62-
with open('README.md', 'r') as f:
63-
readme_content = f.read()
78+
readme_content = _read_text_file('README.md')
6479
except FileNotFoundError:
6580
print("README.md not found")
6681
return False
@@ -207,7 +222,7 @@ def update_readme(stats, last_known_info=None):
207222

208223
# Write updated README
209224
try:
210-
with open('README.md', 'w') as f:
225+
with open('README.md', 'w', encoding='utf-8', newline='\n') as f:
211226
f.write(readme_content)
212227
print(f"✓ README.md updated successfully!")
213228
print(f" Total problems: {total}")

0 commit comments

Comments
 (0)