Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/06/2019 in all areas

  1. This begs the question, "Why the phuk are you boring us to death here, on what is basically a PHP site, with all this Python stuff when you could be doing it to the members of "python-forum.io?"
    1 point
  2. The $freqs array contains the counts for P1, P2 , P3 for each digit... $freqs = Array ( [0] => Array # digit "0" ( [0] => 4 # P1 [1] => 7 # P2 [2] => 1 # P3 ) [1] => Array ( [0] => 3 [1] => 2 [2] => 6 ) [2] => Array ( [0] => 4 [1] => 4 [2] => 6 ) which, coincidentally, is the same structure as the output table. You now loop through the array and for each digit (row) loop through its array (positions columns) and build the table. // // create frequncy table and calc digit totals // $totals = array_fill_keys(range(0,9), []); $tdata = ''; foreach ($freqs as $n => $occs) { $tdata .= "<tr><td><b>$n</b></td>"; foreach ($occs as $o) { $tdata .= "<td>$o</td>"; } $total = array_sum($occs); $totals[$n] = [$n,$total]; $tdata .= "<td>=</td><td><b>$total</b></td></tr>\n"; } My complete solution...
    1 point
This leaderboard is set to New York/GMT-04:00
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.