Skip to content
/ AOC_2021 Public

My solution of problems from Advent of Code in 2021

License

Notifications You must be signed in to change notification settings

LXZE/AOC_2021

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LXZE's 2021 Advent of Code solutions

This repository is dedicated to archiving my solutions for questions in Advent of Code 2021, separating each question to each folder by its released date.

Read it at your own risk.

Note

  • Day 15
     G = nx.Graph()
     h, w = len(maps), len(maps[0])
     for r in range(h):
     	for c in range(w):
     		for e in list(filter(
     			lambda p: 0 <= p[0] < h and 0 <= p[1] < w,
     			[(r-1, c), (r+1, c), (r, c-1), (r, c+1)]
     		)): G.add_edge((r, c), e)
     # check weight here instead of assign while adding edge
     weight_func = lambda u,v,d: maps[v[0]][v[1]]
     res = nx.dijkstra_path(G, (0, 0), (h-1, w-1), weight=weight_func)
     print(reduce(lambda acc, p: acc+maps[p[0]][p[1]], res[1:], 0))

About

My solution of problems from Advent of Code in 2021

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages