Here is another approach.

Features include:

use strict; use warnings; # # The display will be divided into two areas, each containing # a grid of Xterm windows. One grid will be $a1 by $b tiles # and the other will be $a2 by ($b-1) tiles. # # For each number of screens ($n), determine $a1, $a2 and $b such that # ($a1*$b)+($a2*($b-1) == $n, the minimum aspect ratio (width/height) # of an Xterm exceeds a threshold and the difference in size between # the larger and smaller Xterm windows is minimized. # $| = 1; my ( $width, $height) = ( 1024, 768 ); # display dimensions in conven +ient units my $aspect = 5/4; # threshold aspect ratio foreach my $n (1..100) { my $minx = 1e100; # to be minimized my $maxb = 0; my @solution; foreach my $a1 (1..$n) { foreach my $a2 (0..($n-1)) { next if($a1 + $a2 > $n); foreach my $b (1..$n) { next unless( ( $a1 * $b ) + ( $a2 * ( $b - 1 ) ) == $n + ); next unless( ( $width * ( $a1 + $a1 ) / $height / $b) +> $aspect ); if( $b > $maxb ) { @solution = ( $a1, $a2, $b ); $maxb = $b; } } } } print "$n: @solution\n"; } __END__ 1: 1 0 1 2: 1 0 2 3: 1 1 2 4: 1 2 2 5: 1 3 2 6: 2 0 3 7: 1 5 2 8: 2 0 4 9: 3 0 3 10: 2 2 3 11: 2 1 4 12: 3 0 4 13: 3 2 3 14: 2 2 4 15: 3 0 5 16: 4 0 4 17: 2 3 4 18: 3 0 6 19: 3 1 5 20: 4 0 5 21: 3 3 4 22: 4 2 4 23: 3 1 6 24: 4 0 6 25: 5 0 5 26: 2 6 4 27: 3 3 5 28: 4 0 7 29: 4 1 6 30: 5 0 6 31: 3 4 5 32: 4 0 8 33: 3 3 6 34: 4 1 7 35: 5 0 7 36: 6 0 6 37: 5 3 5 38: 3 4 6 39: 4 1 8 40: 5 0 8 41: 5 1 7 42: 6 0 7 43: 3 5 6 44: 4 4 6 45: 5 0 9 46: 4 2 8 47: 5 1 8 48: 6 0 8 49: 7 0 7 50: 5 0 10 51: 6 3 6 52: 4 4 7 53: 5 1 9 54: 6 0 9 55: 6 1 8 56: 7 0 8 57: 7 3 6 58: 4 5 7 59: 5 1 10 60: 6 0 10 61: 5 2 9 62: 6 1 9 63: 7 0 9 64: 8 0 8 65: 5 5 7 66: 6 0 11 67: 4 5 8 68: 5 2 10 69: 6 1 10 70: 7 0 10 71: 7 1 9 72: 6 0 12 73: 7 4 7 74: 4 6 8 75: 5 5 8 76: 6 1 11 77: 7 0 11 78: 6 2 10 79: 7 1 10 80: 8 0 10 81: 9 0 9 82: 5 6 8 83: 6 1 12 84: 7 0 12 85: 5 5 9 86: 6 2 11 87: 7 1 11 88: 8 0 11 89: 8 1 10 90: 9 0 10 91: 7 0 13 92: 8 4 8 93: 5 6 9 94: 6 2 12 95: 7 1 12 96: 8 0 12 97: 7 2 11 98: 7 0 14 99: 9 0 11 100: 10 0 10

In reply to Re: Fitting N Xterms On An X by Y screen by ig
in thread Fitting N Xterms On An X by Y screen by Limbic~Region

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.