eulertest.py 4.34 KB
Newer Older
 Nayuki Minase committed Jul 26, 2015 1 2 ``````# # Test suite for Project Euler all Python solutions `````` Nayuki committed Dec 27, 2016 3 ``````# Copyright (c) Project Nayuki. All rights reserved. `````` Nayuki Minase committed Jul 26, 2015 4 ``````# `````` Nayuki Minase committed Feb 05, 2016 5 ``````# https://www.nayuki.io/page/project-euler-solutions `````` Nayuki Minase committed Jul 26, 2015 6 7 8 ``````# https://github.com/nayuki/Project-Euler-solutions # `````` Nayuki Minase committed Jul 22, 2015 9 10 11 12 ``````import importlib, time def main(): `````` 13 `````` totaltime = 0.0 # In seconds `````` Nayuki Minase committed Jul 22, 2015 14 15 16 `````` for (prob, expectans) in sorted(ANSWERS.items()): module = importlib.import_module("p{:03d}".format(prob)) starttime = time.time() `````` 17 `````` actualans = module.compute() # Must return a string `````` Nayuki Minase committed Jul 22, 2015 18 `````` elapsedtime = time.time() - starttime `````` Nayuki Minase committed Jul 22, 2015 19 `````` totaltime += elapsedtime `````` 20 21 22 `````` print("Problem {:03d}: {:7d} ms{}".format( prob, int(round(elapsedtime * 1000)), "" if actualans == expectans else " *** FAIL ***")) `````` Nayuki Minase committed Aug 13, 2015 23 `````` print("Total computation time: {} ms".format(int(round(totaltime * 1000)))) `````` Nayuki Minase committed Jul 22, 2015 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 `````` ANSWERS = { 1: "233168", 2: "4613732", 3: "6857", 4: "906609", 5: "232792560", 6: "25164150", 7: "104743", 8: "23514624000", 9: "31875000", 10: "142913828922", 11: "70600674", 12: "76576500", 13: "5537376230", 14: "837799", 15: "137846528820", 16: "1366", 17: "21124", 18: "1074", 19: "171", 20: "648", 21: "31626", 22: "871198282", 23: "4179871", 24: "2783915460", 25: "4782", 26: "983", 27: "-59231", 28: "669171001", 29: "9183", 30: "443839", 31: "73682", 32: "45228", 33: "100", 34: "40730", 35: "55", 36: "872187", 37: "748317", 38: "932718654", 39: "840", 40: "210", `````` Nayuki Minase committed Jul 23, 2015 67 68 69 `````` 41: "7652413", 42: "162", 43: "16695334890", `````` Nayuki Minase committed Dec 09, 2015 70 `````` 44: "5482660", `````` Nayuki Minase committed Jul 23, 2015 71 72 73 74 `````` 45: "1533776805", 46: "5777", 47: "134043", 48: "9110846700", `````` Nayuki Minase committed Dec 09, 2015 75 `````` 49: "296962999629", `````` Nayuki Minase committed Jul 23, 2015 76 `````` 50: "997651", `````` Nayuki Minase committed Feb 21, 2016 77 `````` 51: "121313", `````` Nayuki Minase committed Jul 23, 2015 78 79 `````` 52: "142857", 53: "4075", `````` 80 `````` 54: "376", `````` Nayuki Minase committed Jul 23, 2015 81 82 83 `````` 55: "249", 56: "972", 57: "153", `````` Nayuki Minase committed Jul 24, 2015 84 `````` 58: "26241", `````` Nayuki Minase committed Sep 18, 2015 85 `````` 59: "107359", `````` Nayuki committed Dec 26, 2016 86 `````` 60: "26033", `````` Nayuki Minase committed Feb 24, 2016 87 `````` 61: "28684", `````` Nayuki Minase committed Feb 19, 2016 88 `````` 62: "127035954683", `````` Nayuki Minase committed Jul 24, 2015 89 `````` 63: "49", `````` Nayuki committed Oct 11, 2016 90 `````` 64: "1322", `````` Nayuki Minase committed Jul 24, 2015 91 `````` 65: "272", `````` Nayuki committed Oct 11, 2016 92 `````` 66: "661", `````` Nayuki Minase committed Jul 24, 2015 93 `````` 67: "7273", `````` Nayuki Minase committed Feb 19, 2016 94 `````` 68: "6531031914842725", `````` Nayuki Minase committed Jul 26, 2015 95 96 97 98 `````` 69: "510510", 70: "8319823", 71: "428570", 72: "303963552391", `````` Nayuki Minase committed Feb 19, 2016 99 100 101 `````` 73: "7295372", 74: "402", 75: "161667", `````` Nayuki Minase committed Jul 26, 2015 102 103 `````` 76: "190569291", 77: "71", `````` Nayuki Minase committed Feb 20, 2016 104 105 `````` 78: "55374", 79: "73162890", `````` Nayuki Minase committed Jul 26, 2015 106 107 `````` 80: "40886", 81: "427337", `````` Nayuki Minase committed Feb 20, 2016 108 109 `````` 82: "260324", 83: "425185", `````` Nayuki committed Dec 26, 2016 110 `````` 84: "101524", `````` Nayuki Minase committed Jul 26, 2015 111 `````` 85: "2772", `````` Nayuki committed Dec 26, 2016 112 `````` 86: "1818", `````` Nayuki Minase committed Feb 20, 2016 113 `````` 87: "1097343", `````` Nayuki committed Oct 11, 2016 114 `````` 88: "7587457", `````` 115 `````` 89: "743", `````` Nayuki Minase committed Feb 22, 2016 116 `````` 90: "1217", `````` 117 118 `````` 91: "14234", 92: "8581146", `````` Nayuki committed Dec 26, 2016 119 `````` 93: "1258", `````` Nayuki committed Oct 11, 2016 120 `````` 94: "518408346", `````` Nayuki committed Dec 26, 2016 121 `````` 95: "14316", `````` Nayuki Minase committed Aug 21, 2015 122 `````` 96: "24702", `````` 123 `````` 97: "8739992577", `````` Nayuki committed Dec 26, 2016 124 `````` 98: "18769", `````` Nayuki committed Oct 11, 2016 125 `````` 99: "709", `````` Nayuki committed Oct 11, 2016 126 `````` 100: "756872327473", `````` Nayuki Minase committed Dec 09, 2015 127 `````` 101: "37076114526", `````` 128 `````` 102: "228", `````` Nayuki committed Mar 08, 2018 129 `````` 103: "20313839404245", `````` 130 `````` 104: "329468", `````` Nayuki committed Oct 11, 2016 131 `````` 105: "73702", `````` Nayuki committed Mar 09, 2018 132 `````` 106: "21384", `````` Nayuki committed Dec 26, 2016 133 `````` 107: "259679", `````` Nayuki Minase committed Feb 21, 2016 134 135 `````` 108: "180180", 109: "38182", `````` Nayuki committed Dec 26, 2016 136 `````` 111: "612407567715", `````` 137 138 139 140 141 142 `````` 112: "1587000", 113: "51161058134250", 114: "16475640049", 115: "168", 116: "20492570929", 117: "100808458960497", `````` Nayuki committed Oct 11, 2016 143 `````` 118: "44680", `````` Nayuki Minase committed Feb 21, 2016 144 `````` 119: "248155780267521", `````` Nayuki Minase committed Jul 28, 2015 145 `````` 120: "333082500", `````` Nayuki Minase committed Feb 22, 2016 146 147 `````` 121: "2269", 122: "1582", `````` Nayuki Minase committed Jul 28, 2015 148 149 `````` 123: "21035", 124: "21417", `````` Nayuki Minase committed Feb 22, 2016 150 151 `````` 125: "2906969179", 127: "18407904", `````` Nayuki Minase committed Jul 28, 2015 152 153 `````` 128: "14516824220", 129: "1000023", `````` Nayuki Minase committed Aug 12, 2015 154 `````` 130: "149253", `````` Nayuki Minase committed Jul 28, 2015 155 156 `````` 132: "843296", 133: "453647705", `````` Nayuki Minase committed Aug 12, 2015 157 158 `````` 134: "18613426663617118", 135: "4989", `````` Nayuki committed Oct 22, 2016 159 `````` 139: "10057761", `````` Nayuki committed Oct 11, 2016 160 `````` 142: "1006193", `````` Nayuki committed Jun 25, 2016 161 `````` 145: "608720", `````` Nayuki committed Dec 26, 2016 162 `````` 146: "676333270", `````` Nayuki Minase committed Feb 22, 2016 163 `````` 149: "52852124", `````` Nayuki Minase committed Aug 12, 2015 164 165 `````` 150: "-271248680", 151: "0.464399", `````` 166 `````` 155: "3857447", `````` Nayuki Minase committed Aug 11, 2015 167 168 169 `````` 160: "16576", 162: "3D58725572C62302", 164: "378158756814587", `````` Nayuki Minase committed Feb 22, 2016 170 `````` 166: "7130034", `````` Nayuki Minase committed Aug 11, 2015 171 `````` 169: "178653872807", `````` Nayuki Minase committed Aug 19, 2015 172 `````` 171: "142989277", `````` Nayuki committed Oct 11, 2016 173 `````` 172: "227485267000992000", `````` Nayuki Minase committed Aug 11, 2015 174 `````` 173: "1572729", `````` Nayuki Minase committed Aug 12, 2015 175 `````` 174: "209566", `````` Nayuki committed Jul 11, 2017 176 `````` 178: "126461847755", `````` Nayuki Minase committed Aug 19, 2015 177 `````` 179: "986262", `````` Nayuki Minase committed Aug 12, 2015 178 `````` 182: "399788195976", `````` Nayuki Minase committed Dec 15, 2015 179 `````` 186: "2325629", `````` Nayuki Minase committed Feb 22, 2016 180 `````` 187: "17427258", `````` Nayuki Minase committed Aug 11, 2015 181 182 `````` 188: "95962097", 191: "1918080160", `````` Nayuki Minase committed Aug 11, 2015 183 `````` 197: "1.710637717", `````` Nayuki Minase committed Feb 22, 2016 184 185 `````` 203: "34029210557338", 204: "2944730", `````` Nayuki Minase committed Aug 11, 2015 186 `````` 205: "0.5731441", `````` Nayuki committed Dec 26, 2016 187 `````` 206: "1389019170", `````` Nayuki committed Jul 01, 2017 188 `````` 208: "331951449665644800", `````` Nayuki committed Dec 26, 2016 189 `````` 211: "1922364685", `````` Nayuki Minase committed Feb 22, 2016 190 `````` 214: "1677366278943", `````` Nayuki committed Oct 22, 2016 191 `````` 215: "806844323190414", `````` Nayuki Minase committed Dec 10, 2015 192 `````` 216: "5437849", `````` 193 `````` 218: "0", `````` Nayuki committed Dec 26, 2016 194 `````` 222: "1590933", `````` Nayuki Minase committed Aug 12, 2015 195 `````` 225: "2009", `````` Nayuki Minase committed Feb 22, 2016 196 197 `````` 231: "7526965179680", 243: "892371480", `````` Nayuki Minase committed Aug 25, 2015 198 `````` 249: "9275262564250418", `````` Nayuki Minase committed Jul 28, 2015 199 `````` 250: "1425480602091519", `````` Nayuki committed Dec 26, 2016 200 `````` 265: "209110240768", `````` Nayuki Minase committed Aug 13, 2015 201 `````` 267: "0.999992836187", `````` Nayuki committed Sep 11, 2016 202 `````` 271: "4617456485273129588", `````` Nayuki committed Jul 13, 2017 203 `````` 280: "430.088247", `````` Nayuki committed Oct 30, 2017 204 `````` 287: "313135496", `````` Nayuki Minase committed Jul 28, 2015 205 `````` 301: "2178309", `````` Nayuki committed Sep 11, 2016 206 `````` 303: "1111981904675169", `````` Nayuki committed Dec 26, 2016 207 `````` 304: "283988410192", `````` Nayuki Minase committed Sep 29, 2015 208 `````` 315: "13625242", `````` Nayuki Minase committed Aug 11, 2015 209 `````` 323: "6.3551758451", `````` Nayuki committed Jul 13, 2017 210 `````` 329: "199740353/29386561536000", `````` Nayuki committed Sep 11, 2016 211 `````` 345: "13938", `````` Nayuki committed Dec 25, 2016 212 `````` 346: "336108797689259276", `````` Nayuki committed Oct 22, 2016 213 `````` 347: "11109800204052", `````` Nayuki committed Jul 12, 2017 214 `````` 348: "1004195061", `````` Nayuki committed Sep 11, 2016 215 `````` 357: "1739023853137", `````` Nayuki Minase committed Aug 11, 2015 216 `````` 381: "139602943319822", `````` Nayuki Minase committed Sep 29, 2015 217 `````` 387: "696067597313468", `````` Nayuki Minase committed Sep 29, 2015 218 `````` 401: "281632621", `````` Nayuki committed Dec 26, 2016 219 `````` 407: "39782849136421", `````` Nayuki committed Dec 26, 2016 220 `````` 425: "46479497324", `````` Nayuki Minase committed Jul 28, 2015 221 `````` 429: "98792821", `````` Nayuki committed Jul 03, 2017 222 `````` 451: "153651073760956", `````` Nayuki committed Oct 22, 2016 223 `````` 493: "6.818741802", `````` Nayuki committed May 12, 2017 224 `````` 500: "35407281", `````` Nayuki committed Dec 26, 2016 225 `````` 518: "100315739184392", `````` Nayuki committed Dec 25, 2016 226 `````` 549: "476001479068717", `````` Nayuki committed Jul 12, 2017 227 `````` 587: "2240", `````` Nayuki Minase committed Jul 22, 2015 228 229 230 231 232 ``````} if __name__ == "__main__": main()``````