2021 Day 5, part 1 - Python

2021.12.06 05:05 y_shr 2021 Day 5, part 1 - Python

I'm pretty stuck. My solution works for horizontal and vertical lines. I also checked the diagonal lines, and the output matched what I would expect. But for the proper input data, it fails. Here's the code, slightly trimmed for readability:

import numpy as np class Line: def __init__(self, start, end): self.start = start self.end = end if self.start[0] > self.end[0]: self.dx = -1 elif self.start[0] < self.end[0]: self.dx = 1 else: self.dx = 0 if self.start[1] > self.end[1]: self.dy = -1 elif self.start[1] < self.end[1]: self.dy = 1 else: self.dy = 0 fname = INPUT_FILE # Some filename with correctly formatted input data # Help functions def read_lines(fname): # Parse file as Line objects lines = [] max_x = 0 max_y = 0 with open(fname) as f: for textline in f.readlines(): raw_coords = textline[:-1].split(" -> ") start = [int(raw_num) for raw_num in raw_coords[0].split(",")] end = [int(raw_num) for raw_num in raw_coords[1].split(",")] lines.append(Line.Line(start, end)) max_x = np.max([start[0], end[0], max_x]) max_y = np.max([start[1], end[1], max_y]) return lines, max_x, max_y def draw_line(board, line): pos = line.start.copy() while pos != line.end: board[pos[0], pos[1]] += 1 pos[0] += line.dx pos[1] += line.dy # Explicitly include final point board[pos[0], pos[1]] += 1 # Read file and preallocate lines, max_x, max_y = read_lines(fname) board = np.zeros([max_x + 1, max_y + 1]) # Solve first problem i = 0 for line in lines: draw_line(board, line) print("At least two lines overlap at", np.sum(board >= 2), "squares") 
A few commments: * The use of lists in the Line class is probably suboptimal. * I let the board be a numpy array solely to make the final answer a one-liner. * draw_line could probably have been more numpy-esque.
Any help is appreciated!
submitted by y_shr to adventofcode [link] [comments]


2021.12.06 05:05 ImMarbles 🎵K-K-K-K-Kenny and His Jet🎵

submitted by ImMarbles to GME [link] [comments]


2021.12.06 05:05 CKsTechnologyNews Open source lightweight alternative to TensorFlow for time-series data

submitted by CKsTechnologyNews to CKsTechNews [link] [comments]


2021.12.06 05:05 gillylfc8 Content

Anyone got any of her content to post
submitted by gillylfc8 to Laurenkenny [link] [comments]


2021.12.06 05:05 Bananas_1911 Is Spotify’s UI garbage on purpose?

I’m looking to migrating to Spotify because f*** it. They took over Gimlet. And I really love Heavyweight. I was messing about with their suggestions and it’s actually pretty useful but then when I set up all these new podcasts I wanted to listen to… oh my goodness it is complete trash. I downloaded some episodes but then I have to click on something to click on something to click on something… does anyone have Spotify? Is there any suggestions? I’m trying to get away from pocketcasts because I’m dead tired of always having a podcast finish 3 minutes before it should or what have you. Apple podcasts is also overwhelming.
submitted by Bananas_1911 to podcasts [link] [comments]


2021.12.06 05:05 MarlboroReddit sick oneliner

submitted by MarlboroReddit to bombingcirclejerk [link] [comments]


2021.12.06 05:05 JazzE81 Jingle Bells - Elad David (Christmas ukulele) [instrumental]

submitted by JazzE81 to Instrumentals [link] [comments]


2021.12.06 05:05 Shoddy-Design-7581 18 M4F Syracuse ny take my virginity

submitted by Shoddy-Design-7581 to upstatenyr4r [link] [comments]


2021.12.06 05:05 Veridically_ ELI5: how do electrons interfere with themselves?

I was always told and believed that interference was a relationship between at least two things. But electron interference seems to be a single term relationship.
submitted by Veridically_ to explainlikeimfive [link] [comments]


2021.12.06 05:05 xXBASSXx777 [USA-OH] [H] PayPal, Cash [W] 1050ti or 960 4gb

Hello, I am looking for a 1050ti for around $150 shipped or local (southeast OH). I would prefer a 1050ti but if I could get a good deal on a 4Gb 960 I would consider that as well. I plan to add it to my Plex server for video encoding and decoding. if you have something that could fit that use case and my budget I would be interested in what you're offering. May be interested in certain Quadro P cards as well. Thanks in advance!
submitted by xXBASSXx777 to hardwareswap [link] [comments]


2021.12.06 05:05 code_hunter_cc Readonly models in Django admin interface?

Django
How can I make a model completely read-only in the admin interface? It's for a kind of log table, where I'm using the admin features to search, sort, filter etc, but there is no need to modify the log.
In case this looks like a duplicate, here's not what I'm trying to do:

Answer link : https://codehunter.cc/a/django/readonly-models-in-django-admin-interface
submitted by code_hunter_cc to codehunter [link] [comments]


2021.12.06 05:05 el3rod عروض ك إم للتجارة ابو شغارة|توفير|حتى 8-12-2021 #عروض_ك_ام_للتجاره #العروض #el3rod #تخفيضات #خصومات #تسوق #عروض #تخفيض #خصم #عرض #اخر_عروض_الامارات #الامارات #عروض_الامارات

عروض ك إم للتجارة ابو شغارة|توفير|حتى 8-12-2021 #عروض_ك_ام_للتجاره #العروض #el3rod #تخفيضات #خصومات #تسوق #عروض #تخفيض #خصم #عرض #اخر_عروض_الامارات #الامارات #عروض_الامارات submitted by el3rod to el3rod_UAE [link] [comments]


2021.12.06 05:05 chapiku1 Guys, I can't find my wrapped story!

I may have skipped through it (I sure hope not!) If you skip it is it gone forever?
I only have the playlist.
Where can I find my wrapped story?
submitted by chapiku1 to spotify [link] [comments]


2021.12.06 05:05 silly_bugga Ray Lyn uppercut downstairs by Sapphire

Ray Lyn uppercut downstairs by Sapphire submitted by silly_bugga to WGLBArchive2 [link] [comments]


2021.12.06 05:05 mindstop7 Cheap and Best way to get USDT

As you know the prices of USDT are insanely High. Is there a way to get it at the correct price?
Any suggestions is appreciated. I see the actual price is 74 but exchange has it at 82 rupees.
submitted by mindstop7 to CryptoIndia [link] [comments]


2021.12.06 05:05 Cream_Rabbit Count timer while executing?

Hi everyone. So i am currently having a project of Gomoku, AKA Tictactoe but with a larger size map, and you need to score 5 to win instead of 3
My project consists of 3 game modes: the casual gamemode when you play normally, the time attack gamemode when, if a player's time counter runs out, loses, and the Vs Robot mode, but since we haven't touched a bit into AI, so i just simply make a random bot, picking move randomly, and our tutors do not require us to make a high-quality bot
That leaves the second gamemode
So my plan is, to keep the code of the first gamemode

if (gamemode==1) { cout << "Select the map you want to play: " << endl; cout << " 1. 3x3" << endl; cout << " 2. 5x5" << endl; cout << " 3. 7x7" << endl; cin >> szchoice; if (szchoice==1) { b.bsize=3; wincon=3; } if (szchoice==2) { b.bsize=5; wincon=5; } if (szchoice==3) { b.bsize=7; wincon=5; } while (c!='z' && gamewin==0) { system("CLS"); Print\_Board(b); c=\_getch(); switch(c) { 
case 119:
{
if (b.cursor>=b.bsize)
b.cursor=b.cursor-b.bsize;
break;
}
case 115:
{
if (b.cursor<=b.bsize*(b.bsize-1)-1)
b.cursor=b.cursor+b.bsize;
break;
}
case 97:
{
if (b.cursor%b.bsize>0)
b.cursor=b.cursor-1;
break;
}
case 100:
{
if (b.cursor%b.bsize b.cursor=b.cursor+1;
break;
}
case 13:
{
if (b.grid[b.cursob.bsize][b.cursor%b.bsize]==0)
{
if (player1turn)
{
b.grid[b.cursob.bsize][b.cursor%b.bsize]=1;
player1turn=false;
if (CheckWin(b, 1, wincon)==true)
gamewin=1;
}
else
{
b.grid[b.cursob.bsize][b.cursor%b.bsize]=2;
player1turn=true;
if (CheckWin(b, 2, wincon)==true)
gamewin=2;
}
break;
}
}
 } if (gamewin==1) { 
system("CLS");
Print_Board(b);
cout << "Congratulations, player 1, you have won";
ofstream output;
output.open("C:\\Users\\Windows 10 21H1\\Desktop\\Tictactoe\\Winning.txt");
output << "Gamemode: " << gamemode << endl;
output << "Map size: " << b.bsize << endl;
output << "Winner: Player 1";
output.close();
break;
 } if (gamewin==2) { 
system("CLS");
Print_Board(b);
cout << "Congratulations, player 2, you have won";
ofstream output;
output.open("C:\\Users\\Windows 10 21H1\\Desktop\\Tictactoe\\Winning.txt");
output << "Gamemode: " << gamemode << endl;
output << "Map size: " << b.bsize << endl;
output << "Winner: Player 1";
output.close();
break;
 } } } 
and then add the time-counting feature for both players. So what should i do with the timer and where do i put it?
submitted by Cream_Rabbit to Cplusplus [link] [comments]


2021.12.06 05:05 Leureka I can't be the only one that loses it all the time with the idle Bru'kan emote

I'm coming... I'm coming...
It's mostly the delivery in the style of an old tired man. Sorry for low effort post I had to share.
submitted by Leureka to hearthstone [link] [comments]


2021.12.06 05:05 CondomLeavesARice What gives you a headache?

submitted by CondomLeavesARice to AskReddit [link] [comments]


2021.12.06 05:05 makhiwhites New Binance Coins

Visit for The New Binance Coins. Binance is the best cryptocurrency exchange in the world and it's user base is worldwide across over 182 countries. Binance is also the most used cryptocurrency exchange, it's extremely easy to use and learn. Additionally, you can earn a 20% commission discount on each purchase.
20% Binance Referral Code: T8DGFFIZ
How to Create Binance Account?
Access the site of Binance, which is binance.com. Then, at that point, click on "Register". On the page, enter your telephone number and create a solid secret key for your Binance account. Subsequent to perusing every one of the Terms of Use cautiously, essentially look at the container and snap on "Create Account".
Note: For the wellbeing of the account, make a point to create a secret key of least 8 characters, including 1 number and 1 capitalized character.
Complete the confirmation for your security. You will get a confirmation code on your mail by the framework. Then, at that point, enter the code you got inside 30 minutes. Assuming that you can't track down the code in the inbox of your email, if it's not too much trouble, actually take a look at the other mail inside around 30 minutes. Besides, click on the "Resend Email" with the goal that you can get another code later. Congrats, you have registered on Binance effectively. Now, you can buy binance coins. To help the security of your account, simply click on "Go to Dashboard" to permit two variable validation, including Google confirmation and telephone check.
Funding Your Binance Account
As referenced before, Binance is absolutely a cryptocurrency trade application. This implies that to begin exchanging with Binance, you will be needed to finance your account with some current cryptocurrency.
This should be possible utilizing some other cryptocurrency trade wallet. Just go to your wallet where you have the cryptocurrency put away, select the amount you need to move, and send those assets to your substantial Binance account.
The most awesome aspect of exchanging with computerized monetary standards is that everything occurs in a moment. When you select 'send' from your crypto trade wallet, your Binance account will be supported right away.
If you register with a Binance Referral, it will provide to you 20% discount from your each buying.
submitted by makhiwhites to CryptoOblast [link] [comments]


2021.12.06 05:05 anthonychapman123 Binance Futures Account

The most used and at the same time the most reliable crypto exchange platform is Binance. Also, Binance extremely easy to use and learn. you can EARN A 15% COMMISSION DISCOUNT on each purchase, by registering with a [Binance Futures Account](https://accounts.binance.com/en/register?ref=77181558).

Binance 15% Referral Code: 77181558
submitted by anthonychapman123 to BinancePromoCodes1 [link] [comments]


2021.12.06 05:05 ManIdkWhatToType :D

Hello!
now go post illegal,cringe things or whatever just dont be toxic
submitted by ManIdkWhatToType to FunniCringeThings [link] [comments]


2021.12.06 05:05 AnnaGorlos Each person on this planet owns a different set of teeth, that is why we will introduce you to a product that can give that IDEAL SMILE to every person, regardless what kind of teeth they have. Introducing the PERFECT SMILE SNAP ON BRACES.

Each person on this planet owns a different set of teeth, that is why we will introduce you to a product that can give that IDEAL SMILE to every person, regardless what kind of teeth they have. Introducing the PERFECT SMILE SNAP ON BRACES. submitted by AnnaGorlos to Annaxo [link] [comments]


2021.12.06 05:05 bobbymorris123 Binance Referral Bonus Code

Visit for Binance Referral Bonus Code .The most used and at the same time the most reliable crypto exchange platform is Binance. Also, Binance extremely easy to use and learn, you can earn a 20% commission discount on each purchase.
Binance 20% Sign Up Code: 77181558
How to Register Binance? To make an account with Binance, you should simply get enrolled on the Official Binance Website. On the enrollment page you will be elevated to enter a substantial email address and pick a secret phrase for yourself. When you consent to the Terms and Conditions, you will be approached to check your account by means of email. The email shipped off your given account will contain a connection where you can check your Binance account. When you click on the connection, your Binance account has been made and you are prepared to start exchanging. Yet, before you do, we suggest getting your account through two-factor confirmation. Since exchanging cryptographic money is an expensive and dangerous cycle, it is fundamental for guard your account from any programmers on the web. Binance permits you to set up 2FA and interface your account to your versatile number. This implies that before you can sign in to your Binance account from another gadget, you will be approached to confirm your personality through the telephone number gave.
Funding Your Binance Account As referenced before, Binance is absolutely a cryptocurrency trade application. This implies that to begin exchanging with Binance, you will be needed to finance your account with some current cryptocurrency. This should be possible utilizing some other cryptocurrency trade wallet. Just go to your wallet where you have the cryptocurrency put away, select the amount you need to move, and send those assets to your substantial Binance account. The most awesome aspect of exchanging with computerized monetary standards is that everything occurs in a moment. When you select 'send' from your crypto trade wallet, your Binance account will be supported right away. If you register with a Binance Referral Link, it will provide to you 15% discount from your each buying.
submitted by bobbymorris123 to CryptoFarmer [link] [comments]


2021.12.06 05:05 augustestes Anti Phishing Binance

Visit for Anti Phishing Binance. The most used and at the same time the most reliable crypto exchange platform is Binance. Also, Binance extremely easy to use and learn. You can earn a 20% commission discount on each purchase.
Binance 20% Sign Up Code: 77181558
How to Register Binance? To make an account with Binance, you should simply get enrolled on the Official Binance Website. On the enrollment page you will be elevated to enter a substantial email address and pick a secret phrase for yourself. When you consent to the Terms and Conditions, you will be approached to check your account by means of email. The email shipped off your given account will contain a connection where you can check your Binance account. When you click on the connection, your Binance account has been made and you are prepared to start exchanging. Yet, before you do, we suggest getting your account through two-factor confirmation. Since exchanging cryptographic money is an expensive and dangerous cycle, it is fundamental for guard your account from any programmers on the web. Binance permits you to set up 2FA and interface your account to your versatile number. This implies that before you can sign in to your Binance account from another gadget, you will be approached to confirm your personality through the telephone number gave.
Funding Your Binance Account As referenced before, Binance is absolutely a cryptocurrency trade application. This implies that to begin exchanging with Binance, you will be needed to finance your account with some current cryptocurrency. This should be possible utilizing some other cryptocurrency trade wallet. Just go to your wallet where you have the cryptocurrency put away, select the amount you need to move, and send those assets to your substantial Binance account. The most awesome aspect of exchanging with computerized monetary standards is that everything occurs in a moment. When you select 'send' from your crypto trade wallet, your Binance account will be supported right away. If you register with a Binance Referral Link, it will provide to you 20% discount from your each buying.
submitted by augustestes to BinanceBonusCodes [link] [comments]


2021.12.06 05:05 jeremytaildol Funding Fee Binance

How to register Binance? To make an account with Binance, you should simply get enrolled on the Binance site. On the enrollment page you will be elevated to enter a substantial email address and pick a secret phrase for yourself. When you consent to the Terms and Conditions, you will be approached to check your account by means of email. The email shipped off your given account will contain a connection where you can check your Binance account. When you click on the connection, your Binance account has been made and you are prepared to start exchanging. Yet, before you do, we suggest getting your account through two-factor confirmation. Since exchanging cryptographic money is an expensive and dangerous cycle, it is fundamental for guard your account from any programmers on the web. Binance permits you to set up 2FA and interface your account to your versatile number. This implies that before you can sign in to your Binance account from another gadget, you will be approached to confirm your personality through the telephone number gave. Funding Your Binance Account As referenced before, Binance is absolutely a cryptocurrency trade application. This implies that to begin exchanging with Binance, you will be needed to finance your account with some current cryptocurrency. This should be possible utilizing some other cryptocurrency trade wallet. Just go to your wallet where you have the cryptocurrency put away, select the amount you need to move, and send those assets to your substantial Binance account. The most awesome aspect of exchanging with computerized monetary standards is that everything occurs in a moment. When you select 'send' from your crypto trade wallet, your Binance account will be supported right away. If you register with Binance Referral Link, it will provide to you 15% discount from your each buying. , it will provide to you 15% discount from your each buying. How to register Binance?
To make an account with Binance, you should simply get enrolled on the [Binance site](https://accounts.binance.com/en/register?ref=77181558). On the enrollment page you will be elevated to enter a substantial email address and pick a secret phrase for yourself. When you consent to the Terms and Conditions, you will be approached to check your account by means of email.
The email shipped off your given account will contain a connection where you can check your Binance account. When you click on the connection, your Binance account has been made and you are prepared to start exchanging.
Yet, before you do, we suggest getting your account through two-factor confirmation. Since exchanging cryptographic money is an expensive and dangerous cycle, it is fundamental for guard your account from any programmers on the web. Binance permits you to set up 2FA and interface your account to your versatile number. This implies that before you can sign in to your Binance account from another gadget, you will be approached to confirm your personality through the telephone number gave.
Funding Your Binance Account
As referenced before, Binance is absolutely a cryptocurrency trade application. This implies that to begin exchanging with Binance, you will be needed to finance your account with some current cryptocurrency.
This should be possible utilizing some other cryptocurrency trade wallet. Just go to your wallet where you have the cryptocurrency put away, select the amount you need to move, and send those assets to your substantial Binance account.
The most awesome aspect of exchanging with computerized monetary standards is that everything occurs in a moment. When you select 'send' from your crypto trade wallet, your Binance account will be supported right away.
If you register with [Binance Referral Link](https://accounts.binance.com/en/register?ref=77181558), it will provide to you 15% discount from your each buying. , it will provide to you 15% discount from your each buying.
submitted by jeremytaildol to BinanceRegister [link] [comments]


http://v-noske.ru