i love advent of code, you can compare yourself with others and you can also see how others have solved it and thus learn new features of a programming language
And for the second art of Day 1: #!/usr/bin/env python3 from collections import Counter filename = "input.txt" def similarity(filename) -> int: """Calculates sum of common elements * counts in 2nd list.""" a_list = [] b_list = [] with open(filename, "r") as file: for line in file: x, y = map(int, line.split()) a_list.append(x) b_list.append(y) a_list.sort() b_list.sort() a_set = set(a_list) b_set = set(b_list) common_elements = a_set.intersection(b_set) b_counts = Counter(b_list) return sum(key * b_counts[key] for key in common_elements) print(similarity(filename))
Thanks for sharing, well explained! I noticed that most people solve the advent of code using python, is there a reason why you didn't prefer javascript or java?
Difficult to understand the solution. In the text they write about two lists. Your code reads a file. Where does the file come from? Why not two files for two lists? They should write more precise descriptions instead of christmas stories.
@@Miguel-y4o Realmente, realmente, embora seja agradável pra quem esteja cansado ou só com não muita paciência mesmo pra acompanhar legendas no momento… a incompetência do TH-cam (que só sabe pensar em forma de enfiar anúncio no nosso rabo) demorou pra colocar sinceramente. 😔
my solution: filename="./input" file=open(filename, "r").readlines() list1=list() list2=list() for line in file: line=line.replace(" ", "").split() list1.append(int(line[0])) list2.append(int(line[1])) def partOne(): myList1=sorted(list1) myList2=sorted(list2) distances=list() for index in range(len(myList1)): distances.append(abs(myList1[index]-myList2[index])) print(sum(distances)) def partTwo(): frequenz_map = dict() for item in list2: if not frequenz_map.keys().__contains__(item): frequenz_map.update({item:1}) else: frequenz_map.update({item: frequenz_map.get(item)+1}) summe=list() for item in list1: if frequenz_map.get(item)!=None: summe.append(item*frequenz_map.get(item)) print(sum(summe)) partOne() partTwo() do you have any suggestions for improvement?
I think we should begin a programming competition. This lady is something else when it comes to programming
Hahah thanks so much!
i love advent of code, you can compare yourself with others and you can also see how others have solved it and thus learn new features of a programming language
this is a great way to see what other's solutions are like
Cool challenge! All the best for deadline as well, Jackie!
Thank you so much
Thanks Jackie, you are great. Loved listening to this while I ate some food hehe
Thank you for challenging us to code with you. 😀
Great video ! I loved it !
Thank you!! 😊
Woww brains and beuty. Very well.
hahah, wow thanks i'm flattered!
Good work Jackie. Would request you to make a video on regular task ETA estimation
That’s a tough one! I’m terrible at estimating 😄
Great solution, lady 🎉
Thank you 🥳
Nice challenge 😊 Merry Christmas 🎁🎄
Thank you ♥️ merry Christmas! 🎁
interesting using a hash map. I did it a different way
How did you do it? 🙌
And for the second art of Day 1:
#!/usr/bin/env python3
from collections import Counter
filename = "input.txt"
def similarity(filename) -> int:
"""Calculates sum of common elements * counts in 2nd list."""
a_list = []
b_list = []
with open(filename, "r") as file:
for line in file:
x, y = map(int, line.split())
a_list.append(x)
b_list.append(y)
a_list.sort()
b_list.sort()
a_set = set(a_list)
b_set = set(b_list)
common_elements = a_set.intersection(b_set)
b_counts = Counter(b_list)
return sum(key * b_counts[key] for key in common_elements)
print(similarity(filename))
She is very smart! 😮
Happy New Year!
A bit early but thank you, I hope you have a lovely holiday season and a great year ahead 🥳
nice, let's try doing it in C without libraries!
😭 pls no
@@CSJackie I am doing that to myself this year. Still haven't finished day 1 xD
Thanks for sharing, well explained! I noticed that most people solve the advent of code using python, is there a reason why you didn't prefer javascript or java?
❤
♥️♥️
btw i use arch
you're superior
wait aren't you Drew Gooden's wife, the youtuber guy
haha i'm afraid not
essa tradução pra br não tem como.
Second comment😢
helloo
Difficult to understand the solution. In the text they write about two lists. Your code reads a file. Where does the file come from? Why not two files for two lists? They should write more precise descriptions instead of christmas stories.
woow muy bien en español
Hehe ☺️
Omg how can I turn off this AI voice over?
Change language in account settings
Omg, you hit me on brazil, I really was expecting in english audio and I suprised by portuguese audio, you are outlier hahah xDD
I think TH-cam must be doing this automatically - I filmed in English ☺️
Essa nova feature tá salvando demais que não curte ver legenda.
@@heeloheelo32 mano, demais, agora fica tudo mais acessível, porém deixa acomodado pra aprender ingles hahah
@@Miguel-y4o Realmente, realmente, embora seja agradável pra quem esteja cansado ou só com não muita paciência mesmo pra acompanhar legendas no momento… a incompetência do TH-cam (que só sabe pensar em forma de enfiar anúncio no nosso rabo) demorou pra colocar sinceramente. 😔
Ame que fuera en Español!!! ❤
my solution:
filename="./input"
file=open(filename, "r").readlines()
list1=list()
list2=list()
for line in file:
line=line.replace("
", "").split()
list1.append(int(line[0]))
list2.append(int(line[1]))
def partOne():
myList1=sorted(list1)
myList2=sorted(list2)
distances=list()
for index in range(len(myList1)):
distances.append(abs(myList1[index]-myList2[index]))
print(sum(distances))
def partTwo():
frequenz_map = dict()
for item in list2:
if not frequenz_map.keys().__contains__(item):
frequenz_map.update({item:1})
else:
frequenz_map.update({item: frequenz_map.get(item)+1})
summe=list()
for item in list1:
if frequenz_map.get(item)!=None:
summe.append(item*frequenz_map.get(item))
print(sum(summe))
partOne()
partTwo()
do you have any suggestions for improvement?
Looks good 👌
I am using Linux 🐧
I use Arch, btw.
Me too
oldschool
Mam do you earn 130k pound sterlings a year in uk now? Please reply in yes or no. Thanks a lot.
Love the three 🤩🚥🚦 good luck with your deadline 😊
Thank you so much ☺️ !