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

Home > Just Math
Increasing sequences (Posted on 2015-11-30) Difficulty: 3 of 5
List all the 3X3 arrays of nine distinct positive digits such that each of the rows and each of the columns is an increasing sequence.
Example: 1,2,5; 3,4,7; 6,8,9.

See The Solution Submitted by Ady TZIDON    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 1 of 3
There are 42:

123
456
789

123
457
689

123
458
679

123
467
589

123
468
579

124
356
789

124
357
689

124
358
679

124
367
589

124
368
579

125
346
789

125
347
689

125
348
679

125
367
489

125
368
479

126
347
589

126
348
579

126
357
489

126
358
479

127
348
569

127
358
469

134
256
789

134
257
689

134
258
679

134
267
589

134
268
579

135
246
789

135
247
689

135
248
679

135
267
489

135
268
479

136
247
589

136
248
579

136
257
489

136
258
479

137
248
569

137
258
469

145
267
389

145
268
379

146
257
389

146
258
379

147
258
369




DefDbl A-Z
Dim wd(10) As String, w As String, sz, crlf$
Function mform$(x, t$)
  a$ = Format$(x, t$)
  If Len(a$) < Len(t$) Then a$ = Space$(Len(t$) - Len(a$)) & a$
  mform$ = a$
End Function

Private Sub Form_Load()
 Text1.Text = ""
 crlf$ = Chr(13) + Chr(10)
 Form1.Visible = True

 a$ = "123456789": h$ = a
 Do
   DoEvents
   good = 1
   For row = 1 To 7 Step 3
    For col = 1 To 2
      If Mid(a, row + col, 1) < Mid(a, row + col - 1, 1) Then good = 0: Exit For
    Next
    If good = 0 Then Exit For
   Next
   For col = 0 To 2
    For row = 4 To 7 Step 3
      If Mid(a, row + col, 1) < Mid(a, row - 3 + col, 1) Then good = 0: Exit For
    Next
    If good = 0 Then Exit For
   Next
   
   If good Then
     Text1.Text = Text1.Text & Left(a, 3) & crlf & Mid(a, 4, 3) & crlf & Right(a, 3) & crlf & crlf
     ct = ct + 1
   End If
   
   permute a
 Loop Until a = h
 
 Text1.Text = Text1.Text & crlf & ct & " done"
 

End Sub

Sub permute(a$)

 x$ = ""
 For i = Len(a$) To 1 Step -1
  l$ = x$
  x$ = Mid$(a$, i, 1)
  If x$ < l$ Then Exit For
 Next


 If i = 0 Then
  For j = 1 To Len(a$) \ 2
   x$ = Mid$(a$, j, 1)
   Mid$(a$, j, 1) = Mid$(a$, Len(a$) - j + 1, 1)
   Mid$(a$, Len(a$) - j + 1, 1) = x$
  Next
 Else
  For j = Len(a$) To i + 1 Step -1
   If Mid$(a$, j, 1) > x$ Then Exit For
  Next
  Mid$(a$, i, 1) = Mid$(a$, j, 1)
  Mid$(a$, j, 1) = x$
  For j = 1 To (Len(a$) - i) \ 2
   x$ = Mid$(a$, i + j, 1)
   Mid$(a$, i + j, 1) = Mid$(a$, Len(a$) - j + 1, 1)
   Mid$(a$, Len(a$) - j + 1, 1) = x$
  Next
 End If
End Sub




  Posted by Charlie on 2015-11-30 14:48:11
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


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

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