Initial commit

This commit is contained in:
2020-06-21 23:53:32 +02:00
commit 7ca64a7a82
67 changed files with 1698 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
import csv
import math
with open('42.txt') as file:
reader = csv.reader(file, delimiter=",", quotechar='"')
words = list(reader)[0]
def wordValue(n):
return sum([ord(i.lower())-96 for i in n])
def triangleBase(n):
return (math.sqrt(8*n+1)-1)/2
result = 0
for i in words:
n = wordValue(i)
if triangleBase(n).is_integer():
result+=1
print(result)
#inverse triangle: (sqrt(8*n+1)-1)/2