What is the most frequent absolute value of determinant of 2x2 matrices with integer [-9,9] elements

This problem’s question: {\color{#D61F06}\text{This problem's question:}} What is the most frequent absolute value of the determinant of all possible 2x2 matrices with integer elements with values from -9 to 9 inclusive?


The answer is 12.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

3 solutions

Kyle T
Jul 8, 2019

My solution in PHP

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
<?php
$min = -9;
$max = 9;
$det = array();
for($a=$min;$a<=$max;$a++){
    for($b=$min;$b<=$max;$b++){
        for($c=$min;$c<=$max;$c++){
            for($d=$min;$d<=$max;$d++){
                $det[] = abs(($a*$d) - ($b*$c));
            }
        }
    }
}
$v = array_count_values($det);
arsort($v);
$v = array_keys($v);
echo $v[0]; //12
?>

Very similar methodology.

A Former Brilliant Member - 1 year, 11 months ago

Log in to reply

Are you unhappy with our solutions?

Micah Wood - 1 year, 11 months ago

Log in to reply

No, I am happy with your solutions.

I never learned to program in PHP. Python, I learned and did not like Python -- significant spaces was a great source of problems in programs written by a group and extremely hard to find and the internal documentation of the compiler and runtime was miserable. That is why the programs I write in this site's coding environment are in in C/C++ or Rust.

I was commenting that the algorithm in the PHP and Python programs offered as solutions are very similar to the algorithm in the solution I offered -- not better nor worse.

A Former Brilliant Member - 1 year, 11 months ago
Micah Wood
Jul 7, 2019

My solution in Python:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
from itertools import product

D = dict()
for i in range(0, 163):
    D[i] = 0

for a,b,c,d in product( range(-9, 10), repeat = 4 ):
    D[ abs(a*d - b*c) ] += 1

print( max(D, key = lambda k: D[k]) ) 

Very similar methodology.

A Former Brilliant Member - 1 year, 11 months ago

Computer solution (the language is Wolfram Mathematica 12): First [ SortBy [ Tally [ Flatten [ Table [ Abs [ Det [ ( a b c d ) ] ] , { a , 9 , 9 } , { b , 9 , 9 } , { c , 9 , 9 } , { d , 9 , 9 } ] ] ] , # [ [ 2 ] ] & ] ] { 12 , 3568 } \text{First}\left[\text{SortBy}\left[\text{Tally}\left[\text{Flatten}\left[\text{Table}\left[\text{Abs}\left[\text{Det}\left[\left( \begin{array}{cc} a & b \\ c & d \\ \end{array} \right)\right] \right] ,\{a,-9,9\},\{b,-9,9\},\{c,-9,9\},\{d,-9,9\}\right]\right]\right],-\#[[2]]\&\right]\right] \Rightarrow \{12,3568\}

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...