fork download
  1. <?php
  2. header('Content-type: text/plain; charset=utf-8');
  3. $digits=array(11,10,18,7,14,17,12,11);
  4. $size = count($digits);
  5. $sum = array_sum($digits);
  6. for ($i = 0; $i < $size-1; $i++) {
  7. $new_digits = array();
  8. for ($j = $i; $j < $size-1; $j++) {
  9. $new_digits[] = $digits[$j];
  10. $new_digits_sum = array_sum($new_digits);
  11. if ($new_digits_sum*2 == $sum) {
  12. $str = implode("+", $new_digits);
  13. echo $str." = ";
  14. $another_new_digits = array();
  15. for ($q = 0; $q < $i; $q++) {
  16. $another_new_digits[] = $digits[$q];
  17. }
  18. for ($q = $j + 1; $q < $size; $q++)
  19. {
  20. $another_new_digits[] = $digits[$q];
  21. }
  22. $str = implode("+", $another_new_digits);
  23. echo $str."\n";
  24. }
  25. if ($new_digits_sum == 100) {
  26. $str = implode("+", $new_digits);
  27. echo $str." = 100\n";
  28. }
  29. }
  30. }
  31. if ($sum == 100) {
  32. $str = implode("+", $digits);
  33. echo $str." = 100\n";
  34. }
  35. ?>
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
7+14+17+12 = 11+10+18+11
11+10+18+7+14+17+12+11 = 100