forked from freeCodeCamp/freeCodeCamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproject-euler-problems.json
4033 lines (4032 loc) · 169 KB
/
project-euler-problems.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
[
{
"id": "5900f54d1000cf542c510060",
"challengeType": 5,
"type": "bonfire",
"title": "Problem 481: Chef Showdown",
"tests": [
"assert.strictEqual(euler481(), TODO: MISSING ANSWER, 'message: <code>euler481()</code> should return TODO: MISSING ANSWER.');"
],
"solutions": [],
"translations": {},
"challengeSeed": [
"function euler481() {",
" // Good luck!",
" return true;",
"}",
"",
"euler481();"
],
"description": [
"A group of chefs (numbered #1, #2, etc) participate in a turn-based strategic cooking competition. On each chef's turn, he/she cooks up a dish to the best of his/her ability and gives it to a separate panel of judges for taste-testing. Let S(k) represent chef #k's skill level (which is publicly known). More specifically, S(k) is the probability that chef #k's dish will be assessed favorably by the judges (on any/all turns). If the dish receives a favorable rating, then the chef must choose one other chef to be eliminated from the competition. The last chef remaining in the competition is the winner.",
"",
"The game always begins with chef #1, with the turn order iterating sequentially over the rest of the chefs still in play. Then the cycle repeats from the lowest-numbered chef. All chefs aim to optimize their chances of winning within the rules as stated, assuming that the other chefs behave in the same manner. In the event that a chef has more than one equally-optimal elimination choice, assume that the chosen chef is always the one with the next-closest turn.",
"",
"Define Wn(k) as the probability that chef #k wins in a competition with n chefs. If we have S(1) = 0.25, S(2) = 0.5, and S(3) = 1, then W3(1) = 0.29375.",
"",
"Going forward, we assign S(k) = Fk/Fn+1 over all 1 ≤ k ≤ n, where Fk is a Fibonacci number: Fk = Fk-1 + Fk-2 with base cases F1 = F2 = 1. Then, for example, when considering a competition with n = 7 chefs, we have W7(1) = 0.08965042, W7(2) = 0.20775702, W7(3) = 0.15291406, W7(4) = 0.14554098, W7(5) = 0.15905291, W7(6) = 0.10261412, and W7(7) = 0.14247050, rounded to 8 decimal places each.",
"",
"Let E(n) represent the expected number of dishes cooked in a competition with n chefs. For instance, E(7) = 42.28176050.",
"",
"Find E(14) rounded to 8 decimal places."
]
},
{
"id": "5900f54f1000cf542c510061",
"challengeType": 5,
"type": "bonfire",
"title": "Problem 482: The incenter of a triangle",
"tests": [
"assert.strictEqual(euler482(), TODO: MISSING ANSWER, 'message: <code>euler482()</code> should return TODO: MISSING ANSWER.');"
],
"solutions": [],
"translations": {},
"challengeSeed": [
"function euler482() {",
" // Good luck!",
" return true;",
"}",
"",
"euler482();"
],
"description": [
"ABC is an integer sided triangle with incenter I and perimeter p.",
"The segments IA, IB and IC have integral length as well. ",
"",
"",
"Let L = p + |IA| + |IB| + |IC|. ",
"",
"",
"Let S(P) = ∑L for all such triangles where p ≤ P. For example, S(103) = 3619.",
"",
"",
"Find S(107)."
]
},
{
"id": "5900f54f1000cf542c510062",
"challengeType": 5,
"type": "bonfire",
"title": "Problem 483: Repeated permutation",
"tests": [
"assert.strictEqual(euler483(), TODO: MISSING ANSWER, 'message: <code>euler483()</code> should return TODO: MISSING ANSWER.');"
],
"solutions": [],
"translations": {},
"challengeSeed": [
"function euler483() {",
" // Good luck!",
" return true;",
"}",
"",
"euler483();"
],
"description": [
"We define a permutation as an operation that rearranges the order of the elements {1, 2, 3, ..., n}.",
"There are n! such permutations, one of which leaves the elements in their initial order.",
"For n = 3 we have 3! = 6 permutations:",
"- P1 = keep the initial order",
"- P2 = exchange the 1st and 2nd elements",
"- P3 = exchange the 1st and 3rd elements",
"- P4 = exchange the 2nd and 3rd elements",
"- P5 = rotate the elements to the right",
"- P6 = rotate the elements to the left",
"",
"",
"If we select one of these permutations, and we re-apply the same permutation repeatedly, we eventually restore the initial order.For a permutation Pi, let f(Pi) be the number of steps required to restore the initial order by applying the permutation Pi repeatedly.For n = 3, we obtain:- f(P1) = 1 : (1,2,3) → (1,2,3)- f(P2) = 2 : (1,2,3) → (2,1,3) → (1,2,3)- f(P3) = 2 : (1,2,3) → (3,2,1) → (1,2,3)- f(P4) = 2 : (1,2,3) → (1,3,2) → (1,2,3)- f(P5) = 3 : (1,2,3) → (3,1,2) → (2,3,1) → (1,2,3)- f(P6) = 3 : (1,2,3) → (2,3,1) → (3,1,2) → (1,2,3)",
"",
"",
"Let g(n) be the average value of f2(Pi) over all permutations Pi of length n.g(3) = (12 + 22 + 22 + 22 + 32 + 32)/3! = 31/6 ≈ 5.166666667e0g(5) = 2081/120 ≈ 1.734166667e1g(20) = 12422728886023769167301/2432902008176640000 ≈ 5.106136147e3",
"",
"",
"Find g(350) and write the answer in scientific notation rounded to 10 significant digits, using a lowercase e to separate mantissa and exponent, as in the examples above."
]
},
{
"id": "5900f5501000cf542c510063",
"challengeType": 5,
"type": "bonfire",
"title": "Problem 484: Arithmetic Derivative",
"tests": [
"assert.strictEqual(euler484(), TODO: MISSING ANSWER, 'message: <code>euler484()</code> should return TODO: MISSING ANSWER.');"
],
"solutions": [],
"translations": {},
"challengeSeed": [
"function euler484() {",
" // Good luck!",
" return true;",
"}",
"",
"euler484();"
],
"description": [
"The arithmetic derivative is defined by",
"p' = 1 for any prime p",
"(ab)' = a'b + ab' for all integers a, b (Leibniz rule)",
"For example, 20' = 24",
"",
"Find ∑ gcd(k,k') for 1 < k ≤ 5·1015",
"",
"Note: gcd(x,y) denotes the greatest common divisor of x and y."
]
},
{
"id": "5900f5511000cf542c510064",
"challengeType": 5,
"type": "bonfire",
"title": "Problem 485: Maximum number of divisors",
"tests": [
"assert.strictEqual(euler485(), 51281274340, 'message: <code>euler485()</code> should return 51281274340.');"
],
"solutions": [],
"translations": {},
"challengeSeed": [
"function euler485() {",
" // Good luck!",
" return true;",
"}",
"",
"euler485();"
],
"description": [
"Let d(n) be the number of divisors of n.",
"Let M(n,k) be the maximum value of d(j) for n ≤ j ≤ n+k-1.",
"Let S(u,k) be the sum of M(n,k) for 1 ≤ n ≤ u-k+1.",
"",
"",
"You are given that S(1000,10)=17176.",
"",
"",
"Find S(100 000 000,100 000)."
]
},
{
"id": "5900f5531000cf542c510065",
"challengeType": 5,
"type": "bonfire",
"title": "Problem 486: Palindrome-containing strings",
"tests": [
"assert.strictEqual(euler486(), 11408450515, 'message: <code>euler486()</code> should return 11408450515.');"
],
"solutions": [],
"translations": {},
"challengeSeed": [
"function euler486() {",
" // Good luck!",
" return true;",
"}",
"",
"euler486();"
],
"description": [
"Let F5(n) be the number of strings s such that:",
"s consists only of '0's and '1's,",
"s has length at most n, and",
"s contains a palindromic substring of length at least 5.",
"For example, F5(4) = 0, F5(5) = 8, ",
"F5(6) = 42 and F5(11) = 3844.",
"",
"Let D(L) be the number of integers n such that ",
"5 ≤ n ≤ L and F5(n) is divisible by 87654321.",
"",
"For example, D(107) = 0 and D(5·109) = 51.",
"",
"Find D(1018)."
]
},
{
"id": "5900f5531000cf542c510066",
"challengeType": 5,
"type": "bonfire",
"title": "Problem 487: Sums of power sums",
"tests": [
"assert.strictEqual(euler487(), 106650212746, 'message: <code>euler487()</code> should return 106650212746.');"
],
"solutions": [],
"translations": {},
"challengeSeed": [
"function euler487() {",
" // Good luck!",
" return true;",
"}",
"",
"euler487();"
],
"description": [
"Let fk(n) be the sum of the kth powers of the first n positive integers.",
"",
"For example, f2(10) = 12 + 22 + 32 + 42 + 52 + 62 + 72 + 82 + 92 + 102 = 385.",
"",
"Let Sk(n) be the sum of fk(i) for 1 ≤ i ≤ n. For example, S4(100) = 35375333830.",
"",
"What is ∑ (S10000(1012) mod p) over all primes p between 2 ⋅ 109 and 2 ⋅ 109 + 2000?"
]
},
{
"id": "5900f5541000cf542c510067",
"challengeType": 5,
"type": "bonfire",
"title": "Problem 488: Unbalanced Nim",
"tests": [
"assert.strictEqual(euler488(), TODO: MISSING ANSWER, 'message: <code>euler488()</code> should return TODO: MISSING ANSWER.');"
],
"solutions": [],
"translations": {},
"challengeSeed": [
"function euler488() {",
" // Good luck!",
" return true;",
"}",
"",
"euler488();"
],
"description": [
"Alice and Bob have enjoyed playing Nim every day. However, they finally got bored of playing ordinary three-heap Nim.",
"So, they added an extra rule:",
"",
"- Must not make two heaps of the same size.",
"",
"The triple (a,b,c) indicates the size of three heaps.",
"Under this extra rule, (2,4,5) is one of the losing positions for the next player.",
"",
"To illustrate:",
"- Alice moves to (2,4,3)",
"- Bob moves to (0,4,3)",
"- Alice moves to (0,2,3)",
"- Bob moves to (0,2,1)",
"",
"Unlike ordinary three-heap Nim, (0,1,2) and its permutations are the end states of this game.",
"",
"For an integer N, we define F(N) as the sum of a+b+c for all the losing positions for the next player, with 0 < a < b < c < N.",
"",
"For example, F(8) = 42, because there are 4 losing positions for the next player, (1,3,5), (1,4,6), (2,3,6) and (2,4,5).",
"We can also verify that F(128) = 496062.",
"",
"Find the last 9 digits of F(1018)."
]
},
{
"id": "5900f5561000cf542c510068",
"challengeType": 5,
"type": "bonfire",
"title": "Problem 489: Common factors between two sequences",
"tests": [
"assert.strictEqual(euler489(), TODO: MISSING ANSWER, 'message: <code>euler489()</code> should return TODO: MISSING ANSWER.');"
],
"solutions": [],
"translations": {},
"challengeSeed": [
"function euler489() {",
" // Good luck!",
" return true;",
"}",
"",
"euler489();"
],
"description": [
"Let G(a, b) be the smallest non-negative integer n for which gcd(n3 + b, (n + a)3 + b) is maximized.",
"For example, G(1, 1) = 5 because gcd(n3 + 1, (n + 1)3 + 1) reaches its maximum value of 7 for n = 5, and is smaller for 0 ≤ n < 5.",
"Let H(m, n) = Σ G(a, b) for 1 ≤ a ≤ m, 1 ≤ b ≤ n.",
"You are given H(5, 5) = 128878 and H(10, 10) = 32936544.",
"Find H(18, 1900)."
]
},
{
"id": "5900f5561000cf542c510069",
"challengeType": 5,
"type": "bonfire",
"title": "Problem 490: Jumping frog",
"tests": [
"assert.strictEqual(euler490(), TODO: MISSING ANSWER, 'message: <code>euler490()</code> should return TODO: MISSING ANSWER.');"
],
"solutions": [],
"translations": {},
"challengeSeed": [
"function euler490() {",
" // Good luck!",
" return true;",
"}",
"",
"euler490();"
],
"description": [
"There are n stones in a pond, numbered 1 to n. Consecutive stones are spaced one unit apart.",
"",
"A frog sits on stone 1. He wishes to visit each stone exactly once, stopping on stone n. However, he can only jump from one stone to another if they are at most 3 units apart. In other words, from stone i, he can reach a stone j if 1 ≤ j ≤ n and j is in the set {i-3, i-2, i-1, i+1, i+2, i+3}.",
"",
"Let f(n) be the number of ways he can do this. For example, f(6) = 14, as shown below:",
"1 → 2 → 3 → 4 → 5 → 6 ",
"1 → 2 → 3 → 5 → 4 → 6 ",
"1 → 2 → 4 → 3 → 5 → 6 ",
"1 → 2 → 4 → 5 → 3 → 6 ",
"1 → 2 → 5 → 3 → 4 → 6 ",
"1 → 2 → 5 → 4 → 3 → 6 ",
"1 → 3 → 2 → 4 → 5 → 6 ",
"1 → 3 → 2 → 5 → 4 → 6 ",
"1 → 3 → 4 → 2 → 5 → 6 ",
"1 → 3 → 5 → 2 → 4 → 6 ",
"1 → 4 → 2 → 3 → 5 → 6 ",
"1 → 4 → 2 → 5 → 3 → 6 ",
"1 → 4 → 3 → 2 → 5 → 6 ",
"1 → 4 → 5 → 2 → 3 → 6",
"",
"Other examples are f(10) = 254 and f(40) = 1439682432976.",
"",
"Let S(L) = ∑ f(n)3 for 1 ≤ n ≤ L.",
"Examples:",
"S(10) = 18230635",
"S(20) = 104207881192114219",
"S(1 000) mod 109 = 225031475",
"S(1 000 000) mod 109 = 363486179",
"",
"Find S(1014) mod 109."
]
},
{
"id": "5900f5591000cf542c51006b",
"challengeType": 5,
"type": "bonfire",
"title": "Problem 491: Double pandigital number divisible by 11",
"tests": [
"assert.strictEqual(euler491(), 194505988824000, 'message: <code>euler491()</code> should return 194505988824000.');"
],
"solutions": [],
"translations": {},
"challengeSeed": [
"function euler491() {",
" // Good luck!",
" return true;",
"}",
"",
"euler491();"
],
"description": [
"We call a positive integer double pandigital if it uses all the digits 0 to 9 exactly twice (with no leading zero). For example, 40561817703823564929 is one such number.",
"",
"How many double pandigital numbers are divisible by 11?"
]
},
{
"id": "5900f5581000cf542c51006a",
"challengeType": 5,
"type": "bonfire",
"title": "Problem 492: Exploding sequence",
"tests": [
"assert.strictEqual(euler492(), TODO: MISSING ANSWER, 'message: <code>euler492()</code> should return TODO: MISSING ANSWER.');"
],
"solutions": [],
"translations": {},
"challengeSeed": [
"function euler492() {",
" // Good luck!",
" return true;",
"}",
"",
"euler492();"
],
"description": [
"Define the sequence a1, a2, a3, ... as:",
"a1 = 1",
"an+1 = 6an2 + 10an + 3 for n ≥ 1.",
"",
"Examples:",
"a3 = 2359",
"a6 = 269221280981320216750489044576319",
"a6 mod 1 000 000 007 = 203064689",
"a100 mod 1 000 000 007 = 456482974",
"",
"",
"",
"Define B(x,y,n) as ∑ (an mod p) for every prime p such that x ≤ p ≤ x+y.",
"",
"",
"",
"Examples:",
"B(109, 103, 103) = 23674718882",
"B(109, 103, 1015) = 20731563854",
"",
"",
"Find B(109, 107, 1015)."
]
},
{
"id": "5900f55a1000cf542c51006c",
"challengeType": 5,
"type": "bonfire",
"title": "Problem 493: Under The Rainbow",
"tests": [
"assert.strictEqual(euler493(), 6.818741802, 'message: <code>euler493()</code> should return 6.818741802.');"
],
"solutions": [],
"translations": {},
"challengeSeed": [
"function euler493() {",
" // Good luck!",
" return true;",
"}",
"",
"euler493();"
],
"description": [
"70 colored balls are placed in an urn, 10 for each of the seven rainbow colors.",
"What is the expected number of distinct colors in 20 randomly picked balls?",
"Give your answer with nine digits after the decimal point (a.bcdefghij)."
]
},
{
"id": "5900f55a1000cf542c51006d",
"challengeType": 5,
"type": "bonfire",
"title": "Problem 494: Collatz prefix families",
"tests": [
"assert.strictEqual(euler494(), TODO: MISSING ANSWER, 'message: <code>euler494()</code> should return TODO: MISSING ANSWER.');"
],
"solutions": [],
"translations": {},
"challengeSeed": [
"function euler494() {",
" // Good luck!",
" return true;",
"}",
"",
"euler494();"
],
"description": [
"The Collatz sequence is defined as:",
"$a_{i+1} = \\left\\{ \\large{\\frac {a_i} 2 \\atop 3 a_i+1} {\\text{if }a_i\\text{ is even} \\atop \\text{if }a_i\\text{ is odd}} \\right.$.",
"",
"",
"The Collatz conjecture states that starting from any positive integer, the sequence eventually reaches the cycle 1,4,2,1....",
"We shall define the sequence prefix p(n) for the Collatz sequence starting with a1 = n as the sub-sequence of all numbers not a power of 2 (20=1 is considered a power of 2 for this problem). For example:p(13) = {13, 40, 20, 10, 5} p(8) = {}",
"Any number invalidating the conjecture would have an infinite length sequence prefix.",
"",
"",
"Let Sm be the set of all sequence prefixes of length m. Two sequences {a1, a2, ..., am} and {b1, b2, ..., bm} in Sm are said to belong to the same prefix family if ai < aj if and only if bi < bj for all 1 ≤ i,j ≤ m.",
"",
"",
"For example, in S4, {6, 3, 10, 5} is in the same family as {454, 227, 682, 341}, but not {113, 340, 170, 85}.",
"Let f(m) be the number of distinct prefix families in Sm.",
"You are given f(5) = 5, f(10) = 55, f(20) = 6771.",
"",
"",
"Find f(90)."
]
},
{
"id": "5900f55b1000cf542c51006e",
"challengeType": 5,
"type": "bonfire",
"title": "Problem 495: Writing n as the product of k distinct positive integers",
"tests": [
"assert.strictEqual(euler495(), TODO: MISSING ANSWER, 'message: <code>euler495()</code> should return TODO: MISSING ANSWER.');"
],
"solutions": [],
"translations": {},
"challengeSeed": [
"function euler495() {",
" // Good luck!",
" return true;",
"}",
"",
"euler495();"
],
"description": [
"Let W(n,k) be the number of ways in which n can be written as the product of k distinct positive integers.",
"For example, W(144,4) = 7. There are 7 ways in which 144 can be written as a product of 4 distinct positive integers:",
"144 = 1×2×4×18",
"144 = 1×2×8×9",
"144 = 1×2×3×24",
"144 = 1×2×6×12",
"144 = 1×3×4×12",
"144 = 1×3×6×8",
"144 = 2×3×4×6",
"Note that permutations of the integers themselves are not considered distinct.",
"Furthermore, W(100!,10) modulo 1 000 000 007 = 287549200.",
"Find W(10000!,30) modulo 1 000 000 007."
]
},
{
"id": "5900f55d1000cf542c51006f",
"challengeType": 5,
"type": "bonfire",
"title": "Problem 496: Incenter and circumcenter of triangle",
"tests": [
"assert.strictEqual(euler496(), 2042473533769142800, 'message: <code>euler496()</code> should return 2042473533769142800.');"
],
"solutions": [],
"translations": {},
"challengeSeed": [
"function euler496() {",
" // Good luck!",
" return true;",
"}",
"",
"euler496();"
],
"description": [
"Given an integer sided triangle ABC:",
"Let I be the incenter of ABC.",
"Let D be the intersection between the line AI and the circumcircle of ABC (A ≠ D).",
"",
"We define F(L) as the sum of BC for the triangles ABC that satisfy AC = DI and BC ≤ L.",
"",
"For example, F(15) = 45 because the triangles ABC with (BC,AC,AB) = (6,4,5), (12,8,10), (12,9,7), (15,9,16) satisfy the conditions.",
"",
"Find F(109)."
]
},
{
"id": "5900f55f1000cf542c510070",
"challengeType": 5,
"type": "bonfire",
"title": "Problem 497: Drunken Tower of Hanoi",
"tests": [
"assert.strictEqual(euler497(), 684901360, 'message: <code>euler497()</code> should return 684901360.');"
],
"solutions": [],
"translations": {},
"challengeSeed": [
"function euler497() {",
" // Good luck!",
" return true;",
"}",
"",
"euler497();"
],
"description": [
"Bob is very familiar with the famous mathematical puzzle/game, \"Tower of Hanoi,\" which consists of three upright rods and disks of different sizes that can slide onto any of the rods. The game begins with a stack of n disks placed on the leftmost rod in descending order by size. The objective of the game is to move all of the disks from the leftmost rod to the rightmost rod, given the following restrictions:",
"",
"Only one disk can be moved at a time.",
"A valid move consists of taking the top disk from one stack and placing it onto another stack (or an empty rod).",
"No disk can be placed on top of a smaller disk.",
"Moving on to a variant of this game, consider a long room k units (square tiles) wide, labeled from 1 to k in ascending order. Three rods are placed at squares a, b, and c, and a stack of n disks is placed on the rod at square a.",
"",
"Bob begins the game standing at square b. His objective is to play the Tower of Hanoi game by moving all of the disks to the rod at square c. However, Bob can only pick up or set down a disk if he is on the same square as the rod / stack in question.",
"",
"Unfortunately, Bob is also drunk. On a given move, Bob will either stumble one square to the left or one square to the right with equal probability, unless Bob is at either end of the room, in which case he can only move in one direction. Despite Bob's inebriated state, he is still capable of following the rules of the game itself, as well as choosing when to pick up or put down a disk.",
"",
"The following animation depicts a side-view of a sample game for n = 3, k = 7, a = 2, b = 4, and c = 6:",
"",
"",
"",
"Let E(n,k,a,b,c) be the expected number of squares that Bob travels during a single optimally-played game. A game is played optimally if the number of disk-pickups is minimized.",
"",
"Interestingly enough, the result is always an integer. For example, E(2,5,1,3,5) = 60 and E(3,20,4,9,17) = 2358.",
"",
"Find the last nine digits of ∑1≤n≤10000 E(n,10n,3n,6n,9n)."
]
},
{
"id": "5900f55f1000cf542c510071",
"challengeType": 5,
"type": "bonfire",
"title": "Problem 498: Remainder of polynomial division",
"tests": [
"assert.strictEqual(euler498(), 472294837, 'message: <code>euler498()</code> should return 472294837.');"
],
"solutions": [],
"translations": {},
"challengeSeed": [
"function euler498() {",
" // Good luck!",
" return true;",
"}",
"",
"euler498();"
],
"description": [
"For positive integers n and m, we define two polynomials Fn(x) = xn and Gm(x) = (x-1)m.",
"We also define a polynomial Rn,m(x) as the remainder of the division of Fn(x) by Gm(x).",
"For example, R6,3(x) = 15x2 - 24x + 10.",
"",
"Let C(n, m, d) be the absolute value of the coefficient of the d-th degree term of Rn,m(x).",
"We can verify that C(6, 3, 1) = 24 and C(100, 10, 4) = 227197811615775.",
"",
"Find C(1013, 1012, 104) mod 999999937."
]
},
{
"id": "5900f5611000cf542c510072",
"challengeType": 5,
"type": "bonfire",
"title": "Problem 499: St. Petersburg Lottery",
"tests": [
"assert.strictEqual(euler499(), 0.8660312, 'message: <code>euler499()</code> should return 0.8660312.');"
],
"solutions": [],
"translations": {},
"challengeSeed": [
"function euler499() {",
" // Good luck!",
" return true;",
"}",
"",
"euler499();"
],
"description": [
"A gambler decides to participate in a special lottery. In this lottery the gambler plays a series of one or more games.",
"Each game costs m pounds to play and starts with an initial pot of 1 pound. The gambler flips an unbiased coin. Every time a head appears, the pot is doubled and the gambler continues. When a tail appears, the game ends and the gambler collects the current value of the pot. The gambler is certain to win at least 1 pound, the starting value of the pot, at the cost of m pounds, the initial fee.",
"",
"The gambler cannot continue to play if his fortune falls below m pounds.",
"Let pm(s) denote the probability that the gambler will never run out of money in this lottery given his initial fortune s and the cost per game m.",
"For example p2(2) ≈ 0.2522, p2(5) ≈ 0.6873 and p6(10 000) ≈ 0.9952 (note: pm(s) = 0 for s < m).",
"",
"Find p15(109) and give your answer rounded to 7 decimal places behind the decimal point in the form 0.abcdefg."
]
},
{
"id": "5900f5611000cf542c510073",
"challengeType": 5,
"type": "bonfire",
"title": "Problem 500: Problem 500!!!",
"tests": [
"assert.strictEqual(euler500(), 35407281, 'message: <code>euler500()</code> should return 35407281.');"
],
"solutions": [],
"translations": {},
"challengeSeed": [
"function euler500() {",
" // Good luck!",
" return true;",
"}",
"",
"euler500();"
],
"description": [
"The number of divisors of 120 is 16.",
"In fact 120 is the smallest number having 16 divisors.",
"",
"",
"Find the smallest number with 2500500 divisors.",
"Give your answer modulo 500500507."
]
},
{
"id": "5900f5621000cf542c510074",
"challengeType": 5,
"type": "bonfire",
"title": "Problem 501: Eight Divisors",
"tests": [
"assert.strictEqual(euler501(), 197912312715, 'message: <code>euler501()</code> should return 197912312715.');"
],
"solutions": [],
"translations": {},
"challengeSeed": [
"function euler501() {",
" // Good luck!",
" return true;",
"}",
"",
"euler501();"
],
"description": [
"The eight divisors of 24 are 1, 2, 3, 4, 6, 8, 12 and 24.",
"The ten numbers not exceeding 100 having exactly eight divisors are 24, 30, 40, 42, 54, 56, 66, 70, 78 and 88.",
"Let f(n) be the count of numbers not exceeding n with exactly eight divisors.",
"You are given f(100) = 10, f(1000) = 180 and f(106) = 224427.",
"Find f(1012)."
]
},
{
"id": "5900f5621000cf542c510075",
"challengeType": 5,
"type": "bonfire",
"title": "Problem 502: Counting Castles",
"tests": [
"assert.strictEqual(euler502(), TODO: MISSING ANSWER, 'message: <code>euler502()</code> should return TODO: MISSING ANSWER.');"
],
"solutions": [],
"translations": {},
"challengeSeed": [
"function euler502() {",
" // Good luck!",
" return true;",
"}",
"",
"euler502();"
],
"description": [
"We define a block to be a rectangle with a height of 1 and an integer-valued length. Let a castle be a configuration of stacked blocks.",
"",
"Given a game grid that is w units wide and h units tall, a castle is generated according to the following rules:",
"",
"",
"Blocks can be placed on top of other blocks as long as nothing sticks out past the edges or hangs out over open space.",
"All blocks are aligned/snapped to the grid.",
"Any two neighboring blocks on the same row have at least one unit of space between them.",
"The bottom row is occupied by a block of length w.",
"The maximum achieved height of the entire castle is exactly h.",
"The castle is made from an even number of blocks.",
"The following is a sample castle for w=8 and h=5:",
"",
"",
"",
"Let F(w,h) represent the number of valid castles, given grid parameters w and h.",
"",
"For example, F(4,2) = 10, F(13,10) = 3729050610636, F(10,13) = 37959702514, and F(100,100) mod 1 000 000 007 = 841913936.",
"",
"Find (F(1012,100) + F(10000,10000) + F(100,1012)) mod 1 000 000 007."
]
},
{
"id": "5900f5631000cf542c510076",
"challengeType": 5,
"type": "bonfire",
"title": "Problem 503: Compromise or persist",
"tests": [
"assert.strictEqual(euler503(), 3.8694550145, 'message: <code>euler503()</code> should return 3.8694550145.');"
],
"solutions": [],
"translations": {},
"challengeSeed": [
"function euler503() {",
" // Good luck!",
" return true;",
"}",
"",
"euler503();"
],
"description": [
"Alice is playing a game with n cards numbered 1 to n.",
"",
"A game consists of iterations of the following steps.",
"(1) Alice picks one of the cards at random.",
"(2) Alice cannot see the number on it. Instead, Bob, one of her friends, sees the number and tells Alice how many previously-seen numbers are bigger than the number which he is seeing.",
"(3) Alice can end or continue the game. If she decides to end, the number becomes her score. If she decides to continue, the card is removed from the game and she returns to (1). If there is no card left, she is forced to end the game.",
"",
"Let F(n) be the Alice's expected score if she takes the optimized strategy to minimize her score.",
"",
"For example, F(3) = 5/3. At the first iteration, she should continue the game. At the second iteration, she should end the game if Bob says that one previously-seen number is bigger than the number which he is seeing, otherwise she should continue the game.",
"",
"We can also verify that F(4) = 15/8 and F(10) ≈ 2.5579365079.",
"",
"Find F(106). Give your answer rounded to 10 decimal places behind the decimal point."
]
},
{
"id": "5900f5641000cf542c510077",
"challengeType": 5,
"type": "bonfire",
"title": "Problem 504: Square on the Inside",
"tests": [
"assert.strictEqual(euler504(), 694687, 'message: <code>euler504()</code> should return 694687.');"
],
"solutions": [],
"translations": {},
"challengeSeed": [
"function euler504() {",
" // Good luck!",
" return true;",
"}",
"",
"euler504();"
],
"description": [
"Let ABCD be a quadrilateral whose vertices are lattice points lying on the coordinate axes as follows:",
"",
"A(a, 0), B(0, b), C(−c, 0), D(0, −d), where 1 ≤ a, b, c, d ≤ m and a, b, c, d, m are integers.",
"",
"It can be shown that for m = 4 there are exactly 256 valid ways to construct ABCD. Of these 256 quadrilaterals, 42 of them strictly contain a square number of lattice points.",
"",
"How many quadrilaterals ABCD strictly contain a square number of lattice points for m = 100?"
]
},
{
"id": "5900f5661000cf542c510078",
"challengeType": 5,
"type": "bonfire",
"title": "Problem 505: Bidirectional Recurrence",
"tests": [
"assert.strictEqual(euler505(), TODO: MISSING ANSWER, 'message: <code>euler505()</code> should return TODO: MISSING ANSWER.');"
],
"solutions": [],
"translations": {},
"challengeSeed": [
"function euler505() {",
" // Good luck!",
" return true;",
"}",
"",
"euler505();"
],
"description": [
"Let:",
"$\\begin{array}{ll} x(0)&=0 \\\\ x(1)&=1 \\\\ x(2k)&=(3x(k)+2x(\\lfloor \\frac k 2 \\rfloor)) \\text{ mod } 2^{60} \\text{ for } k \\ge 1 \\text {, where } \\lfloor \\text { } \\rfloor \\text { is the floor function} \\\\ x(2k+1)&=(2x(k)+3x(\\lfloor \\frac k 2 \\rfloor)) \\text{ mod } 2^{60} \\text{ for } k \\ge 1 \\\\ y_n(k)&=\\left\\{{\\begin{array}{lc} x(k) && \\text{if } k \\ge n \\\\ 2^{60} - 1 - max(y_n(2k),y_n(2k+1)) && \\text{if } k < n \\end{array}} \\right. \\\\ A(n)&=y_n(1) \\end{array}$",
"You are given:",
"$\\begin{array}{ll} x(2)&=3 \\\\ x(3)&=2 \\\\ x(4)&=11 \\\\ y_4(4)&=11 \\\\ y_4(3)&=2^{60}-9\\\\ y_4(2)&=2^{60}-12 \\\\ y_4(1)&=A(4)=8 \\\\ A(10)&=2^{60}-34\\\\ A(10^3)&=101881 \\end{array}$",
"Find $A(10^{12})$."
]
},
{
"id": "5900f5671000cf542c510079",
"challengeType": 5,
"type": "bonfire",
"title": "Problem 506: Clock sequence",
"tests": [
"assert.strictEqual(euler506(), 18934502, 'message: <code>euler506()</code> should return 18934502.');"
],
"solutions": [],
"translations": {},
"challengeSeed": [
"function euler506() {",
" // Good luck!",
" return true;",
"}",
"",
"euler506();"
],
"description": [
"Consider the infinite repeating sequence of digits:",
"1234321234321234321...",
"Amazingly, you can break this sequence of digits into a sequence of integers such that the sum of the digits in the n'th value is n.",
"The sequence goes as follows:",
"1, 2, 3, 4, 32, 123, 43, 2123, 432, 1234, 32123, ...",
"Let vn be the n'th value in this sequence. For example, v2 = 2, v5 = 32 and v11 = 32123.",
"Let S(n) be v1 + v2 + ... + vn. For example, S(11) = 36120, and S(1000) mod 123454321 = 18232686.",
"Find S(1014) mod 123454321."
]
},
{
"id": "5900f5671000cf542c51007a",
"challengeType": 5,
"type": "bonfire",
"title": "Problem 507: Shortest Lattice Vector",
"tests": [
"assert.strictEqual(euler507(), TODO: MISSING ANSWER, 'message: <code>euler507()</code> should return TODO: MISSING ANSWER.');"
],
"solutions": [],
"translations": {},
"challengeSeed": [
"function euler507() {",
" // Good luck!",
" return true;",
"}",
"",
"euler507();"
],
"description": [
"Let $t_n$ be the tribonacci numbers defined as:",
"$t_0 = t_1 = 0$;",
"$t_2 = 1$;",
"$t_n = t_{n-1} + t_{n-2} + t_{n-3}$ for $n \\ge 3$",
"and let $r_n = t_n \\text{ mod } 10^7$.",
"",
"",
"For each pair of Vectors $V_n=(v_1,v_2,v_3)$ and $W_n=(w_1,w_2,w_3)$ with $v_1=r_{12n-11}-r_{12n-10}, v_2=r_{12n-9}+r_{12n-8}, v_3=r_{12n-7} \\cdot r_{12n-6}$ and $w_1=r_{12n-5}-r_{12n-4}, w_2=r_{12n-3}+r_{12n-2}, w_3=r_{12n-1} \\cdot r_{12n}$",
"",
"",
"we define $S(n)$ as the minimal value of the manhattan length of the vector $D=k \\cdot V_n+l \\cdot W_n$ measured as $|k \\cdot v_1+l \\cdot w_1|+|k \\cdot v_2+l \\cdot w_2|+|k \\cdot v_3+l \\cdot w_3|$",
" for any integers $k$ and $l$ with $(k,l)\\neq (0,0)$.",
"",
"The first vector pair is (-1, 3, 28), (-11, 125, 40826).",
"You are given that $S(1)=32$ and $\\sum_{n=1}^{10} S(n)=130762273722$.",
"",
"",
"Find $\\sum_{n=1}^{20000000} S(n)$."
]
},
{
"id": "5900f5691000cf542c51007c",
"challengeType": 5,
"type": "bonfire",
"title": "Problem 508: Integers in base i-1",
"tests": [
"assert.strictEqual(euler508(), TODO: MISSING ANSWER, 'message: <code>euler508()</code> should return TODO: MISSING ANSWER.');"
],
"solutions": [],
"translations": {},
"challengeSeed": [
"function euler508() {",
" // Good luck!",
" return true;",
"}",
"",
"euler508();"
],
"description": [
"Consider the Gaussian integer i-1. A base i-1 representation of a Gaussian integer a+bi is a finite sequence of digits dn-1dn-2...d1d0 such that:",
"",
"a+bi = dn-1(i-1)n-1 + dn-2(i-1)n-2 + ... + d1(i-1) + d0",
"Each dk is in {0,1}",
"There are no leading zeroes, i.e. dn-1 ≠ 0, unless a+bi is itself 0",
"Here are base i-1 representations of a few Gaussian integers:",
"11+24i → 111010110001101",
"24-11i → 110010110011",
"8+0i → 111000000",
"-5+0i → 11001101",
"0+0i → 0",
"",
"Remarkably, every Gaussian integer has a unique base i-1 representation!",
"",
"Define f(a+bi) as the number of 1s in the unique base i-1 representation of a+bi. For example, f(11+24i) = 9 and f(24-11i) = 7.",
"",
"Define B(L) as the sum of f(a+bi) for all integers a, b such that |a| ≤ L and |b| ≤ L. For example, B(500) = 10795060.",
"",
"Find B(1015) mod 1 000 000 007."
]
},
{
"id": "5900f5691000cf542c51007b",
"challengeType": 5,
"type": "bonfire",
"title": "Problem 509: Divisor Nim",
"tests": [
"assert.strictEqual(euler509(), 151725678, 'message: <code>euler509()</code> should return 151725678.');"
],
"solutions": [],
"translations": {},
"challengeSeed": [
"function euler509() {",
" // Good luck!",
" return true;",
"}",
"",
"euler509();"
],
"description": [
"Anton and Bertrand love to play three pile Nim.",
"However, after a lot of games of Nim they got bored and changed the rules somewhat.",
"They may only take a number of stones from a pile that is a proper divisor of the number of stones present in the pile. E.g. if a pile at a certain moment contains 24 stones they may take only 1,2,3,4,6,8 or 12 stones from that pile.",
"So if a pile contains one stone they can't take the last stone from it as 1 isn't a proper divisor of 1.",
"The first player that can't make a valid move loses the game.",
"Of course both Anton and Bertrand play optimally.",
"",
"The triple (a,b,c) indicates the number of stones in the three piles.",
"Let S(n) be the number of winning positions for the next player for 1 ≤ a, b, c ≤ n.S(10) = 692 and S(100) = 735494.",
"",
"Find S(123456787654321) modulo 1234567890."
]
},
{
"id": "5900f56b1000cf542c51007d",
"challengeType": 5,
"type": "bonfire",
"title": "Problem 510: Tangent Circles",
"tests": [
"assert.strictEqual(euler510(), 315306518862563700, 'message: <code>euler510()</code> should return 315306518862563700.');"
],
"solutions": [],
"translations": {},
"challengeSeed": [
"function euler510() {",
" // Good luck!",
" return true;",
"}",
"",
"euler510();"
],
"description": [
"Circles A and B are tangent to each other and to line L at three distinct points.",
"Circle C is inside the space between A, B and L, and tangent to all three.",
"Let rA, rB and rC be the radii of A, B and C respectively.",
"Let S(n) = Σ rA + rB + rC, for 0 < rA ≤ rB ≤ n where rA, rB and rC are integers.",
"The only solution for 0 < rA ≤ rB ≤ 5 is rA = 4, rB = 4 and rC = 1, so S(5) = 4 + 4 + 1 = 9.",
"You are also given S(100) = 3072.",
"Find S(109)."
]
},
{
"id": "5900f56b1000cf542c51007e",
"challengeType": 5,
"type": "bonfire",
"title": "Problem 511: Sequences with nice divisibility properties",
"tests": [
"assert.strictEqual(euler511(), 935247012, 'message: <code>euler511()</code> should return 935247012.');"
],
"solutions": [],
"translations": {},
"challengeSeed": [