euler-manager 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (499) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +21 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +37 -0
  6. data/Rakefile +1 -0
  7. data/bin/euler +145 -0
  8. data/data/answers.yml +456 -0
  9. data/data/problems/1.yml +7 -0
  10. data/data/problems/10.yml +8 -0
  11. data/data/problems/100.yml +13 -0
  12. data/data/problems/101.yml +49 -0
  13. data/data/problems/102.yml +16 -0
  14. data/data/problems/103.yml +26 -0
  15. data/data/problems/104.yml +15 -0
  16. data/data/problems/105.yml +21 -0
  17. data/data/problems/106.yml +19 -0
  18. data/data/problems/107.yml +20 -0
  19. data/data/problems/108.yml +32 -0
  20. data/data/problems/109.yml +33 -0
  21. data/data/problems/11.yml +33 -0
  22. data/data/problems/110.yml +19 -0
  23. data/data/problems/111.yml +21 -0
  24. data/data/problems/112.yml +15 -0
  25. data/data/problems/113.yml +13 -0
  26. data/data/problems/114.yml +106 -0
  27. data/data/problems/115.yml +17 -0
  28. data/data/problems/116.yml +76 -0
  29. data/data/problems/117.yml +82 -0
  30. data/data/problems/118.yml +9 -0
  31. data/data/problems/119.yml +11 -0
  32. data/data/problems/12.yml +13 -0
  33. data/data/problems/120.yml +17 -0
  34. data/data/problems/121.yml +15 -0
  35. data/data/problems/122.yml +42 -0
  36. data/data/problems/123.yml +13 -0
  37. data/data/problems/124.yml +58 -0
  38. data/data/problems/125.yml +12 -0
  39. data/data/problems/126.yml +17 -0
  40. data/data/problems/127.yml +31 -0
  41. data/data/problems/128.yml +18 -0
  42. data/data/problems/129.yml +12 -0
  43. data/data/problems/13.yml +6 -0
  44. data/data/problems/130.yml +19 -0
  45. data/data/problems/131.yml +12 -0
  46. data/data/problems/132.yml +12 -0
  47. data/data/problems/133.yml +13 -0
  48. data/data/problems/134.yml +19 -0
  49. data/data/problems/135.yml +20 -0
  50. data/data/problems/136.yml +17 -0
  51. data/data/problems/137.yml +36 -0
  52. data/data/problems/138.yml +20 -0
  53. data/data/problems/139.yml +15 -0
  54. data/data/problems/14.yml +28 -0
  55. data/data/problems/140.yml +29 -0
  56. data/data/problems/141.yml +14 -0
  57. data/data/problems/142.yml +14 -0
  58. data/data/problems/143.yml +20 -0
  59. data/data/problems/144.yml +30 -0
  60. data/data/problems/145.yml +11 -0
  61. data/data/problems/146.yml +9 -0
  62. data/data/problems/147.yml +14 -0
  63. data/data/problems/148.yml +11 -0
  64. data/data/problems/149.yml +41 -0
  65. data/data/problems/15.yml +11 -0
  66. data/data/problems/150.yml +34 -0
  67. data/data/problems/151.yml +19 -0
  68. data/data/problems/152.yml +12 -0
  69. data/data/problems/153.yml +57 -0
  70. data/data/problems/154.yml +16 -0
  71. data/data/problems/155.yml +22 -0
  72. data/data/problems/156.yml +27 -0
  73. data/data/problems/157.yml +34 -0
  74. data/data/problems/158.yml +19 -0
  75. data/data/problems/159.yml +29 -0
  76. data/data/problems/16.yml +6 -0
  77. data/data/problems/160.yml +8 -0
  78. data/data/problems/161.yml +15 -0
  79. data/data/problems/162.yml +15 -0
  80. data/data/problems/163.yml +19 -0
  81. data/data/problems/164.yml +8 -0
  82. data/data/problems/165.yml +32 -0
  83. data/data/problems/166.yml +15 -0
  84. data/data/problems/167.yml +17 -0
  85. data/data/problems/168.yml +13 -0
  86. data/data/problems/169.yml +10 -0
  87. data/data/problems/17.yml +11 -0
  88. data/data/problems/170.yml +16 -0
  89. data/data/problems/171.yml +13 -0
  90. data/data/problems/172.yml +6 -0
  91. data/data/problems/173.yml +12 -0
  92. data/data/problems/174.yml +20 -0
  93. data/data/problems/175.yml +21 -0
  94. data/data/problems/176.yml +9 -0
  95. data/data/problems/177.yml +16 -0
  96. data/data/problems/178.yml +9 -0
  97. data/data/problems/179.yml +10 -0
  98. data/data/problems/18.yml +21 -0
  99. data/data/problems/180.yml +34 -0
  100. data/data/problems/181.yml +7 -0
  101. data/data/problems/182.yml +35 -0
  102. data/data/problems/183.yml +27 -0
  103. data/data/problems/184.yml +18 -0
  104. data/data/problems/185.yml +22 -0
  105. data/data/problems/186.yml +28 -0
  106. data/data/problems/187.yml +16 -0
  107. data/data/problems/188.yml +10 -0
  108. data/data/problems/189.yml +15 -0
  109. data/data/problems/19.yml +12 -0
  110. data/data/problems/190.yml +13 -0
  111. data/data/problems/191.yml +15 -0
  112. data/data/problems/192.yml +27 -0
  113. data/data/problems/193.yml +7 -0
  114. data/data/problems/194.yml +18 -0
  115. data/data/problems/195.yml +13 -0
  116. data/data/problems/196.yml +25 -0
  117. data/data/problems/197.yml +16 -0
  118. data/data/problems/198.yml +21 -0
  119. data/data/problems/199.yml +14 -0
  120. data/data/problems/2.yml +10 -0
  121. data/data/problems/20.yml +22 -0
  122. data/data/problems/200.yml +12 -0
  123. data/data/problems/201.yml +20 -0
  124. data/data/problems/202.yml +14 -0
  125. data/data/problems/203.yml +21 -0
  126. data/data/problems/204.yml +11 -0
  127. data/data/problems/205.yml +10 -0
  128. data/data/problems/206.yml +6 -0
  129. data/data/problems/207.yml +20 -0
  130. data/data/problems/208.yml +12 -0
  131. data/data/problems/209.yml +27 -0
  132. data/data/problems/21.yml +13 -0
  133. data/data/problems/210.yml +10 -0
  134. data/data/problems/211.yml +11 -0
  135. data/data/problems/212.yml +41 -0
  136. data/data/problems/213.yml +11 -0
  137. data/data/problems/214.yml +15 -0
  138. data/data/problems/215.yml +18 -0
  139. data/data/problems/216.yml +14 -0
  140. data/data/problems/217.yml +27 -0
  141. data/data/problems/218.yml +14 -0
  142. data/data/problems/219.yml +19 -0
  143. data/data/problems/22.yml +13 -0
  144. data/data/problems/220.yml +24 -0
  145. data/data/problems/221.yml +20 -0
  146. data/data/problems/222.yml +7 -0
  147. data/data/problems/223.yml +12 -0
  148. data/data/problems/224.yml +12 -0
  149. data/data/problems/225.yml +11 -0
  150. data/data/problems/226.yml +16 -0
  151. data/data/problems/227.yml +13 -0
  152. data/data/problems/228.yml +23 -0
  153. data/data/problems/229.yml +30 -0
  154. data/data/problems/23.yml +19 -0
  155. data/data/problems/230.yml +23 -0
  156. data/data/problems/231.yml +16 -0
  157. data/data/problems/232.yml +14 -0
  158. data/data/problems/233.yml +10 -0
  159. data/data/problems/234.yml +23 -0
  160. data/data/problems/235.yml +9 -0
  161. data/data/problems/236.yml +32 -0
  162. data/data/problems/237.yml +13 -0
  163. data/data/problems/238.yml +42 -0
  164. data/data/problems/239.yml +9 -0
  165. data/data/problems/24.yml +10 -0
  166. data/data/problems/240.yml +11 -0
  167. data/data/problems/241.yml +17 -0
  168. data/data/problems/242.yml +16 -0
  169. data/data/problems/243.yml +19 -0
  170. data/data/problems/244.yml +32 -0
  171. data/data/problems/245.yml +36 -0
  172. data/data/problems/246.yml +17 -0
  173. data/data/problems/247.yml +21 -0
  174. data/data/problems/248.yml +6 -0
  175. data/data/problems/249.yml +7 -0
  176. data/data/problems/25.yml +15 -0
  177. data/data/problems/250.yml +7 -0
  178. data/data/problems/251.yml +13 -0
  179. data/data/problems/252.yml +31 -0
  180. data/data/problems/253.yml +36 -0
  181. data/data/problems/254.yml +21 -0
  182. data/data/problems/255.yml +59 -0
  183. data/data/problems/256.yml +43 -0
  184. data/data/problems/257.yml +18 -0
  185. data/data/problems/258.yml +13 -0
  186. data/data/problems/259.yml +16 -0
  187. data/data/problems/26.yml +11 -0
  188. data/data/problems/260.yml +30 -0
  189. data/data/problems/261.yml +19 -0
  190. data/data/problems/262.yml +20 -0
  191. data/data/problems/263.yml +19 -0
  192. data/data/problems/264.yml +20 -0
  193. data/data/problems/265.yml +16 -0
  194. data/data/problems/266.yml +10 -0
  195. data/data/problems/267.yml +14 -0
  196. data/data/problems/268.yml +8 -0
  197. data/data/problems/269.yml +15 -0
  198. data/data/problems/27.yml +25 -0
  199. data/data/problems/270.yml +17 -0
  200. data/data/problems/271.yml +13 -0
  201. data/data/problems/272.yml +15 -0
  202. data/data/problems/273.yml +21 -0
  203. data/data/problems/274.yml +23 -0
  204. data/data/problems/275.yml +19 -0
  205. data/data/problems/276.yml +11 -0
  206. data/data/problems/277.yml +24 -0
  207. data/data/problems/278.yml +32 -0
  208. data/data/problems/279.yml +6 -0
  209. data/data/problems/28.yml +17 -0
  210. data/data/problems/280.yml +13 -0
  211. data/data/problems/281.yml +17 -0
  212. data/data/problems/282.yml +10 -0
  213. data/data/problems/283.yml +11 -0
  214. data/data/problems/284.yml +22 -0
  215. data/data/problems/285.yml +17 -0
  216. data/data/problems/286.yml +12 -0
  217. data/data/problems/287.yml +36 -0
  218. data/data/problems/288.yml +15 -0
  219. data/data/problems/289.yml +19 -0
  220. data/data/problems/29.yml +24 -0
  221. data/data/problems/290.yml +8 -0
  222. data/data/problems/291.yml +10 -0
  223. data/data/problems/292.yml +13 -0
  224. data/data/problems/293.yml +15 -0
  225. data/data/problems/294.yml +10 -0
  226. data/data/problems/295.yml +26 -0
  227. data/data/problems/296.yml +15 -0
  228. data/data/problems/297.yml +19 -0
  229. data/data/problems/298.yml +46 -0
  230. data/data/problems/299.yml +31 -0
  231. data/data/problems/3.yml +7 -0
  232. data/data/problems/30.yml +12 -0
  233. data/data/problems/300.yml +24 -0
  234. data/data/problems/301.yml +25 -0
  235. data/data/problems/302.yml +18 -0
  236. data/data/problems/303.yml +11 -0
  237. data/data/problems/304.yml +19 -0
  238. data/data/problems/305.yml +14 -0
  239. data/data/problems/306.yml +29 -0
  240. data/data/problems/307.yml +12 -0
  241. data/data/problems/308.yml +34 -0
  242. data/data/problems/309.yml +17 -0
  243. data/data/problems/31.yml +18 -0
  244. data/data/problems/310.yml +19 -0
  245. data/data/problems/311.yml +21 -0
  246. data/data/problems/312.yml +15 -0
  247. data/data/problems/313.yml +17 -0
  248. data/data/problems/314.yml +29 -0
  249. data/data/problems/315.yml +49 -0
  250. data/data/problems/316.yml +25 -0
  251. data/data/problems/317.yml +11 -0
  252. data/data/problems/318.yml +61 -0
  253. data/data/problems/319.yml +23 -0
  254. data/data/problems/32.yml +14 -0
  255. data/data/problems/320.yml +12 -0
  256. data/data/problems/321.yml +18 -0
  257. data/data/problems/322.yml +12 -0
  258. data/data/problems/323.yml +19 -0
  259. data/data/problems/324.yml +17 -0
  260. data/data/problems/325.yml +25 -0
  261. data/data/problems/326.yml +12 -0
  262. data/data/problems/327.yml +39 -0
  263. data/data/problems/328.yml +36 -0
  264. data/data/problems/329.yml +17 -0
  265. data/data/problems/33.yml +13 -0
  266. data/data/problems/330.yml +40 -0
  267. data/data/problems/331.yml +28 -0
  268. data/data/problems/332.yml +16 -0
  269. data/data/problems/333.yml +25 -0
  270. data/data/problems/334.yml +39 -0
  271. data/data/problems/335.yml +16 -0
  272. data/data/problems/336.yml +24 -0
  273. data/data/problems/337.yml +15 -0
  274. data/data/problems/338.yml +41 -0
  275. data/data/problems/339.yml +17 -0
  276. data/data/problems/34.yml +7 -0
  277. data/data/problems/340.yml +14 -0
  278. data/data/problems/341.yml +18 -0
  279. data/data/problems/342.yml +17 -0
  280. data/data/problems/343.yml +29 -0
  281. data/data/problems/344.yml +21 -0
  282. data/data/problems/345.yml +26 -0
  283. data/data/problems/346.yml +11 -0
  284. data/data/problems/347.yml +16 -0
  285. data/data/problems/348.yml +12 -0
  286. data/data/problems/349.yml +13 -0
  287. data/data/problems/35.yml +8 -0
  288. data/data/problems/350.yml +18 -0
  289. data/data/problems/351.yml +13 -0
  290. data/data/problems/352.yml +49 -0
  291. data/data/problems/353.yml +25 -0
  292. data/data/problems/354.yml +16 -0
  293. data/data/problems/355.yml +8 -0
  294. data/data/problems/356.yml +10 -0
  295. data/data/problems/357.yml +9 -0
  296. data/data/problems/358.yml +31 -0
  297. data/data/problems/359.yml +26 -0
  298. data/data/problems/36.yml +8 -0
  299. data/data/problems/360.yml +12 -0
  300. data/data/problems/361.yml +20 -0
  301. data/data/problems/362.yml +32 -0
  302. data/data/problems/363.yml +33 -0
  303. data/data/problems/364.yml +15 -0
  304. data/data/problems/365.yml +17 -0
  305. data/data/problems/366.yml +26 -0
  306. data/data/problems/367.yml +20 -0
  307. data/data/problems/368.yml +39 -0
  308. data/data/problems/369.yml +15 -0
  309. data/data/problems/37.yml +10 -0
  310. data/data/problems/370.yml +16 -0
  311. data/data/problems/371.yml +13 -0
  312. data/data/problems/372.yml +16 -0
  313. data/data/problems/373.yml +10 -0
  314. data/data/problems/374.yml +25 -0
  315. data/data/problems/375.yml +23 -0
  316. data/data/problems/376.yml +25 -0
  317. data/data/problems/377.yml +11 -0
  318. data/data/problems/378.yml +15 -0
  319. data/data/problems/379.yml +15 -0
  320. data/data/problems/38.yml +18 -0
  321. data/data/problems/380.yml +22 -0
  322. data/data/problems/381.yml +21 -0
  323. data/data/problems/382.yml +23 -0
  324. data/data/problems/383.yml +13 -0
  325. data/data/problems/384.yml +28 -0
  326. data/data/problems/385.yml +22 -0
  327. data/data/problems/386.yml +16 -0
  328. data/data/problems/387.yml +19 -0
  329. data/data/problems/388.yml +12 -0
  330. data/data/problems/389.yml +12 -0
  331. data/data/problems/39.yml +10 -0
  332. data/data/problems/390.yml +18 -0
  333. data/data/problems/391.yml +29 -0
  334. data/data/problems/392.yml +22 -0
  335. data/data/problems/393.yml +12 -0
  336. data/data/problems/394.yml +22 -0
  337. data/data/problems/395.yml +19 -0
  338. data/data/problems/396.yml +28 -0
  339. data/data/problems/397.yml +20 -0
  340. data/data/problems/398.yml +13 -0
  341. data/data/problems/399.yml +22 -0
  342. data/data/problems/4.yml +8 -0
  343. data/data/problems/40.yml +18 -0
  344. data/data/problems/400.yml +18 -0
  345. data/data/problems/401.yml +11 -0
  346. data/data/problems/402.yml +25 -0
  347. data/data/problems/403.yml +19 -0
  348. data/data/problems/404.yml +21 -0
  349. data/data/problems/405.yml +15 -0
  350. data/data/problems/406.yml +46 -0
  351. data/data/problems/407.yml +20 -0
  352. data/data/problems/408.yml +14 -0
  353. data/data/problems/409.yml +12 -0
  354. data/data/problems/41.yml +8 -0
  355. data/data/problems/410.yml +19 -0
  356. data/data/problems/411.yml +23 -0
  357. data/data/problems/412.yml +19 -0
  358. data/data/problems/413.yml +13 -0
  359. data/data/problems/414.yml +40 -0
  360. data/data/problems/415.yml +19 -0
  361. data/data/problems/416.yml +13 -0
  362. data/data/problems/417.yml +21 -0
  363. data/data/problems/418.yml +17 -0
  364. data/data/problems/419.yml +22 -0
  365. data/data/problems/42.yml +14 -0
  366. data/data/problems/420.yml +13 -0
  367. data/data/problems/421.yml +29 -0
  368. data/data/problems/422.yml +22 -0
  369. data/data/problems/423.yml +22 -0
  370. data/data/problems/424.yml +37 -0
  371. data/data/problems/425.yml +16 -0
  372. data/data/problems/426.yml +29 -0
  373. data/data/problems/427.yml +18 -0
  374. data/data/problems/428.yml +32 -0
  375. data/data/problems/429.yml +10 -0
  376. data/data/problems/43.yml +17 -0
  377. data/data/problems/430.yml +20 -0
  378. data/data/problems/431.yml +33 -0
  379. data/data/problems/432.yml +13 -0
  380. data/data/problems/433.yml +18 -0
  381. data/data/problems/434.yml +32 -0
  382. data/data/problems/435.yml +21 -0
  383. data/data/problems/436.yml +21 -0
  384. data/data/problems/437.yml +22 -0
  385. data/data/problems/438.yml +29 -0
  386. data/data/problems/439.yml +17 -0
  387. data/data/problems/44.yml +16 -0
  388. data/data/problems/440.yml +21 -0
  389. data/data/problems/441.yml +23 -0
  390. data/data/problems/442.yml +9 -0
  391. data/data/problems/443.yml +13 -0
  392. data/data/problems/444.yml +28 -0
  393. data/data/problems/445.yml +37 -0
  394. data/data/problems/446.yml +29 -0
  395. data/data/problems/447.yml +31 -0
  396. data/data/problems/448.yml +14 -0
  397. data/data/problems/449.yml +17 -0
  398. data/data/problems/45.yml +15 -0
  399. data/data/problems/450.yml +26 -0
  400. data/data/problems/451.yml +15 -0
  401. data/data/problems/452.yml +8 -0
  402. data/data/problems/453.yml +16 -0
  403. data/data/problems/454.yml +17 -0
  404. data/data/problems/455.yml +16 -0
  405. data/data/problems/456.yml +15 -0
  406. data/data/problems/46.yml +18 -0
  407. data/data/problems/47.yml +21 -0
  408. data/data/problems/48.yml +7 -0
  409. data/data/problems/49.yml +10 -0
  410. data/data/problems/5.yml +8 -0
  411. data/data/problems/50.yml +10 -0
  412. data/data/problems/51.yml +15 -0
  413. data/data/problems/52.yml +8 -0
  414. data/data/problems/53.yml +28 -0
  415. data/data/problems/54.yml +43 -0
  416. data/data/problems/55.yml +21 -0
  417. data/data/problems/56.yml +11 -0
  418. data/data/problems/57.yml +15 -0
  419. data/data/problems/58.yml +22 -0
  420. data/data/problems/59.yml +23 -0
  421. data/data/problems/6.yml +13 -0
  422. data/data/problems/60.yml +10 -0
  423. data/data/problems/61.yml +30 -0
  424. data/data/problems/62.yml +9 -0
  425. data/data/problems/63.yml +7 -0
  426. data/data/problems/64.yml +130 -0
  427. data/data/problems/65.yml +62 -0
  428. data/data/problems/66.yml +27 -0
  429. data/data/problems/67.yml +17 -0
  430. data/data/problems/68.yml +23 -0
  431. data/data/problems/69.yml +14 -0
  432. data/data/problems/7.yml +6 -0
  433. data/data/problems/70.yml +16 -0
  434. data/data/problems/71.yml +17 -0
  435. data/data/problems/72.yml +16 -0
  436. data/data/problems/73.yml +16 -0
  437. data/data/problems/74.yml +41 -0
  438. data/data/problems/75.yml +16 -0
  439. data/data/problems/76.yml +8 -0
  440. data/data/problems/77.yml +8 -0
  441. data/data/problems/78.yml +12 -0
  442. data/data/problems/79.yml +11 -0
  443. data/data/problems/8.yml +6 -0
  444. data/data/problems/80.yml +11 -0
  445. data/data/problems/81.yml +19 -0
  446. data/data/problems/82.yml +19 -0
  447. data/data/problems/83.yml +23 -0
  448. data/data/problems/84.yml +63 -0
  449. data/data/problems/85.yml +9 -0
  450. data/data/problems/86.yml +15 -0
  451. data/data/problems/87.yml +12 -0
  452. data/data/problems/88.yml +53 -0
  453. data/data/problems/89.yml +18 -0
  454. data/data/problems/9.yml +13 -0
  455. data/data/problems/90.yml +23 -0
  456. data/data/problems/91.yml +19 -0
  457. data/data/problems/92.yml +29 -0
  458. data/data/problems/93.yml +21 -0
  459. data/data/problems/94.yml +11 -0
  460. data/data/problems/95.yml +23 -0
  461. data/data/problems/96.yml +46 -0
  462. data/data/problems/97.yml +14 -0
  463. data/data/problems/98.yml +16 -0
  464. data/data/problems/99.yml +16 -0
  465. data/euler-manager.gemspec +31 -0
  466. data/euler-manager.sublime-project +12 -0
  467. data/example/1/README.md +6 -0
  468. data/example/1/ruby/1.rb +5 -0
  469. data/example/1/scala/1.scala +9 -0
  470. data/example/2/README.md +9 -0
  471. data/example/2/python/2.py +5 -0
  472. data/example/2/python/euler.py +0 -0
  473. data/example/Eulerfile.rb +87 -0
  474. data/example/README.md +26 -0
  475. data/example/lib/euler.py +0 -0
  476. data/example/lib/euler.rb +0 -0
  477. data/example/lib/euler.scala +5 -0
  478. data/lib/euler.rb +190 -0
  479. data/lib/euler/errors.rb +7 -0
  480. data/lib/euler/languages.rb +12 -0
  481. data/lib/euler/languages/coffeescript.rb +25 -0
  482. data/lib/euler/languages/javascript.rb +25 -0
  483. data/lib/euler/languages/python.rb +27 -0
  484. data/lib/euler/languages/ruby.rb +25 -0
  485. data/lib/euler/languages/scala.rb +27 -0
  486. data/lib/euler/languages/templates/coffeescript.coffee +5 -0
  487. data/lib/euler/languages/templates/javascript.js +5 -0
  488. data/lib/euler/languages/templates/python.py +5 -0
  489. data/lib/euler/languages/templates/ruby.rb +5 -0
  490. data/lib/euler/languages/templates/scala.scala +9 -0
  491. data/lib/euler/problem.rb +60 -0
  492. data/lib/euler/solution.rb +98 -0
  493. data/lib/euler/version.rb +3 -0
  494. data/scripts/update_problems +68 -0
  495. data/spec/euler/problem_spec.rb +5 -0
  496. data/spec/euler/solution_spec.rb +69 -0
  497. data/spec/euler_spec.rb +27 -0
  498. data/spec/spec_helper.rb +3 -0
  499. metadata +644 -0
@@ -0,0 +1,36 @@
1
+ ---
2
+ :id: 328
3
+ :name: Lowest-cost Search
4
+ :url: http://projecteuler.net/problem=328
5
+ :content: "\r\n<p>We are trying to find a hidden number selected from the set of integers
6
+ {1, 2, ..., <var>n</var>} by asking questions. \r\nEach number (question) we ask,
7
+ has a <u>cost equal to the number asked</u> and we get one of three possible answers:<br></p>\n<ul>\n<li>
8
+ \"Your guess is lower than the hidden number\", or</li>\r\n<li> \"Yes, that's it!\",
9
+ or</li>\r\n<li> \"Your guess is higher than the hidden number\".</li>\r\n</ul>\n<p>Given
10
+ the value of <var>n</var>, an <i>optimal strategy</i> minimizes the total cost (i.e.
11
+ the sum of all the questions asked) <u>for the worst possible case</u>. E.g.</p>\r\n\r\n<p>If
12
+ <var>n</var>=3, the best we can do is obviously to ask the number \"<b>2</b>\".
13
+ The answer will immediately lead us to find the hidden number (at a total cost =
14
+ 2).</p>\r\n\r\n<p>If <var>n</var>=8, we might decide to use a \"binary search\"
15
+ type of strategy: Our first question would be \"<b>4</b>\" and if the hidden number
16
+ is higher than 4 we will need one or two additional questions.<br>\r\nLet our second
17
+ question be \"<b>6</b>\". If the hidden number is still higher than 6, we will need
18
+ a third question in order to discriminate between 7 and 8.<br>\r\nThus, our third
19
+ question will be \"<b>7</b>\" and the total cost for this worst-case scenario will
20
+ be 4+6+7=<span style=\"color:red;\"><b>17</b></span>.</p>\r\n\r\n<p>We can improve
21
+ considerably the worst-case cost for <var>n</var>=8, by asking \"<b>5</b>\" as our
22
+ first question.<br>\r\nIf we are told that the hidden number is higher than 5, our
23
+ second question will be \"<b>7</b>\", then we'll know for certain what the hidden
24
+ number is (for a total cost of 5+7=<span style=\"color:blue;\"><b>12</b></span>).<br>\r\nIf
25
+ we are told that the hidden number is lower than 5, our second question will be
26
+ \"<b>3</b>\" and if the hidden number is lower than 3 our third question will be
27
+ \"<b>1</b>\", giving a total cost of 5+3+1=<span style=\"color:blue;\"><b>9</b></span>.<br>\r\nSince
28
+ <span style=\"color:blue;\"><b>12</b></span>&gt;<span style=\"color:blue;\"><b>9</b></span>,
29
+ the worst-case cost for this strategy is <span style=\"color:red;\"><b>12</b></span>.
30
+ That's better than what we achieved previously with the \"binary search\" strategy;
31
+ it is also better than or equal to any other strategy.<br>\r\nSo, in fact, we have
32
+ just described an optimal strategy for <var>n</var>=8.</p>\r\n\r\n<p>Let C(<var>n</var>)
33
+ be the worst-case cost achieved by an optimal strategy for <var>n</var>, as described
34
+ above.<br>\r\nThus C(1) = 0, C(2) = 1, C(3) = 2 and C(8) = 12.<br>\r\nSimilarly,
35
+ C(100) = 400 and <img style=\"vertical-align:middle\" src=\"project/images/p_328_sum1.gif\">C(<var>n</var>)
36
+ = 17575.</p>\r\n\r\n<p>Find <img style=\"vertical-align:middle\" src=\"project/images/p_328_sum2.gif\">C(<var>n</var>).</p>\r\n"
@@ -0,0 +1,17 @@
1
+ ---
2
+ :id: 329
3
+ :name: Prime Frog
4
+ :url: http://projecteuler.net/problem=329
5
+ :content: "\r\n<p>Susan has a prime frog.<br>\r\nHer frog is jumping around over 500
6
+ squares numbered 1 to 500.\r\nHe can only jump one square to the left or to the
7
+ right, with equal probability, and he cannot jump outside the range [1;500].<br>(if
8
+ it lands at either end, it automatically jumps to the only available square on the
9
+ next move.)\r\n</p>\r\n<p>\r\nWhen he is on a square with a prime number on it,
10
+ he croaks 'P' (PRIME) with probability 2/3 or 'N' (NOT PRIME) with probability 1/3
11
+ just before jumping to the next square.<br>\r\nWhen he is on a square with a number
12
+ on it that is not a prime he croaks 'P' with probability 1/3 or 'N' with probability
13
+ 2/3 just before jumping to the next square.\r\n</p>\r\n<p>\r\nGiven that the frog's
14
+ starting position is random with the same probability for every square, and given
15
+ that she listens to his first 15 croaks, what is the probability that she hears
16
+ the sequence PPPPNNPPPNPPNPN?\r\n</p>\r\nGive your answer as a fraction p/q in reduced
17
+ form.\r\n\r\n"
@@ -0,0 +1,13 @@
1
+ ---
2
+ :id: 33
3
+ :name: Digit canceling fractions
4
+ :url: http://projecteuler.net/problem=33
5
+ :content: "\r\n<p>The fraction <sup>49</sup>/<sub>98</sub> is a curious fraction,
6
+ as an inexperienced mathematician in attempting to simplify it may incorrectly believe
7
+ that <sup>49</sup>/<sub>98</sub> = <sup>4</sup>/<sub>8</sub>, which is correct,
8
+ is obtained by cancelling the 9s.</p>\r\n<p>We shall consider fractions like, <sup>30</sup>/<sub>50</sub>
9
+ = <sup>3</sup>/<sub>5</sub>, to be trivial examples.</p>\r\n<p>There are exactly
10
+ four non-trivial examples of this type of fraction, less than one in value, and
11
+ containing two digits in the numerator and denominator.</p>\r\n<p>If the product
12
+ of these four fractions is given in its lowest common terms, find the value of the
13
+ denominator.</p>\r\n\r\n"
@@ -0,0 +1,40 @@
1
+ ---
2
+ :id: 330
3
+ :name: Euler's Number
4
+ :url: http://projecteuler.net/problem=330
5
+ :content: "\r\nAn infinite sequence of real numbers <var>a</var>(<var>n</var>) is
6
+ defined for all integers <var>n</var> as follows:\r\n<div align=\"center\"><img
7
+ src=\"project/images/p_330_formula.gif\"></div>\r\n\r\n<p>For example,<br></p>\n<table
8
+ class=\"formula\"><tr>\n<td>\n<var>a</var>(0) = </td>\r\n <td><table class=\"frac\">\n<tr><td>1</td></tr>\n<tr><td
9
+ class=\"overline\">1!</td></tr>\n</table></td>\r\n <td>+</td>\r\n <td><table
10
+ class=\"frac\">\n<tr><td>1</td></tr>\n<tr><td class=\"overline\">2!</td></tr>\n</table></td>\r\n
11
+ \ <td>+</td>\r\n <td><table class=\"frac\">\n<tr><td>1</td></tr>\n<tr><td class=\"overline\">3!</td></tr>\n</table></td>\r\n
12
+ \ <td>+ ... = e <img src=\"images/symbol_minus.gif\" width=\"9\" height=\"3\"
13
+ alt=\"−\" border=\"0\" style=\"vertical-align:middle;\"> 1 </td>\r\n</tr></table>\n<table
14
+ class=\"formula\"><tr>\n<td>\n<var>a</var>(1) = </td>\r\n <td><table class=\"frac\">\n<tr><td>e
15
+ <img src=\"images/symbol_minus.gif\" width=\"9\" height=\"3\" alt=\"−\" border=\"0\"
16
+ style=\"vertical-align:middle;\"> 1</td></tr>\n<tr><td class=\"overline\">1!</td></tr>\n</table></td>\r\n
17
+ \ <td>+</td>\r\n <td><table class=\"frac\">\n<tr><td>1</td></tr>\n<tr><td class=\"overline\">2!</td></tr>\n</table></td>\r\n
18
+ \ <td>+</td>\r\n <td><table class=\"frac\">\n<tr><td>1</td></tr>\n<tr><td class=\"overline\">3!</td></tr>\n</table></td>\r\n
19
+ \ <td>+ ... = 2e <img src=\"images/symbol_minus.gif\" width=\"9\" height=\"3\"
20
+ alt=\"−\" border=\"0\" style=\"vertical-align:middle;\"> 3 </td>\r\n</tr></table>\n<table
21
+ class=\"formula\"><tr>\n<td>\n<var>a</var>(2) = </td>\r\n <td><table class=\"frac\">\n<tr><td>2e
22
+ <img src=\"images/symbol_minus.gif\" width=\"9\" height=\"3\" alt=\"−\" border=\"0\"
23
+ style=\"vertical-align:middle;\"> 3</td></tr>\n<tr><td class=\"overline\">1!</td></tr>\n</table></td>\r\n
24
+ \ <td>+</td>\r\n <td><table class=\"frac\">\n<tr><td>e <img src=\"images/symbol_minus.gif\"
25
+ width=\"9\" height=\"3\" alt=\"−\" border=\"0\" style=\"vertical-align:middle;\">
26
+ 1</td></tr>\n<tr><td class=\"overline\">2!</td></tr>\n</table></td>\r\n <td>+</td>\r\n
27
+ \ <td><table class=\"frac\">\n<tr><td>1</td></tr>\n<tr><td class=\"overline\">3!</td></tr>\n</table></td>\r\n
28
+ \ <td>+ ... =</td>\r\n <td><table class=\"frac\">\n<tr><td>7</td></tr>\n<tr><td
29
+ class=\"overline\">2</td></tr>\n</table></td>\r\n <td>e <img src=\"images/symbol_minus.gif\"
30
+ width=\"9\" height=\"3\" alt=\"−\" border=\"0\" style=\"vertical-align:middle;\">
31
+ 6 </td>\r\n</tr></table>\r\nwith e = 2.7182818... being Euler's constant.\r\n\r\n<p>\r\n</p>\n<table
32
+ class=\"formula\"><tr>\n<td>It can be shown that <var>a</var>(<var>n</var>) is of
33
+ the form \r\n </td>\r\n <td><table class=\"frac\">\n<tr><td>A(<var>n</var>)
34
+ e + B(<var>n</var>)</td></tr>\n<tr><td class=\"overline\">\n<var>n</var>!</td></tr>\n</table></td>\r\n
35
+ \ <td>for integers A(<var>n</var>) and B(<var>n</var>). \r\n </td>\r\n</tr></table>\n<table
36
+ class=\"formula\"><tr>\n<td>For example <var>a</var>(10) = \r\n </td>\r\n <td><table
37
+ class=\"frac\">\n<tr><td>328161643 e <img src=\"images/symbol_minus.gif\" width=\"9\"
38
+ height=\"3\" alt=\"−\" border=\"0\" style=\"vertical-align:middle;\"> 652694486</td></tr>\n<tr><td
39
+ class=\"overline\">10!</td></tr>\n</table></td>\r\n <td>.</td>\r\n</tr></table>\n<p>\r\nFind
40
+ A(10<sup>9</sup>) + B(10<sup>9</sup>) and give your answer mod 77 777 777.\r\n</p>\r\n\r\n\r\n\r\n"
@@ -0,0 +1,28 @@
1
+ ---
2
+ :id: 331
3
+ :name: Cross flips
4
+ :url: http://projecteuler.net/problem=331
5
+ :content: "\r\n<p><var>N</var><img src=\"images/symbol_times.gif\" width=\"9\" height=\"9\"
6
+ alt=\"×\" border=\"0\" style=\"vertical-align:middle;\"><var>N</var> disks are placed
7
+ on a square game board. Each disk has a black side and white side.</p>\r\n\r\n<p>At
8
+ each turn, you may choose a disk and flip all the disks in the same row and the
9
+ same column as this disk: thus 2<img src=\"images/symbol_times.gif\" width=\"9\"
10
+ height=\"9\" alt=\"×\" border=\"0\" style=\"vertical-align:middle;\"><var>N</var>-1
11
+ disks are flipped. The game ends when all disks show their white side. The following
12
+ example shows a game on a 5<img src=\"images/symbol_times.gif\" width=\"9\" height=\"9\"
13
+ alt=\"×\" border=\"0\" style=\"vertical-align:middle;\">5 board.</p>\r\n\r\n<div
14
+ align=\"center\"><img src=\"project/images/p_331_crossflips3.gif\"></div>\r\n\r\n<p>It
15
+ can be proven that 3 is the minimal number of turns to finish this game.</p>\r\n\r\n<p>The
16
+ bottom left disk on the <var>N</var><img src=\"images/symbol_times.gif\" width=\"9\"
17
+ height=\"9\" alt=\"×\" border=\"0\" style=\"vertical-align:middle;\"><var>N</var>
18
+ board has coordinates (0,0);<br>\r\nthe bottom right disk has coordinates (<var>N</var>-1,0)
19
+ and the top left disk has coordinates (0,<var>N</var>-1). </p>\r\n\r\n<p>Let C<sub><var>N</var></sub>
20
+ be the following configuration of a board with <var>N</var><img src=\"images/symbol_times.gif\"
21
+ width=\"9\" height=\"9\" alt=\"×\" border=\"0\" style=\"vertical-align:middle;\"><var>N</var>
22
+ disks:<br>\r\nA disk at (<var>x</var>,<var>y</var>) satisfying <img style=\"vertical-align:middle\"
23
+ src=\"project/images/p_331_crossflips1.gif\">, shows its black side; otherwise,
24
+ it shows its white side. C<sub>5</sub> is shown above.</p>\r\n\r\n<p>Let T(<var>N</var>)
25
+ be the minimal number of turns to finish a game starting from configuration C<sub><var>N</var></sub>
26
+ or 0 if configuration C<sub><var>N</var></sub> is unsolvable.<br>\r\nWe have shown
27
+ that T(5)=3. You are also given that T(10)=29 and T(1 000)=395253.</p>\r\n\r\n<p>Find
28
+ <img style=\"vertical-align:middle\" src=\"project/images/p_331_crossflips2.gif\">.</p>\r\n\r\n"
@@ -0,0 +1,16 @@
1
+ ---
2
+ :id: 332
3
+ :name: Spherical triangles
4
+ :url: http://projecteuler.net/problem=332
5
+ :content: "\r\n<p>A <b>spherical triangle</b> is a figure formed on the surface of
6
+ a sphere by three <b>great circular arcs</b> intersecting pairwise in three vertices.</p>\r\n\r\n<div
7
+ align=\"center\"><img src=\"project/images/p_332_spherical.jpg\"></div>\r\n\r\n\r\n<p>Let
8
+ C(<var>r</var>) be the sphere with the centre (0,0,0) and radius <var>r</var>.<br>\r\nLet
9
+ Z(<var>r</var>) be the set of points on the surface of C(<var>r</var>) with integer
10
+ coordinates.<br>\r\nLet T(<var>r</var>) be the set of spherical triangles with vertices
11
+ in Z(<var>r</var>).\r\nDegenerate spherical triangles, formed by three points on
12
+ the same great arc, are <u>not</u> included in T(<var>r</var>).<br>\r\nLet A(<var>r</var>)
13
+ be the area of the smallest spherical triangle in T(<var>r</var>).</p>\r\n\r\n<p>For
14
+ example A(14) is 3.294040 rounded to six decimal places.</p>\r\n\r\n<p>Find <img
15
+ style=\"vertical-align:middle\" src=\"project/images/p_332_sum.gif\"> A(<var>r</var>).
16
+ Give your answer rounded to six decimal places.</p>\r\n\r\n"
@@ -0,0 +1,25 @@
1
+ ---
2
+ :id: 333
3
+ :name: Special partitions
4
+ :url: http://projecteuler.net/problem=333
5
+ :content: "\r\n<p>All positive integers can be partitioned in such a way that each
6
+ and every term of the partition can be expressed as 2<sup>i</sup>x3<sup>j</sup>,
7
+ where i,j <img src=\"images/symbol_ge.gif\" width=\"10\" height=\"12\" alt=\"≥\"
8
+ border=\"0\" style=\"vertical-align:middle;\"> 0.</p>\r\n\r\n<p>Let's consider only
9
+ those such partitions where none of the terms can divide any of the other terms.\r\n<br>For
10
+ example, the partition of 17 = 2 + 6 + 9 = (2<sup>1</sup>x3<sup>0</sup> + 2<sup>1</sup>x3<sup>1</sup>
11
+ + 2<sup>0</sup>x3<sup>2</sup>) would not be valid since 2 can divide 6. Neither
12
+ would the partition 17 = 16 + 1 = (2<sup>4</sup>x3<sup>0</sup> + 2<sup>0</sup>x3<sup>0</sup>)
13
+ since 1 can divide 16. The only valid partition of 17 would be 8 + 9 = (2<sup>3</sup>x3<sup>0</sup>
14
+ + 2<sup>0</sup>x3<sup>2</sup>).</p>\r\n\r\n<p>Many integers have more than one valid
15
+ partition, the first being 11 having the following two partitions.\r\n<br>11 = 2
16
+ + 9 = (2<sup>1</sup>x3<sup>0</sup> + 2<sup>0</sup>x3<sup>2</sup>)\r\n<br>11 = 8
17
+ + 3 = (2<sup>3</sup>x3<sup>0</sup> + 2<sup>0</sup>x3<sup>1</sup>)</p>\r\n\r\n<p>Let's
18
+ define P(<var>n</var>) as the number of valid partitions of <var>n</var>. For example,
19
+ P(11) = 2.</p>\r\n\r\n<p>Let's consider only the prime integers <var>q</var> which
20
+ would have a single valid partition such as P(17).</p>\r\n\r\n<p>The sum of the
21
+ primes <var>q</var> <img src=\"images/symbol_lt.gif\" width=\"10\" height=\"10\"
22
+ alt=\"&lt;\" border=\"0\" style=\"vertical-align:middle;\">100 such that P(<var>q</var>)=1
23
+ equals 233.</p>\r\n\r\n<p>Find the sum of the primes <var>q</var> <img src=\"images/symbol_lt.gif\"
24
+ width=\"10\" height=\"10\" alt=\"&lt;\" border=\"0\" style=\"vertical-align:middle;\">1000000
25
+ such that P(<var>q</var>)=1.</p>\r\n"
@@ -0,0 +1,39 @@
1
+ ---
2
+ :id: 334
3
+ :name: Spilling the beans
4
+ :url: http://projecteuler.net/problem=334
5
+ :content: "\r\n<p>In Plato's heaven, there exist an infinite number of bowls in a
6
+ straight line.<br>\r\nEach bowl either contains some or none of a finite number
7
+ of beans.<br>\r\nA child plays a game, which allows only one kind of move: removing
8
+ two beans from any bowl, and putting one in each of the two adjacent bowls.<br>
9
+ The game ends when each bowl contains either one or no beans.</p>\r\n\r\n<p>For
10
+ example, consider two adjacent bowls containing 2 and 3 beans respectively, all
11
+ other bowls being empty. The following eight moves will finish the game:</p>\r\n\r\n<div
12
+ align=\"center\"><img src=\"project/images/p_334_beans.gif\"></div>\r\n\r\n<p>You
13
+ are given the following sequences:<br></p>\n<table class=\"formula\" style=\"margin-left:50px;\"><tr>\n<td>\r\n
14
+ \ <var>t</var><sub><i>0</i></sub> = 123456.\r\n </td>\r\n</tr></table>\n<table
15
+ class=\"formula\" style=\"margin-left:50px;\">\n<tr>\n<td>\r\n <var>t</var><sub><i>i</i></sub>
16
+ = \r\n </td>\r\n <td><img src=\"project/images/p_334_cases.gif\"></td>\r\n <td>\r\n
17
+ \ <table class=\"formula\">\n<tr>\n<td></td>\r\n <td>\r\n <table class=\"frac\">\n<tr><td>\n<var>t</var><sub><i>i-1</i></sub>\n</td></tr>\n<tr><td
18
+ class=\"overline\">2</td></tr>\n</table>\n</td>\r\n <td>\r\n ,\r\n
19
+ \ </td>\r\n <td></td>\r\n <td>\r\n if <var>t</var><sub><i>i-1</i></sub>
20
+ is even\r\n </td>\r\n </tr>\n<tr>\n<td><img src=\"project/images/p_334_lfloor.gif\"></td>\r\n
21
+ \ <td>\r\n <table class=\"frac\">\n<tr><td>\n<var>t</var><sub><i>i-1</i></sub>\n</td></tr>\n<tr><td
22
+ class=\"overline\">2</td></tr>\n</table>\n</td>\r\n <td>\r\n <img src=\"project/images/p_334_rfloor.gif\">\n</td>\r\n
23
+ \ <td>\r\n 926252, \r\n </td>\r\n <td>\r\n if <var>t</var><sub><i>i-1</i></sub>
24
+ is odd\r\n </td>\r\n </tr>\n</table>\n</td>\n<td>\r\n</td>\n</tr>\n<tr>\n<td></td>\r\n
25
+ \ <td></td>\r\n <td>\r\n where <img src=\"images/symbol_lfloor.gif\" width=\"6\"
26
+ height=\"16\" alt=\"⌊\" border=\"0\" style=\"vertical-align:middle;\"><var>x</var><img
27
+ src=\"images/symbol_rfloor.gif\" width=\"6\" height=\"16\" alt=\"⌋\" border=\"0\"
28
+ style=\"vertical-align:middle;\"> is the floor function\r\n </td>\r\n</tr>\n<tr>\n<td></td>\r\n
29
+ \ <td></td>\r\n <td>\r\n and <img src=\"project/images/p_334_oplus.gif\">
30
+ is the bitwise XOR operator.\r\n </td>\r\n</tr>\n</table>\n<table class=\"formula\"
31
+ style=\"margin-left:50px;\"><tr>\n<td>\r\n <var>b</var><sub><i>i</i></sub>
32
+ = ( <var>t</var><sub><i>i</i></sub> mod 2<sup>11</sup>) + 1.\r\n </td>\r\n</tr></table>\n<p>The
33
+ first two terms of the last sequence are <var>b</var><sub><i>1</i></sub> = 289 and
34
+ <var>b</var><sub><i>2</i></sub> = 145.<br>\r\nIf we start with <var>b</var><sub><i>1</i></sub>
35
+ and <var>b</var><sub><i>2</i></sub> beans in two adjacent bowls, 3419100 moves would
36
+ be required to finish the game.</p>\r\n\r\n<p>Consider now 1500 adjacent bowls containing
37
+ <var>b</var><sub><i>1</i></sub>, <var>b</var><sub><i>2</i></sub>,..., <var>b</var><sub><i>1500</i></sub>
38
+ beans respectively, all other bowls being empty. Find how many moves it takes before
39
+ the game ends.</p>\r\n\r\n\r\n"
@@ -0,0 +1,16 @@
1
+ ---
2
+ :id: 335
3
+ :name: Gathering the beans
4
+ :url: http://projecteuler.net/problem=335
5
+ :content: "\r\n<p>Whenever Peter feels bored, he places some bowls, containing one
6
+ bean each, in a circle. After this, he takes all the beans out of a certain bowl
7
+ and drops them one by one in the bowls going clockwise. He repeats this, starting
8
+ from the bowl he dropped the last bean in, until the initial situation appears again.
9
+ For example with 5 bowls he acts as follows:</p>\r\n\r\n<div align=\"center\"><img
10
+ src=\"project/images/p_335_mancala.gif\"></div>\r\n\r\n<p>So with 5 bowls it takes
11
+ Peter 15 moves to return to the initial situation.</p>\r\n\r\n<p>Let <var>M</var>(<var>x</var>)
12
+ represent the number of moves required to return to the initial situation, starting
13
+ with <var>x</var> bowls. Thus, <var>M</var>(5) = 15. It can also be verified that
14
+ <var>M</var>(100) = 10920.</p>\r\n\r\n<p>Find <img style=\"vertical-align:middle\"
15
+ src=\"project/images/p_335_sum.gif\"><var>M</var>(2<sup><var>k</var></sup>+1). Give
16
+ your answer modulo 7<sup>9</sup>.</p>\r\n\r\n\r\n"
@@ -0,0 +1,24 @@
1
+ ---
2
+ :id: 336
3
+ :name: Maximix Arrangements
4
+ :url: http://projecteuler.net/problem=336
5
+ :content: "\r\n<p>A train is used to transport four carriages in the order: ABCD.
6
+ However, sometimes when the train arrives to collect the carriages they are not
7
+ in the correct order. <br>\r\nTo rearrange the carriages they are all shunted on
8
+ to a large rotating turntable. After the carriages are uncoupled at a specific point
9
+ the train moves off the turntable pulling the carriages still attached with it.
10
+ The remaining carriages are rotated 180 degrees. All of the carriages are then rejoined
11
+ and this process is repeated as often as necessary in order to obtain the least
12
+ number of uses of the turntable.<br>\r\nSome arrangements, such as ADCB, can be
13
+ solved easily: the carriages are separated between A and D, and after DCB are rotated
14
+ the correct order has been achieved.</p>\r\n\r\n<p>However, Simple Simon, the train
15
+ driver, is not known for his efficiency, so he always solves the problem by initially
16
+ getting carriage A in the correct place, then carriage B, and so on.</p>\r\n\r\n<p>Using
17
+ four carriages, the worst possible arrangements for Simon, which we shall call <i>maximix
18
+ arrangements</i>, are DACB and DBAC; each requiring him five rotations (although,
19
+ using the most efficient approach, they could be solved using just three rotations).
20
+ The process he uses for DACB is shown below.</p>\r\n\r\n<div align=\"center\"><img
21
+ src=\"project/images/p_336_maximix.gif\"></div>\r\n\r\n\r\n<p>It can be verified
22
+ that there are 24 maximix arrangements for six carriages, of which the tenth lexicographic
23
+ maximix arrangement is DFAECB.</p>\r\n\r\n<p>Find the 2011<sup>th</sup> lexicographic
24
+ maximix arrangement for eleven carriages.</p>\r\n\r\n"
@@ -0,0 +1,15 @@
1
+ ---
2
+ :id: 337
3
+ :name: Totient Stairstep Sequences
4
+ :url: http://projecteuler.net/problem=337
5
+ :content: "\r\n<p>Let {a<sub>1</sub>, a<sub>2</sub>,..., a<sub><var>n</var></sub>}
6
+ be an integer sequence of length <var>n</var> such that:</p>\r\n<ul>\n<li>a<sub>1</sub>
7
+ = 6</li>\r\n<li>for all 1 <img src=\"images/symbol_le.gif\" width=\"10\" height=\"12\"
8
+ alt=\"≤\" border=\"0\" style=\"vertical-align:middle;\"><var>i</var> n : φ(a<sub><var>i</var></sub>)
9
+ <var>i</var>+1) <var>i</var> <var>i</var>+1 <sup>1</sup>\n</li>\r\n</ul>\n<p>Let
10
+ S(<var>N</var>) be the number of such sequences with a<sub><var>n</var></sub><img
11
+ src=\"images/symbol_le.gif\" width=\"10\" height=\"12\" alt=\"≤\" border=\"0\" style=\"vertical-align:middle;\"><var>N</var>.<br>\r\nFor
12
+ example, S(10) = 4: {6}, {6, 8}, {6, 8, 9} and {6, 10}.<br>\r\nWe can verify that
13
+ S(100) = 482073668 and S(10 000) mod 10<sup>8</sup> = 73808307.</p>\r\n\r\n<p>Find
14
+ S(20 000 000) mod 10<sup>8</sup>.</p>\r\n\r\n<p><sup>1</sup> φ denotes <b>Euler's
15
+ totient function</b>.</p>\r\n\r\n"
@@ -0,0 +1,41 @@
1
+ ---
2
+ :id: 338
3
+ :name: Cutting Rectangular Grid Paper
4
+ :url: http://projecteuler.net/problem=338
5
+ :content: "\r\n<p>A rectangular sheet of grid paper with integer dimensions <var>w</var>
6
+ <img src=\"images/symbol_times.gif\" width=\"9\" height=\"9\" alt=\"×\" border=\"0\"
7
+ style=\"vertical-align:middle;\"><var>h</var> is given. Its grid spacing is 1.<br>\r\nWhen
8
+ we cut the sheet along the grid lines into two pieces and rearrange those pieces
9
+ without overlap, we can make new rectangles with different dimensions.</p>\r\n<p>For
10
+ example, from a sheet with dimensions 9 <img src=\"images/symbol_times.gif\" width=\"9\"
11
+ height=\"9\" alt=\"×\" border=\"0\" style=\"vertical-align:middle;\"> 4 , we can
12
+ make rectangles with dimensions 18 <img src=\"images/symbol_times.gif\" width=\"9\"
13
+ height=\"9\" alt=\"×\" border=\"0\" style=\"vertical-align:middle;\"> 2, 12 <img
14
+ src=\"images/symbol_times.gif\" width=\"9\" height=\"9\" alt=\"×\" border=\"0\"
15
+ style=\"vertical-align:middle;\"> 3 and 6 <img src=\"images/symbol_times.gif\" width=\"9\"
16
+ height=\"9\" alt=\"×\" border=\"0\" style=\"vertical-align:middle;\"> 6 by cutting
17
+ and rearranging as below:</p>\r\n\r\n<div align=\"center\">\r\n<img src=\"project/images/p_338_gridpaper.gif\"><br>\n</div>\r\n\r\n<p>Similarly,
18
+ from a sheet with dimensions 9 <img src=\"images/symbol_times.gif\" width=\"9\"
19
+ height=\"9\" alt=\"×\" border=\"0\" style=\"vertical-align:middle;\"> 8 , we can
20
+ make rectangles with dimensions 18 <img src=\"images/symbol_times.gif\" width=\"9\"
21
+ height=\"9\" alt=\"×\" border=\"0\" style=\"vertical-align:middle;\"> 4 and 12 <img
22
+ src=\"images/symbol_times.gif\" width=\"9\" height=\"9\" alt=\"×\" border=\"0\"
23
+ style=\"vertical-align:middle;\"> 6 .</p>\r\n\r\n<p>For a pair <var>w</var> and
24
+ <var>h</var>, let F(<var>w</var>,<var>h</var>) be the number of distinct rectangles
25
+ that can be made from a sheet with dimensions <var>w</var> <img src=\"images/symbol_times.gif\"
26
+ width=\"9\" height=\"9\" alt=\"×\" border=\"0\" style=\"vertical-align:middle;\"><var>h</var>
27
+ .<br>\r\nFor example, F(2,1) = 0, F(2,2) = 1, F(9,4) = 3 and F(9,8) = 2. <br>\r\nNote
28
+ that rectangles congruent to the initial one are not counted in F(<var>w</var>,<var>h</var>).<br>\r\nNote
29
+ also that rectangles with dimensions <var>w</var> <img src=\"images/symbol_times.gif\"
30
+ width=\"9\" height=\"9\" alt=\"×\" border=\"0\" style=\"vertical-align:middle;\"><var>h</var>
31
+ and dimensions <var>h</var> <img src=\"images/symbol_times.gif\" width=\"9\" height=\"9\"
32
+ alt=\"×\" border=\"0\" style=\"vertical-align:middle;\"><var>w</var> are not considered
33
+ distinct.</p>\r\n\r\n<p>For an integer <var>N</var>, let G(<var>N</var>) be the
34
+ sum of F(<var>w</var>,<var>h</var>) for all pairs <var>w</var> and <var>h</var>
35
+ which satisfy 0 <img src=\"images/symbol_lt.gif\" width=\"10\" height=\"10\" alt=\"&lt;\"
36
+ border=\"0\" style=\"vertical-align:middle;\"><var>h</var> <img src=\"images/symbol_le.gif\"
37
+ width=\"10\" height=\"12\" alt=\"≤\" border=\"0\" style=\"vertical-align:middle;\"><var>w</var>
38
+ <img src=\"images/symbol_le.gif\" width=\"10\" height=\"12\" alt=\"≤\" border=\"0\"
39
+ style=\"vertical-align:middle;\"><var>N</var>.<br>\r\nWe can verify that G(10) =
40
+ 55, G(10<sup>3</sup>) = 971745 and G(10<sup>5</sup>) = 9992617687.</p>\r\n\r\n<p>Find
41
+ G(10<sup>12</sup>). Give your answer modulo 10<sup>8</sup>.</p>\r\n"
@@ -0,0 +1,17 @@
1
+ ---
2
+ :id: 339
3
+ :name: Peredur fab Efrawg
4
+ :url: http://projecteuler.net/problem=339
5
+ :content: "\r\n<p>\r\n<i>\"And he came towards a valley, through which ran a river;
6
+ and the borders of the valley were wooded, and on each side of the river were level
7
+ meadows. And on one side of the river he saw a flock of white sheep, and on the
8
+ other a flock of black sheep. And whenever one of the white sheep bleated, one of
9
+ the black sheep would cross over and become white; and when one of the black sheep
10
+ bleated, one of the white sheep would cross over and become black.\"</i><br><a href=\"http://en.wikisource.org/wiki/The_Mabinogion/Peredur_the_Son_of_Evrawc\">en.wikisource.org</a>\r\n</p>\r\n<p>\r\n\r\nInitially
11
+ each flock consists of <var>n</var> sheep. Each sheep (regardless of colour) is
12
+ equally likely to be the next sheep to bleat. After a sheep has bleated and a sheep
13
+ from the other flock has crossed over, Peredur may remove a number of white sheep
14
+ in order to maximize the expected final number of black sheep. Let E(<var>n</var>)
15
+ be the expected final number of black sheep if Peredur uses an optimal strategy.\r\n</p>\r\n<p>\r\n\r\nYou
16
+ are given that E(5) = 6.871346 rounded to 6 places behind the decimal point.<br>\r\nFind
17
+ E(10 000) and give your answer rounded to 6 places behind the decimal point.\r\n</p>\r\n\r\n\r\n"
@@ -0,0 +1,7 @@
1
+ ---
2
+ :id: 34
3
+ :name: Digit factorials
4
+ :url: http://projecteuler.net/problem=34
5
+ :content: "\r\n\n<p>145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.</p>\n<p>Find
6
+ the sum of all numbers which are equal to the sum of the factorial of their digits.</p>\n<p
7
+ class=\"info\">Note: as 1! = 1 and 2! = 2 are not sums they are not included.</p>\n\r\n"
@@ -0,0 +1,14 @@
1
+ ---
2
+ :id: 340
3
+ :name: Crazy Function
4
+ :url: http://projecteuler.net/problem=340
5
+ :content: "\r\n<p>\r\nFor fixed integers a, b, c, define the <i>crazy function</i>
6
+ F(<var>n</var>) as follows:<br>\r\nF(<var>n</var>) = <var>n</var> - c for all <var>n</var>
7
+ <img src=\"images/symbol_gt.gif\" width=\"10\" height=\"10\" alt=\"&gt;\" border=\"0\"
8
+ style=\"vertical-align:middle;\"> b <br>\r\nF(<var>n</var>) = F(a + F(a + F(a +
9
+ F(a + <var>n</var>)))) for all <var>n</var> <img src=\"images/symbol_le.gif\" width=\"10\"
10
+ height=\"12\" alt=\"≤\" border=\"0\" style=\"vertical-align:middle;\"> b.\r\n</p>\r\n<p>\r\nAlso,
11
+ define S(a, b, c) = <img src=\"project/images/p_340_formula.gif\" style=\"vertical-align:middle;\">.\r\n</p>\r\n<p>\r\nFor
12
+ example, if a = 50, b = 2000 and c = 40, then F(0) = 3240 and F(2000) = 2040.<br>\r\nAlso,
13
+ S(50, 2000, 40) = 5204240.\r\n</p>\r\n<p>\r\nFind the last 9 digits of S(21<sup>7</sup>,
14
+ 7<sup>21</sup>, 12<sup>7</sup>).\r\n</p>\r\n\r\n\r\n\r\n\r\n\r\n"
@@ -0,0 +1,18 @@
1
+ ---
2
+ :id: 341
3
+ :name: Golomb's self-describing sequence
4
+ :url: http://projecteuler.net/problem=341
5
+ :content: "\r\n<p>The <b>Golomb's self-describing sequence</b> {G(<var>n</var>)} is
6
+ the only nondecreasing sequence of natural numbers such that <var>n</var> appears
7
+ exactly G(<var>n</var>) times in the sequence. The values of G(<var>n</var>) for
8
+ the first few <var>n</var> are</p>\r\n\r\n<p></p>\n<div align=\"center\">\r\n<table
9
+ cellspacing=\"1\" cellpadding=\"5\" border=\"0\" align=\"center\">\n<tr>\n<td align=\"left\"><var>n</var></td>\n<td>1</td>\n<td>2</td>\n<td>3</td>\n<td>4</td>\n<td>5</td>\n<td>6</td>\n<td>7</td>\n<td>8</td>\n<td>9</td>\n<td>10</td>\n<td>11</td>\n<td>12</td>\n<td>13</td>\n<td>14</td>\n<td>15</td>\n<td>…</td>\n</tr>\n<tr>\n<td>G(<var>n</var>)</td>\n<td>1</td>\n<td>2</td>\n<td>2</td>\n<td>3</td>\n<td>3</td>\n<td>4</td>\n<td>4</td>\n<td>4</td>\n<td>5</td>\n<td>5</td>\n<td>5</td>\n<td>6</td>\n<td>6</td>\n<td>6</td>\n<td>6</td>\n<td>…</td>\n</tr>\n</table>\n</div>\r\n\r\n<p>You
10
+ are given that G(10<sup>3</sup>) = 86, G(10<sup>6</sup>) = 6137.<br>\r\nYou are
11
+ also given that ΣG(<var>n</var><sup>3</sup>) = 153506976 for 1 <img src=\"images/symbol_le.gif\"
12
+ width=\"10\" height=\"12\" alt=\"≤\" border=\"0\" style=\"vertical-align:middle;\"><var>n</var>
13
+ <img src=\"images/symbol_lt.gif\" width=\"10\" height=\"10\" alt=\"&lt;\" border=\"0\"
14
+ style=\"vertical-align:middle;\"> 10<sup>3</sup>.</p>\r\n\r\n<p>Find ΣG(<var>n</var><sup>3</sup>)
15
+ for 1 <img src=\"images/symbol_le.gif\" width=\"10\" height=\"12\" alt=\"≤\" border=\"0\"
16
+ style=\"vertical-align:middle;\"><var>n</var> <img src=\"images/symbol_lt.gif\"
17
+ width=\"10\" height=\"10\" alt=\"&lt;\" border=\"0\" style=\"vertical-align:middle;\">
18
+ 10<sup>6</sup>.</p>\r\n\r\n\r\n"
@@ -0,0 +1,17 @@
1
+ ---
2
+ :id: 342
3
+ :name: The totient of a square is a cube
4
+ :url: http://projecteuler.net/problem=342
5
+ :content: "\r\n<p>\r\nConsider the number 50.<br>\r\n50<sup>2</sup> = 2500 = 2<sup>2</sup><img
6
+ src=\"images/symbol_times.gif\" width=\"9\" height=\"9\" alt=\"×\" border=\"0\"
7
+ style=\"vertical-align:middle;\"> 5<sup>4</sup>, so φ(2500) = 2 <img src=\"images/symbol_times.gif\"
8
+ width=\"9\" height=\"9\" alt=\"×\" border=\"0\" style=\"vertical-align:middle;\">
9
+ 4 <img src=\"images/symbol_times.gif\" width=\"9\" height=\"9\" alt=\"×\" border=\"0\"
10
+ style=\"vertical-align:middle;\"> 5<sup>3</sup> = 8 <img src=\"images/symbol_times.gif\"
11
+ width=\"9\" height=\"9\" alt=\"×\" border=\"0\" style=\"vertical-align:middle;\">
12
+ 5<sup>3</sup> = 2<sup>3</sup><img src=\"images/symbol_times.gif\" width=\"9\" height=\"9\"
13
+ alt=\"×\" border=\"0\" style=\"vertical-align:middle;\"> 5<sup>3</sup>. <sup>1</sup><br>\r\nSo
14
+ 2500 is a square and φ(2500) is a cube.\r\n</p>\r\n<p>\r\nFind the sum of all numbers
15
+ n, 1 &amp;lt n <img src=\"images/symbol_lt.gif\" width=\"10\" height=\"10\" alt=\"&lt;\"
16
+ border=\"0\" style=\"vertical-align:middle;\"> 10<sup>10</sup> such that φ(n<sup>2</sup>)
17
+ is a cube.\r\n</p>\r\n<p>\r\n<sup>1</sup> φ denotes <b>Euler's totient function</b>.\r\n</p>\r\n\r\n\r\n\r\n"
@@ -0,0 +1,29 @@
1
+ ---
2
+ :id: 343
3
+ :name: Fractional Sequences
4
+ :url: http://projecteuler.net/problem=343
5
+ :content: "\r\n<p>For any positive integer <var>k</var>, a finite sequence a<sub><var>i</var></sub>
6
+ of fractions x<sub><var>i</var></sub>/y<sub><var>i</var></sub> is defined by:<br>\r\na<sub>1</sub>
7
+ = 1/<var>k</var> and<br>\r\na<sub><var>i</var></sub> = (x<sub><var>i</var>-1</sub>+1)/(y<sub><var>i</var>-1</sub>-1)
8
+ reduced to lowest terms for <var>i</var>&gt;1.<br>\r\nWhen a<sub><var>i</var></sub>
9
+ reaches some integer <var>n</var>, the sequence stops. (That is, when y<sub><var>i</var></sub>=1.)<br>\r\nDefine
10
+ f(<var>k</var>) = <var>n</var>. <br>\r\nFor example, for <var>k</var> = 20:\r\n</p>\r\n\r\n<p>\r\n1/20
11
+ <img src=\"images/symbol_maps.gif\" width=\"15\" height=\"7\" alt=\"→\" border=\"0\"
12
+ style=\"vertical-align:middle;\"> 2/19 <img src=\"images/symbol_maps.gif\" width=\"15\"
13
+ height=\"7\" alt=\"→\" border=\"0\" style=\"vertical-align:middle;\"> 3/18 = 1/6
14
+ <img src=\"images/symbol_maps.gif\" width=\"15\" height=\"7\" alt=\"→\" border=\"0\"
15
+ style=\"vertical-align:middle;\"> 2/5 <img src=\"images/symbol_maps.gif\" width=\"15\"
16
+ height=\"7\" alt=\"→\" border=\"0\" style=\"vertical-align:middle;\"> 3/4 <img src=\"images/symbol_maps.gif\"
17
+ width=\"15\" height=\"7\" alt=\"→\" border=\"0\" style=\"vertical-align:middle;\">
18
+ 4/3 <img src=\"images/symbol_maps.gif\" width=\"15\" height=\"7\" alt=\"→\" border=\"0\"
19
+ style=\"vertical-align:middle;\"> 5/2 <img src=\"images/symbol_maps.gif\" width=\"15\"
20
+ height=\"7\" alt=\"→\" border=\"0\" style=\"vertical-align:middle;\"> 6/1 = 6\r\n</p>\r\n\r\n<p>\r\nSo
21
+ f(20) = 6.\r\n</p>\r\n\r\n<p>\r\nAlso f(1) = 1, f(2) = 2, f(3) = 1 and Σf(<var>k</var><sup>3</sup>)
22
+ = 118937 for 1 <img src=\"images/symbol_le.gif\" width=\"10\" height=\"12\" alt=\"≤\"
23
+ border=\"0\" style=\"vertical-align:middle;\"><var>k</var> <img src=\"images/symbol_le.gif\"
24
+ width=\"10\" height=\"12\" alt=\"≤\" border=\"0\" style=\"vertical-align:middle;\">
25
+ 100.\r\n</p>\r\n\r\n<p>\r\nFind Σf(<var>k</var><sup>3</sup>) for 1 <img src=\"images/symbol_le.gif\"
26
+ width=\"10\" height=\"12\" alt=\"≤\" border=\"0\" style=\"vertical-align:middle;\"><var>k</var>
27
+ <img src=\"images/symbol_le.gif\" width=\"10\" height=\"12\" alt=\"≤\" border=\"0\"
28
+ style=\"vertical-align:middle;\"> 2<img src=\"images/symbol_times.gif\" width=\"9\"
29
+ height=\"9\" alt=\"×\" border=\"0\" style=\"vertical-align:middle;\">10<sup>6</sup>.\r\n</p>\r\n"