Spaces:
Build error
Build error
File size: 2,092 Bytes
4987d78 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
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)
|