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

Home > Numbers
Dascal triangle (Posted on 2016-02-02) Difficulty: 3 of 5
Arrange integers 1- 15 in a triangle such that the upper row consists of 5 integers, all other rows represent each the absolute values of the differences between the adjacent members of the row above so that the 5th row contains one number only.

A bad example:

4   7  15  10   2
  3  12   5   8
    9   7   * oops!  Can't use 3 again.
Just wanted to explain the build-up..
Better luck to the solvers!

No Solution Yet Submitted by Ady TZIDON    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
re(3): computer solution | Comment 4 of 8 |
(In reply to re(2): computer solution by Charlie)

The generalized program with size 6 for the first row (triangular number = 21) finds no solutions:


DefDbl A-Z
Dim crlf$, grid(20, 20), used(200), sz, tr


Private Sub Form_Load()
 Form1.Visible = True
 
 Text1.Text = ""
 crlf = Chr$(13) + Chr$(10)
 
 sz = 6
 tr = sz * (sz + 1) / 2
 
 addOn 1, 1


 Text1.Text = Text1.Text & crlf & " done"
  
End Sub

Sub addOn(row, col)
 DoEvents
 If row = 1 Then
  For i = 1 To tr
    If col = 1 Then Text1.Text = Text1.Text & Str(i) ' equivalent of a progress bar
    If used(i) = 0 Then
      grid(row, col) = i
      used(i) = 1
      
      r = row: c = col + 1
      If c > sz Then r = r + 1: c = 1
      addOn r, c
      
      used(i) = 0
    End If
  Next
 Else
  diff = Abs(grid(row - 1, col) - grid(row - 1, col + 1))
  If used(diff) = 0 Then
    grid(row, col) = diff
    used(diff) = 1
      
    r = row: c = col + 1
    If c > sz + 1 - row Then r = r + 1: c = 1
    If r < sz + 1 Then
      addOn r, c
    Else
      For r = 1 To sz
       For c = 1 To sz + 1 - r
         Text1.Text = Text1.Text & Str(grid(r, c))
       Next c
       Text1.Text = Text1.Text & crlf
      Next r
      Text1.Text = Text1.Text & crlf
    End If
      
    used(diff) = 0
  End If
 End If
End Sub


  Posted by Charlie on 2016-02-03 22:16:06
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 (0)
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