Parcourir la source

Permuted multiples

Adel Qalieh il y a 13 ans
Parent
commit
8cf7aaa3ea
1 fichiers modifiés avec 27 ajouts et 0 suppressions
  1. 27 0
      52.py

+ 27 - 0
52.py

@@ -0,0 +1,27 @@
+def numhash(num):
+	num = str(num)
+	digithash = {0:0, 1:0, 2:0, 3:0, 4:0, 5:0, 6:0, 7:0, 8:0, 9:0}
+	for digit in num:
+		digithash[int(digit)] += 1
+	return digithash
+
+i = 1
+while True:
+	spechash = numhash(i)
+	if spechash == numhash(2*i):
+		if spechash == numhash(3*i):
+			if spechash == numhash(4*i):
+				if spechash == numhash(5*i):
+					if spechash == numhash(6*i):
+						print(i)
+						break
+					else:
+						i+=1
+				else:
+					i+=1
+			else:
+				i+=1
+		else:
+			i+=1
+	else:
+		i += 1