All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Shapes
Quartering a Square (Posted on 2016-03-29) Difficulty: 3 of 5
Depicted below is one way to divide a 6x6 square into a four areas along the grid lines such that the division has 90 degree rotational symmetry.
+--+--+--+--+--+--+
|  |              |
+  +--+--+  +  +--+
|        |     |  |
+  +  +  +  +  +  +
|        |     |  |
+  +--+--+--+--+  +
|  |     |        |
+  +  +  +  +  +  +
|  |     |        |
+--+  +  +--+--+  +
|              |  |
+--+--+--+--+--+--+
How many ways are there to quarter a square like this?

No Solution Yet Submitted by Brian Smith    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 1 of 4
The program below reports 51 such divisions. One of these is merely dividing the large square into four 3x3 square quadrants.  All the rest come in categories that can be called left-handed or right-handed, and so there are really only 25+1=26 non-trivial varieties.

Any one of the division lines can be taken to characterize the division, as all are the same, rotated at 90° increments.

Each variation was produced by following the main division line chosen as being the one that starts out from the center going right.  The one that never deviates, going straight for the right edge, is the unique one without a mirror-image counterpart.

The division in other instances has the choice of continuing straight at each node, or turning left or right (relative to its own previous path segment). It must avoid hitting either its own prevous position or that of any of the three rotated versions of itself.  As soon as it hits the top, bottom, righ or left edge, that's its end.

As mentioned, the total number of ways is 51, but it's 26 if one eliminates reflections.

DefDbl A-Z
Dim crlf$, dir, x, y, h(20), grid(), sz, ct, prgrid$()


Private Sub Form_Load()
 Form1.Visible = True
 
 Text1.Text = ""
 crlf = Chr$(13) + Chr$(10)
 
 sz = 6
 If sz Mod 2 = 1 Then Text1.Text = Text1.Text & "need even size" & crlf: Exit Sub
 
 ReDim grid(-sz / 2 To sz / 2, -sz / 2 To sz / 2)
 ReDim prgrid$(-sz To sz)
 Open "quartering a square.txt" For Output As #2
 
 grid(0, 0) = 1
 grid(0, 1) = 1
 grid(0, -1) = 1
 grid(1, 0) = 1
 grid(-1, 0) = 1
 
 dir = 1: x = 1: y = 0: h(1) = 1
 
 addOn (2)
 
 Text1.Text = Text1.Text & crlf & ct & " done"
 Close 2
  
End Sub

Sub addOn(wh)
  savedir = dir
  DoEvents
  For d = savedir - 1 To savedir + 1
    savex = x: savey = y
    If d < 1 Then
      dir = d + 4
    ElseIf d > 4 Then
      dir = d - 4
    Else
      dir = d
    End If
    
    Select Case dir
      Case 1
        newx = x + 1: newy = y
      Case 2
        newx = x: newy = y + 1
      Case 3
        newx = x - 1: newy = y
      Case 4
        newx = x: newy = y - 1
    End Select
    
    If Abs(newx) <= sz / 2 And Abs(newy) <= sz / 2 Then
    If grid(newx, newy) = 0 Then
      x = newx: y = newy
      grid(newx, newy) = 1
      grid(-newy, newx) = 1
      grid(-newx, -newy) = 1
      grid(newy, -newx) = 1
      h(wh) = dir
      If Abs(x) = 3 Or Abs(y) = 3 Then
        
        prgrid(-sz) = "+"
        prgrid(sz) = "+"
        For i = 1 To sz
          prgrid(-sz) = prgrid(-sz) + "--+"
          prgrid(sz) = prgrid(sz) + "--+"
        Next
        For r = -sz + 2 To sz - 2 Step 2
          prgrid(r) = "+"
          For i = 1 To sz
            prgrid(r) = prgrid(r) + "  +"
          Next
          prgrid(r + 1) = "|" + Space$(sz * 3 - 1) + "|"
        Next
        prgrid(-sz + 1) = "|" + Space$(sz * 3 - 1) + "|"
        
        xc = 0: yc = 0: fn1 = 1
        
        For i = 1 To wh
          Text1.Text = Text1.Text & h(i)
          Select Case h(i)
            Case 1
              xcn = xc + 1: ycn = yc
            Case 2
              xcn = xc: ycn = yc + 1
              If fn1 = 1 Then fn1 = 2
            Case 3
              xcn = xc - 1: ycn = yc
            Case 4
              xcn = xc: ycn = yc - 1
              If fn1 = 1 Then fn1 = 4
          End Select
          
          ycr = yc: ycrn = ycn
          xcr = xc: xcrn = xcn
          
          For rot = 0 To 3
            If ycr = ycrn Then
              leftx = xcr: rightx = xcrn
              If leftx > rightx Then swap leftx, rightx
              Mid(prgrid(2 * ycr), leftx * 3 + 1 + 3 * sz / 2 + 1, 2) = "--"
            Else
              topy = ycr: bottomy = ycrn
              If topy > bottomy Then swap topy, bottomy
              Mid(prgrid(2 * bottomy - 1), 3 * xcr + 3 * sz / 2 + 1, 1) = "|"
            End If
            xcrr = -ycr: xcrrn = -ycrn
            ycrr = xcr: ycrrn = xcrn
            xcr = xcrr: xcrn = xcrrn
            ycr = ycrr: ycrn = ycrrn
          Next rot
          
          xc = xcn: yc = ycn
        Next
        Text1.Text = Text1.Text & crlf
        ct = ct + 1
        If fn1 < 4 Then
          For i = -sz To sz
            Print #2, prgrid(i)
          Next
          Print #2,
        End If
        
        
      Else
        addOn wh + 1
      End If
      grid(newx, newy) = 0
      grid(-newy, newx) = 0
      grid(-newx, -newy) = 0
      grid(newy, -newx) = 0
    End If
    End If
    
    x = savex: y = savey
  Next
  dir = savedir
End Sub

Sub swap(a, b)
  hld = a: a = b: b = hld
End Sub

shows the following as one method of description:

1443333
1443334
144334
14434
1444
14414
14411
144121
1441221
1414334
141434
14144
14141
1411
14121
141221
1412221
1412222
114344
1143414
1143411
114434
11444
11441
1141
111
1121
11221
11222
112232
1123211
1123212
112322
1214444
1214441
121441
12141
1211
12121
12122
121232
1212332
1221441
122141
12211
12212
1222
12232
122332
1223332
1223333

where 

1 means go to the right (as in East on a map)
2 means go up
3 means go left
4 means go right.

These are with relation to the paper, not right left turns (e.g., up is like north on a map). They also represent only one of the four boundary lines: the one that starts out going to the right.


A file is also produced, with the 26 unique patterns (reflections left out):

+--+--+--+--+--+--+
|        |        |
+  +  +  +  +  +  +
|        |        |
+  +  +  +  +  +  +
|        |        |
+--+--+--+--+--+--+
|        |        |
+  +  +  +  +  +  +
|        |        |
+  +  +  +  +  +  +
|        |        |
+--+--+--+--+--+--+

+--+--+--+--+--+--+
|           |     |
+  +  +  +--+  +  +
|        |        |
+--+  +  +  +  +  +
|  |     |        |
+  +--+--+--+--+  +
|        |     |  |
+  +  +  +  +  +--+
|        |        |
+  +  +--+  +  +  +
|     |           |
+--+--+--+--+--+--+

+--+--+--+--+--+--+
|              |  |
+--+  +  +--+--+  +
|  |     |        |
+  +  +  +  +  +  +
|  |     |        |
+  +--+--+--+--+  +
|        |     |  |
+  +  +  +  +  +  +
|        |     |  |
+  +--+--+  +  +--+
|  |              |
+--+--+--+--+--+--+

+--+--+--+--+--+--+
|  |              |
+  +  +  +--+--+--+
|  |     |        |
+  +  +  +  +  +  +
|  |     |        |
+  +--+--+--+--+  +
|        |     |  |
+  +  +  +  +  +  +
|        |     |  |
+--+--+--+  +  +  +
|              |  |
+--+--+--+--+--+--+

+--+--+--+--+--+--+
|     |           |
+  +--+  +--+--+  +
|  |     |     |  |
+  +  +  +  +  +--+
|  |     |        |
+  +--+--+--+--+  +
|        |     |  |
+--+  +  +  +  +  +
|  |     |     |  |
+  +--+--+  +--+  +
|           |     |
+--+--+--+--+--+--+

+--+--+--+--+--+--+
|              |  |
+--+--+  +--+  +  +
|     |  |  |  |  |
+  +--+  +  +--+  +
|  |     |        |
+  +--+--+--+--+  +
|        |     |  |
+  +--+  +  +--+  +
|  |  |  |  |     |
+  +  +--+  +--+--+
|  |              |
+--+--+--+--+--+--+

+--+--+--+--+--+--+
|  |              |
+  +--+  +--+  +--+
|     |  |  |  |  |
+  +--+  +  +--+  +
|  |     |        |
+  +--+--+--+--+  +
|        |     |  |
+  +--+  +  +--+  +
|  |  |  |  |     |
+--+  +--+  +--+  +
|              |  |
+--+--+--+--+--+--+

+--+--+--+--+--+--+
|     |           |
+  +  +  +--+  +  +
|     |  |  |     |
+  +--+  +  +--+--+
|  |     |        |
+  +--+--+--+--+  +
|        |     |  |
+--+--+  +  +--+  +
|     |  |  |     |
+  +  +--+  +  +  +
|           |     |
+--+--+--+--+--+--+

+--+--+--+--+--+--+
|              |  |
+--+--+--+--+  +  +
|           |  |  |
+  +--+  +--+  +  +
|  |  |  |     |  |
+  +  +--+--+  +  +
|  |     |  |  |  |
+  +  +--+  +--+  +
|  |  |           |
+  +  +--+--+--+--+
|  |              |
+--+--+--+--+--+--+

+--+--+--+--+--+--+
|  |              |
+  +--+--+--+  +--+
|           |  |  |
+  +--+  +--+  +  +
|  |  |  |     |  |
+  +  +--+--+  +  +
|  |     |  |  |  |
+  +  +--+  +--+  +
|  |  |           |
+--+  +--+--+--+  +
|              |  |
+--+--+--+--+--+--+

+--+--+--+--+--+--+
|     |           |
+  +  +--+--+  +  +
|           |     |
+  +--+  +--+  +--+
|  |  |  |     |  |
+  +  +--+--+  +  +
|  |     |  |  |  |
+--+  +--+  +--+  +
|     |           |
+  +  +--+--+  +  +
|           |     |
+--+--+--+--+--+--+

+--+--+--+--+--+--+
|        |        |
+  +  +  +--+  +  +
|           |     |
+  +--+  +--+  +  +
|  |  |  |        |
+--+  +--+--+  +--+
|        |  |  |  |
+  +  +--+  +--+  +
|     |           |
+  +  +--+  +  +  +
|        |        |
+--+--+--+--+--+--+

+--+--+--+--+--+--+
|           |     |
+  +  +  +  +  +  +
|           |     |
+--+--+  +--+  +  +
|     |  |        |
+  +  +--+--+  +  +
|        |  |     |
+  +  +--+  +--+--+
|     |           |
+  +  +  +  +  +  +
|     |           |
+--+--+--+--+--+--+

+--+--+--+--+--+--+
|              |  |
+--+  +  +  +--+  +
|  |        |     |
+  +--+  +--+  +  +
|     |  |        |
+  +  +--+--+  +  +
|        |  |     |
+  +  +--+  +--+  +
|     |        |  |
+  +--+  +  +  +--+
|  |              |
+--+--+--+--+--+--+

+--+--+--+--+--+--+
|  |              |
+  +  +  +  +--+--+
|  |        |     |
+  +--+  +--+  +  +
|     |  |        |
+  +  +--+--+  +  +
|        |  |     |
+  +  +--+  +--+  +
|     |        |  |
+--+--+  +  +  +  +
|              |  |
+--+--+--+--+--+--+

+--+--+--+--+--+--+
|     |           |
+  +--+  +  +--+  +
|  |        |  |  |
+  +--+  +--+  +--+
|     |  |        |
+  +  +--+--+  +  +
|        |  |     |
+--+  +--+  +--+  +
|  |  |        |  |
+  +--+  +  +--+  +
|           |     |
+--+--+--+--+--+--+

+--+--+--+--+--+--+
|        |        |
+  +--+--+  +--+  +
|  |        |  |  |
+  +--+  +--+  +  +
|     |  |     |  |
+--+  +--+--+  +--+
|  |     |  |     |
+  +  +--+  +--+  +
|  |  |        |  |
+  +--+  +--+--+  +
|        |        |
+--+--+--+--+--+--+

+--+--+--+--+--+--+
|        |        |
+  +--+  +--+--+  +
|  |  |        |  |
+  +  +  +--+--+  +
|  |  |  |        |
+--+  +--+--+  +--+
|        |  |  |  |
+  +--+--+  +  +  +
|  |        |  |  |
+  +--+--+  +--+  +
|        |        |
+--+--+--+--+--+--+

+--+--+--+--+--+--+
|           |     |
+  +--+  +  +--+  +
|  |  |        |  |
+--+  +  +--+--+  +
|     |  |        |
+  +  +--+--+  +  +
|        |  |     |
+  +--+--+  +  +--+
|  |        |  |  |
+  +--+  +  +--+  +
|     |           |
+--+--+--+--+--+--+

+--+--+--+--+--+--+
|              |  |
+--+--+  +  +  +  +
|     |        |  |
+  +  +  +--+--+  +
|     |  |        |
+  +  +--+--+  +  +
|        |  |     |
+  +--+--+  +  +  +
|  |        |     |
+  +  +  +  +--+--+
|  |              |
+--+--+--+--+--+--+

+--+--+--+--+--+--+
|  |              |
+  +--+  +  +  +--+
|     |        |  |
+  +  +  +--+--+  +
|     |  |        |
+  +  +--+--+  +  +
|        |  |     |
+  +--+--+  +  +  +
|  |        |     |
+--+  +  +  +--+  +
|              |  |
+--+--+--+--+--+--+

+--+--+--+--+--+--+
|     |           |
+  +  +  +  +  +  +
|     |           |
+  +  +  +--+--+--+
|     |  |        |
+  +  +--+--+  +  +
|        |  |     |
+--+--+--+  +  +  +
|           |     |
+  +  +  +  +  +  +
|           |     |
+--+--+--+--+--+--+

+--+--+--+--+--+--+
|        |        |
+  +  +--+  +  +  +
|     |           |
+  +  +  +--+--+  +
|     |  |     |  |
+--+  +--+--+  +--+
|  |     |  |     |
+  +--+--+  +  +  +
|           |     |
+  +  +  +--+  +  +
|        |        |
+--+--+--+--+--+--+

+--+--+--+--+--+--+
|           |     |
+  +  +--+--+  +  +
|     |           |
+--+  +  +--+--+  +
|  |  |  |     |  |
+  +  +--+--+  +  +
|  |     |  |  |  |
+  +--+--+  +  +--+
|           |     |
+  +  +--+--+  +  +
|     |           |
+--+--+--+--+--+--+

+--+--+--+--+--+--+
|              |  |
+--+  +--+--+--+  +
|  |  |           |
+  +  +  +--+--+  +
|  |  |  |     |  |
+  +  +--+--+  +  +
|  |     |  |  |  |
+  +--+--+  +  +  +
|           |  |  |
+  +--+--+--+  +--+
|  |              |
+--+--+--+--+--+--+

+--+--+--+--+--+--+
|  |              |
+  +  +--+--+--+--+
|  |  |           |
+  +  +  +--+--+  +
|  |  |  |     |  |
+  +  +--+--+  +  +
|  |     |  |  |  |
+  +--+--+  +  +  +
|           |  |  |
+--+--+--+--+  +  +
|              |  |
+--+--+--+--+--+--+


  Posted by Charlie on 2016-03-29 15:45:59
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (6)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2017 by Animus Pactum Consulting. All rights reserved. Privacy Information