File tree Expand file tree Collapse file tree 2 files changed +2252
-0
lines changed Expand file tree Collapse file tree 2 files changed +2252
-0
lines changed Original file line number Diff line number Diff line change 432
432
" break"
433
433
]
434
434
},
435
+ {
436
+ "cell_type" : " markdown" ,
437
+ "metadata" : {},
438
+ "source" : [
439
+ " ## Day 6\n " ,
440
+ " \n " ,
441
+ " Sum of count of unique answers in each group."
442
+ ]
443
+ },
444
+ {
445
+ "cell_type" : " code" ,
446
+ "execution_count" : 63 ,
447
+ "metadata" : {},
448
+ "outputs" : [
449
+ {
450
+ "name" : " stdout" ,
451
+ "output_type" : " stream" ,
452
+ "text" : [
453
+ " 6703\n "
454
+ ]
455
+ }
456
+ ],
457
+ "source" : [
458
+ " import string\n " ,
459
+ " \n " ,
460
+ " counts = 0\n " ,
461
+ " \n " ,
462
+ " with open('day06-input.txt') as input_file_06:\n " ,
463
+ " input_06 = input_file_06.read()\n " ,
464
+ " groups = input_06.split('\\ n\\ n')\n " ,
465
+ " \n " ,
466
+ " for group in groups:\n " ,
467
+ " i = 0\n " ,
468
+ " for l in string.ascii_lowercase:\n " ,
469
+ " if l in group:\n " ,
470
+ " i = i + 1\n " ,
471
+ " counts = counts + i\n " ,
472
+ " \n " ,
473
+ " print(counts)"
474
+ ]
475
+ },
476
+ {
477
+ "cell_type" : " markdown" ,
478
+ "metadata" : {},
479
+ "source" : [
480
+ " Sum of count of questions in each group to which everyone answered yes."
481
+ ]
482
+ },
483
+ {
484
+ "cell_type" : " code" ,
485
+ "execution_count" : 66 ,
486
+ "metadata" : {},
487
+ "outputs" : [
488
+ {
489
+ "name" : " stdout" ,
490
+ "output_type" : " stream" ,
491
+ "text" : [
492
+ " 3430\n "
493
+ ]
494
+ }
495
+ ],
496
+ "source" : [
497
+ " countt = 0\n " ,
498
+ " \n " ,
499
+ " for group in groups:\n " ,
500
+ " allyes = set(string.ascii_lowercase)\n " ,
501
+ " answers = group.split('\\ n')\n " ,
502
+ " for a in answers:\n " ,
503
+ " allyes.intersection_update(set(a))\n " ,
504
+ " countt = countt + len(allyes)\n " ,
505
+ " \n " ,
506
+ " print(countt)"
507
+ ]
508
+ },
435
509
{
436
510
"cell_type" : " code" ,
437
511
"execution_count" : null ,
You can’t perform that action at this time.
0 commit comments