Today's challenge was harder than previous day's.
adj = [(i,j) for i in range(-1, 2) for j in range(-1,2) if i!=0 or j!=0]
window = {(i,j):darr[i][j] for i in range(10) for j in range(10)}
flashes = 0
i=0
previous = set()
while len(previous)<len(window):
previous = set()
window = {k:v+1 for k, v in window.items()}
while True:
if sum(v>9 for k,v in window.items() if k not in previous)==0:
break
for k,v in window.items():
if k not in previous and v>9:
previous.add(k)
for ad in [(k[0]+i,k[1]+j) for i,j in adj if (k[0]+i,k[1]+j) in window]:
window[ad]+=1
flashes+=len(previous)
window.update({k:0 for k in previous})
i+=1
if i==100:
print(f"Part 1: {flashes}")
print(f"Part 2: {i}")
Why not read more?
- Gesture Based Visually Writing System Using OpenCV and Python
- Gesture Based Visually Writing System: Adding Visual User Interface
- Gesture Based Visually Writing System: Adding Virtual Animationn, New Mode and New VUI
- Gesture Based Visually Writing System: Add Slider, More Colors and Optimized OOP code
- Gesture Based Visually Writing System: A Web App
- Contour Based Game: Break The Bricks
- Linear Regression from Scratch
- Writing Popular ML Optimizers from Scratch
- Feed Forward Neural Network from Scratch
- Convolutional Neural Networks from Scratch
- Writing a Simple Image Processing Class from Scratch
- Deploying a RASA Chatbot on Android using Unity3d
- Naive Bayes for text classifications: Scratch to Framework
- Simple OCR for Devanagari Handwritten Text
Top comments (0)