sylvainde / aoc2021 Goto Github PK
View Code? Open in Web Editor NEWAdvent Of Code 2021
License: MIT License
Advent Of Code 2021
License: MIT License
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.