Git Product home page Git Product logo

aoc2021's People

Contributors

sylvainde avatar

Watchers

 avatar  avatar  avatar  avatar

aoc2021's Issues

Day 3 throw an exception with some input sets

Hi,

I was trying to do the advent of code without actually coding, and I got stuck on day 3, as your code threw an exception with my input. It's really annoying, because I had to read you code and what we are asked to guess I could work around the issue with the following patch

diff --git a/day3.py b/day3.py
index 4f50594..5fa0b18 100644
--- a/day3.py
+++ b/day3.py
@@ -23,10 +23,13 @@ def get_power_consumption(diagnostic):
 
 def oxygen_rating(diagnostic, i):
     c = collections.Counter(diag[i] for diag in diagnostic)
-    (val1, nb1), (val2, nb2) = c.most_common(2)
-    if nb1 == nb2:
-        return "1"
-    return val1
+    try:
+        (val1, nb1), (val2, nb2) = c.most_common(2)
+        if nb1 == nb2:
+            return "1"
+        return val1
+    except ValueError:
+        return "0"
 
 
 def co2_rating(diagnostic, i):

Please also test your code with input files you don't have for the coming days.

thx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.