/aoc/ Advent Of Code 2023
https://adventofcode.com/2023import re
sum = 0
i = 1
spellednumbers = [['zero', '0'], ['one', '1'], ['two', '2'], ['three', '3'], ['four', '4'], ['five', '5'], ['six', '6'], ['seven','7'], ['eight', '8'], ['nine', '9']]
numberRegex = r'\d|one|two|three|four|five|six|seven|eight|nine'
with open('input.txt') as inputFile:
f = open("output1.txt", "w")
for line in inputFile:
matchBuffer = []
#start regex pattern matching, if we find a spelled digit we check if it overlaps with another
for match in re.finditer(numberRegex, line):
s = match.start()
e = match.end()
matchBuffer.append(line[s:e])
if line[s:e].isnumeric() == False:
for spelledNumber in spellednumbers:
number = spelledNumber[0]
overlappingIndex = e - 1
overlapped = line.find(number, overlappingIndex, overlappingIndex + len(number))
if overlapped != -1:
#we found overlapping digit, add it to buffer
sub = line[overlapped:overlapped + len(number)]
matchBuffer.append(sub)
break
firstDig = matchBuffer[0]
secondDig = matchBuffer[len(matchBuffer) - 1]
#find numeric value for first digit
for index, number in enumerate(spellednumbers):
if firstDig in number:
firstDig = str(index)
break
#find numeric value for second digit
for index, number in enumerate(spellednumbers):
if secondDig in number:
secondDig = str(index)
break
result = firstDig + secondDig
sum+=int(result)
i+=1
f.write("["+ line.strip() + "] -> " + str(matchBuffer) + " -> " + result + "\n")
f.write("sum of calibration values: " + str(sum))
f.close()
švytnegriai puola
https://notes.valdikss.org.ru/jabber.ru-mitm/Ritmo žaidimų tema
Sveiki, įdomu būtų sužinoti ar kas čionge žaidžia/žaidė bet kokio stiliaus ritminius žaidimus, aišku tikimybė maža, bet gal prie to paties kažkam iš jūsų užkibs.NVIDIA išleidžia atvirojo kodo GPU kernel modulius
>https://developer.nvidia.com/blog/nvidia-releases-open-source-gpu-kernel-modules/