From d23a2b76f98a6f5dadf770fa219de87df9a17fb9 Mon Sep 17 00:00:00 2001 From: Kishan Takoordyal Date: Mon, 22 Feb 2021 10:47:09 +0400 Subject: [PATCH] BUG FIX --- Pizza/data/a_example | 2 +- Pizza/index.js | 14 +-- Pizza/output/result_B.txt | 186 +++++++++++++++++++------------------- 3 files changed, 102 insertions(+), 100 deletions(-) diff --git a/Pizza/data/a_example b/Pizza/data/a_example index 1dc30f1..e1a5790 100644 --- a/Pizza/data/a_example +++ b/Pizza/data/a_example @@ -3,4 +3,4 @@ 3 mushroom tomato basil 3 chicken mushroom pepper 3 tomato mushroom basil -2 chicken basil \ No newline at end of file +2 chicken basil diff --git a/Pizza/index.js b/Pizza/index.js index 2a492a1..831bcd8 100644 --- a/Pizza/index.js +++ b/Pizza/index.js @@ -22,7 +22,7 @@ function main(file, char) { }; // Insert all pizzas in set - for (let i = 1; i < myArray.length; i++) { + for (let i = 1; i < myArray.length - 1; i++) { let pizza = {}; pizza.id = i - 1; @@ -241,14 +241,16 @@ function main(file, char) { if ( set.teams_2 + set.teams_3 + set.teams_4 === 0 || (availablePizzas.length === 2 && set.teams_2 === 0) || - (availablePizzas.length === 3 && set.teams_3 === 0) + (availablePizzas.length === 3 && set.teams_3 === 0) || + availablePizzas.length < 2 ) { break; } if ( (availablePizzas.length % 2 !== 0 || set.teams_2 + set.teams_4 === 0) && - set.teams_3 > 0 + set.teams_3 > 0 && + availablePizzas.length >= 3 ) { find_for_three(); set.teams_3--; @@ -294,8 +296,8 @@ function main(file, char) { main(file_a, 'A'); main(file_b, 'B'); -main(file_c, 'C'); -main(file_d, 'D'); -main(file_e, 'E'); +// main(file_c, 'C'); +// main(file_d, 'D'); +// main(file_e, 'E'); console.log(`Total Score: ${totalScore}`); diff --git a/Pizza/output/result_B.txt b/Pizza/output/result_B.txt index 1628e6e..ad3d829 100644 --- a/Pizza/output/result_B.txt +++ b/Pizza/output/result_B.txt @@ -1,5 +1,5 @@ 168 -3 28 35 500 +2 28 35 2 93 97 2 190 196 2 197 252 @@ -64,7 +64,7 @@ 2 367 387 2 385 430 2 409 439 -2 419 498 +4 419 498 218 123 4 445 473 8 225 4 455 18 263 31 4 499 117 328 392 @@ -74,96 +74,96 @@ 4 13 99 121 394 4 55 71 159 201 4 90 91 163 391 -4 105 218 351 302 -4 123 162 353 422 +4 105 302 429 442 4 139 188 276 235 +4 162 353 424 348 4 192 242 362 100 -4 203 424 459 400 -4 214 348 497 56 -4 230 294 384 69 -4 268 429 449 474 -4 278 283 364 259 -4 336 442 397 16 -4 375 472 80 107 -4 388 427 25 81 -4 399 407 437 289 -4 403 444 467 274 -4 431 26 27 128 -4 438 40 45 116 -4 447 32 59 138 -4 22 41 50 76 -4 29 36 109 114 -4 44 46 70 200 -4 54 112 148 153 -4 66 78 119 207 -4 79 92 132 245 -4 95 104 144 152 -4 101 106 160 282 -4 115 129 151 226 -4 124 172 174 254 -4 136 195 204 233 -4 164 244 267 347 -4 185 251 332 379 -4 186 247 284 425 -4 198 269 295 361 -4 217 304 325 378 -4 237 359 363 468 -4 280 341 365 490 -4 285 372 377 401 -4 307 373 339 390 -4 395 432 453 450 -4 411 446 461 2 -4 460 494 4 9 -4 30 37 39 42 -4 43 49 51 57 -4 53 62 63 74 -4 58 67 68 77 -4 75 83 85 87 -4 82 84 88 94 -4 96 98 102 103 -4 110 118 122 125 -4 126 127 130 133 -4 131 134 137 142 -4 135 140 143 145 -3 146 150 157 -3 161 167 168 -3 169 171 173 -3 176 178 179 -3 183 184 191 -3 194 202 206 -3 205 209 215 -3 211 216 222 -3 220 223 224 -3 227 228 229 -3 232 238 239 -3 241 243 246 -3 248 250 253 -3 255 257 260 -3 262 265 270 -3 272 275 287 -3 281 290 291 -3 293 296 297 -3 303 305 308 -3 309 313 314 -3 312 316 317 -3 318 321 323 -3 327 331 335 -3 338 340 342 -3 343 344 349 -3 346 355 357 -3 354 366 368 -3 370 374 380 -3 381 383 386 -3 382 389 393 -3 398 402 404 -3 406 408 413 -3 415 416 418 -3 417 426 428 -3 435 436 440 -3 456 457 458 -3 464 465 466 -3 469 470 471 -3 476 477 478 -3 479 481 483 -3 480 485 487 -3 488 489 491 \ No newline at end of file +4 203 422 449 497 +4 214 230 294 459 +4 268 444 474 16 +4 278 283 364 56 +4 336 351 397 32 +4 375 472 400 128 +4 384 388 25 81 +4 399 407 437 69 +4 403 467 431 80 +4 427 27 44 138 +4 438 26 59 245 +4 447 40 41 274 +4 22 45 76 79 +4 29 36 50 107 +4 46 70 78 109 +4 54 112 114 153 +4 66 95 116 119 +4 92 106 132 148 +4 101 115 144 160 +4 104 124 151 200 +4 129 136 152 226 +4 164 172 174 254 +4 185 195 233 251 +4 186 204 207 244 +4 198 247 267 295 +4 217 259 304 378 +4 237 269 282 359 +4 280 284 325 347 +4 285 289 341 379 +4 307 332 401 490 +4 339 361 373 468 +4 363 365 372 395 +4 377 411 453 450 +4 390 460 432 2 +4 425 461 4 9 +4 446 494 30 37 +4 39 42 49 51 +4 43 57 62 63 +4 53 67 68 74 +4 58 77 83 85 +4 75 84 87 88 +4 82 94 96 98 +4 102 103 118 122 +4 110 125 126 127 +4 130 133 134 137 +4 131 140 142 143 +3 135 145 146 +3 150 157 161 +3 167 168 169 +3 171 173 176 +3 178 179 183 +3 184 191 202 +3 194 206 215 +3 205 209 216 +3 211 220 222 +3 223 224 228 +3 227 229 232 +3 238 239 241 +3 243 246 248 +3 250 253 255 +3 257 260 265 +3 262 270 272 +3 275 287 290 +3 281 291 293 +3 296 297 303 +3 305 308 313 +3 309 314 316 +3 312 317 321 +3 318 323 327 +3 331 335 338 +3 340 342 343 +3 344 349 355 +3 346 357 366 +3 354 368 370 +3 374 380 381 +3 382 383 386 +3 389 393 398 +3 402 404 406 +3 408 413 416 +3 415 418 426 +3 417 428 435 +3 436 440 456 +3 457 458 464 +3 465 466 469 +3 470 471 476 +3 477 478 479 +3 480 481 483 +3 485 487 488 +3 489 491 493 \ No newline at end of file