Skip to main content
2 of 2
Removed the last lines (actually a paraphrasing of some well-known lyrics) since they don't really contribute to the answer.
Stefan Kohl
  • 19.6k
  • 21
  • 75
  • 137

Me funksionin GAP

MaxOnes := n -> Maximum(List(Filtered(AsList(GF(2)^[n,n]),
                             M->not ForAny(Tuples([1..n-1],2),
                                           s->ForAny(Cartesian([1..n-s[1]],[1..n-s[2]]),
                                                     t->ForAll(Flat(M{[s[1],s[1]+t[1]]}
                                                                     {[s[2],s[2]+t[2]]}),
                                                               IsOne)))),
                             N->Number(Flat(N),IsOne)));

ne kemi per shembull

gap> MaxOnes(1);
1
gap> MaxOnes(2);
3
gap> MaxOnes(3);
6
gap> MaxOnes(4);
9

dhe pergjigja e pyetjes eshte

gap> MaxOnes(43);
( ... ju lutem prisni ... ju lutem prisni ... !! )
Stefan Kohl
  • 19.6k
  • 21
  • 75
  • 137