Coconet_Visual / remove.py
vedant2905's picture
Upload 34 files
4987d78 verified
raw
history blame
2.09 kB
def remove_lines(filepath, lines_to_remove):
# Read the file
with open(filepath, 'r', encoding='utf-8') as f:
file_content = f.read()
# Split content into lines
lines = file_content.split('\n')
# Create a set of line numbers to remove for O(1) lookup
remove_set = set(lines_to_remove)
# Keep lines that aren't in the remove set
filtered_lines = [line for i, line in enumerate(lines, 1) if i not in remove_set]
# Join lines back together
new_content = '\n'.join(filtered_lines)
# Write back to the same file
with open(filepath, 'w', encoding='utf-8') as f:
f.write(new_content)
lines_to_remove = [
5,
11,
26,
46,
53,
84,
117,
174,
175,
209,
212,
219,
220,
268,
272,
277,
294,
319,
322,
333,
369,
402,
437,
451,
471,
471,
471,
480,
494,
502,
514,
564,
569,
579,
592,
599,
602,
602,
619,
647,
679,
681,
685,
688,
781,
795,
833,
843,
859,
860,
899,
911,
941,
947,
989,
993,
1100,
1111,
1120,
1123,
1126,
1153,
1165,
1173,
1183,
1186,
1186,
1220,
1230,
1238,
1242,
1247,
1274,
1285,
1289,
1324,
1358,
1385,
1397,
1402,
1465,
1474,
1504,
1507,
1517,
1563,
1592,
1605,
1614,
1626,
1648,
1648,
1689,
1702,
1730,
1730,
1737,
1769,
1784,
1799,
1824,
1834,
1840,
1853,
1860,
1872,
1941,
2038,
2045,
2081,
2096,
2108,
2115,
2115,
2147,
2149,
2165,
2167,
2173,
2195,
2216,
2275,
2278,
2282,
2285,
2327,
2339,
2347,
2348,
2348,
2425,
2444,
2476,
2477,
2482,
2482,
2486,
2499,
2515,
2529,
2529,
2559,
2565,
2567,
2573,
2582,
2633,
2641,
2677,
2705,
2719,
2744,
2756,
2821,
2860,
2864,
2936,
2955,
2992,
3022,
3041,
3064,
3074,
3121,
3123,
3160,
3170,
3172,
3179,
3180,
3195,
3199,
3208,
3208,
3259,
3269,
3280,
3299,
3300,
3323,
3334,
3352,
3364,
3365,
3378,
3405,
3424,
3438,
3492,
3511,
3512,
3533,
3572,
3579,
3710,
3730,
3735,
3759,
3787,
3793
]
remove_lines('input.in', lines_to_remove)