[C# Helper]
Index Books FAQ Contact About Rod
[Beginning Database Design Solutions, Second Edition]

[Beginning Software Engineering, Second Edition]

[Essential Algorithms, Second Edition]

[The Modern C# Challenge]

[WPF 3d, Three-Dimensional Graphics with WPF and C#]

[The C# Helper Top 100]

[Interview Puzzles Dissected]

[C# 24-Hour Trainer]

[C# 5.0 Programmer's Reference]

[MCSD Certification Toolkit (Exam 70-483): Programming in C#]

Title: Show solutions to the equilateral triangles puzzle in C#

[Show solutions to the equilateral triangles puzzle in C#]

This post shows how to display manually found solutions to the puzzle Puzzle: Find the equilateral triangles in C#. This example uses the following code to define the puzzle's 25 solutions that I found manually.

// Define the solutions. Solutions = new List<int[]>(); Solutions.Add(new int[] { 0, 2, 3 }); Solutions.Add(new int[] { 0, 3, 1 }); Solutions.Add(new int[] { 1, 3, 4 }); Solutions.Add(new int[] { 2, 5, 6 }); Solutions.Add(new int[] { 2, 6, 3 }); Solutions.Add(new int[] { 3, 6, 7 }); Solutions.Add(new int[] { 3, 7, 4 }); Solutions.Add(new int[] { 4, 7, 8 }); Solutions.Add(new int[] { 5, 9, 6 }); Solutions.Add(new int[] { 6, 9, 10 }); Solutions.Add(new int[] { 6, 10, 7 }); Solutions.Add(new int[] { 7, 10, 11 }); Solutions.Add(new int[] { 7, 11, 8 }); Solutions.Add(new int[] { 0, 5, 7 }); Solutions.Add(new int[] { 1, 6, 8 }); Solutions.Add(new int[] { 3, 9, 11 }); Solutions.Add(new int[] { 10, 2, 4 }); Solutions.Add(new int[] { 5, 10, 3 }); Solutions.Add(new int[] { 2, 7, 1 }); Solutions.Add(new int[] { 6, 11, 4 }); Solutions.Add(new int[] { 8, 3, 10 }); Solutions.Add(new int[] { 4, 6, 0 }); Solutions.Add(new int[] { 7, 9, 2 }); Solutions.Add(new int[] { 0, 9, 8 }); Solutions.Add(new int[] { 1, 5, 11 });

This code defines the variable Solutions to be a list containing arrays of integers. It then adds to the list arrays containing the indexes of the points that make up the solutions.

You can try to find the solutions manually, but some of them are pretty hard to visualize. See the example Solve the equilateral triangles puzzle in C# to see how a program can find the solutions.

Download the example to experiment with it and to see additional details.

© 2009-2023 Rocky Mountain Computer Consulting, Inc. All rights reserved.