Restructuring
This commit is contained in:
		
							
								
								
									
										10
									
								
								solutions/ProjectEuler/031/desc.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								solutions/ProjectEuler/031/desc.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| title: Investigating combinations of English currency denominations. | ||||
| url: http://projecteuler.net/problem=31 | ||||
|  | ||||
| desc: | | ||||
|   In England the currency is made up of pound, £ and pence, p, and there are eight coins in general circulation: | ||||
|   1p, 2p, 5p, 10p, 20p, 50p, ñ (100p) and £ (200p). | ||||
|   It is possible to make £ in the following way: | ||||
|   1£ + 150p + 220p + 15p + 12p + 31p | ||||
|   How many different ways can £ be made using any number of coins? | ||||
| solution: Define the target value as 200 to simplify | ||||
							
								
								
									
										34
									
								
								solutions/ProjectEuler/031/problem31.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								solutions/ProjectEuler/031/problem31.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,34 @@ | ||||
| <?php | ||||
| define("TOTAL", 200); | ||||
| $combo=0; | ||||
| $sum = 200; | ||||
|  | ||||
| for ($a = 0; $a <= (TOTAL / 200); $a++) { | ||||
|     $sum_a = TOTAL - ($a * 200); | ||||
|     for ($b = 0; $b <= ($sum_a / 100); $b++) { | ||||
|         $sum_b = $sum_a - ($b * 100); | ||||
|         for ($c = 0; $c <= ($sum_b / 50); $c++) { | ||||
|             $sum_c = $sum_b - ($c * 50); | ||||
|             for ($d = 0; $d <= ($sum_c / 20); $d++) { | ||||
|                 $sum_d = $sum_c - ($d * 20); | ||||
|                 for ($e = 0; $e <= ($sum_d / 10); $e++) { | ||||
|                     $sum_e = $sum_d - ($e * 10); | ||||
|                     for ($f = 0; $f <= ($sum_e / 5); $f++) { | ||||
|                         $sum_f = $sum_e - ($f * 5); | ||||
|                         for ($g = 0; $g <= ($sum_e / 2); $g++) { | ||||
|                             $sum_g = $sum_f - ($g * 2); | ||||
|                             for ($h = 0; $h <= ($sum_g / 1); $h++) { | ||||
|  | ||||
|                                 if ($a * 200 + $b * 100 + $c * 50 + $d * 20 + $e * 10 + $f * 5 + $g * 2 + $h == TOTAL) { | ||||
|                                     $combo++; | ||||
|                                 } | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| echo $combo; | ||||
							
								
								
									
										4
									
								
								solutions/ProjectEuler/031/solve.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								solutions/ProjectEuler/031/solve.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,4 @@ | ||||
| <?php | ||||
| $start = 200; | ||||
|  | ||||
| for($c = 0; $c > $left; $c++); | ||||
		Reference in New Issue
	
	Block a user