-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from Mijo-Software/202112140019
202112140019
- Loading branch information
Showing
2 changed files
with
59 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,71 @@ | ||
//string length; | ||
|
||
const ulong max = 1000; | ||
namespace EulerBricks | ||
{ | ||
internal class EulerBricks | ||
{ | ||
public static void Main() | ||
{ | ||
const ulong max = 1000; | ||
|
||
ulong | ||
n = 0, i = 0, | ||
a_min = 1, b_min = 1, c_min = 1, | ||
a_max = max, b_max = max, c_max = max; | ||
ulong | ||
n = 0, i = 0, | ||
a_min = 1, b_min = 1, c_min = 1, | ||
a_max = max, b_max = max, c_max = max; | ||
|
||
double d, e, f, g; | ||
double d, e, f, g; | ||
|
||
Console.WriteLine(value: "EulerBricks"); | ||
Console.Write(value: "Input the length of the run (default=1000, hit ENTER): "); | ||
string length = Console.ReadLine(); | ||
if (ulong.TryParse(s: length, result: out a_max)) | ||
{ | ||
b_max = c_max = a_max; | ||
} | ||
else | ||
{ | ||
Console.WriteLine(value: "Default value loaded!"); | ||
a_max = b_max = c_max = max; | ||
} | ||
Console.WriteLine(value: "EulerBricks"); | ||
Console.Write(value: "Input the length of the run (default=1000, hit ENTER): "); | ||
string length = Console.ReadLine(); | ||
if (ulong.TryParse(s: length, result: out a_max)) | ||
{ | ||
b_max = c_max = a_max; | ||
} | ||
else | ||
{ | ||
Console.WriteLine(value: "Default value loaded!"); | ||
a_max = b_max = c_max = max; | ||
} | ||
|
||
for (ulong a = a_min; a < a_max; a++) | ||
{ | ||
for (ulong b = b_min; b < b_max; b++) | ||
{ | ||
for (ulong c = c_min; c < c_max; c++) | ||
{ | ||
d = Math.Sqrt(d: Math.Pow(x: a, y: 2) + Math.Pow(x: b, y: 2)); | ||
if ((d % 1) == 0) | ||
for (ulong a = a_min; a < a_max; a++) | ||
{ | ||
e = Math.Sqrt(d: Math.Pow(x: a, y: 2) + Math.Pow(x: c, y: 2)); | ||
if ((e % 1) == 0) | ||
for (ulong b = b_min; b < b_max; b++) | ||
{ | ||
f = Math.Sqrt(d: Math.Pow(x: b, y: 2) + Math.Pow(x: c, y: 2)); | ||
if ((f % 1) == 0) | ||
for (ulong c = c_min; c < c_max; c++) | ||
{ | ||
n++; | ||
if (a <= b && a <= c && b <= c) | ||
d = Math.Sqrt(d: Math.Pow(x: a, y: 2) + Math.Pow(x: b, y: 2)); | ||
if ((d % 1) == 0) | ||
{ | ||
i++; | ||
Console.WriteLine(value: $"{n}|{i} = {{a: {a}, b: {b}, c: {c}}}{{d: {Math.Round(a: (double)d)}, e: {Math.Round(a: (double)e)}, f: {Math.Round(a: (double)f)}}}"); | ||
} | ||
else | ||
{ | ||
Console.ForegroundColor = ConsoleColor.DarkGray; | ||
Console.WriteLine(value: $"{n}|{i} = {{a: {a}, b: {b}, c: {c}}}{{d: {Math.Round(a: (double)d)}, e: {Math.Round(a: (double)e)}, f: {Math.Round(a: (double)f)}}}"); | ||
Console.ForegroundColor = ConsoleColor.White; | ||
} | ||
g = Math.Sqrt(d: Math.Pow(x: a, y: 2) + Math.Pow(x: b, y: 2) + Math.Pow(x: c, y: 2)); | ||
if ((g % 1) == 0) | ||
{ | ||
Console.ForegroundColor = ConsoleColor.Green; | ||
Console.WriteLine(value: $"{n}|{i} = {{a: {a}, b: {b}, c: {c}}}{{d: {Math.Round(a: (double)d)}, e: {Math.Round(a: (double)e)}, f: {Math.Round(a: (double)f)}}}{{g: {Math.Round(a: (double)g)}"); | ||
Console.ForegroundColor = ConsoleColor.White; | ||
e = Math.Sqrt(d: Math.Pow(x: a, y: 2) + Math.Pow(x: c, y: 2)); | ||
if ((e % 1) == 0) | ||
{ | ||
f = Math.Sqrt(d: Math.Pow(x: b, y: 2) + Math.Pow(x: c, y: 2)); | ||
if ((f % 1) == 0) | ||
{ | ||
n++; | ||
if (a <= b && a <= c && b <= c) | ||
{ | ||
i++; | ||
Console.WriteLine(value: $"{n}|{i} = {{a: {a}, b: {b}, c: {c}}}{{d: {Math.Round(a: (double)d)}, e: {Math.Round(a: (double)e)}, f: {Math.Round(a: (double)f)}}}"); | ||
} | ||
else | ||
{ | ||
Console.ForegroundColor = ConsoleColor.DarkGray; | ||
Console.WriteLine(value: $"{n}|{i} = {{a: {a}, b: {b}, c: {c}}}{{d: {Math.Round(a: (double)d)}, e: {Math.Round(a: (double)e)}, f: {Math.Round(a: (double)f)}}}"); | ||
Console.ForegroundColor = ConsoleColor.White; | ||
} | ||
g = Math.Sqrt(d: Math.Pow(x: a, y: 2) + Math.Pow(x: b, y: 2) + Math.Pow(x: c, y: 2)); | ||
if ((g % 1) == 0) | ||
{ | ||
Console.ForegroundColor = ConsoleColor.Green; | ||
Console.WriteLine(value: $"{n}|{i} = {{a: {a}, b: {b}, c: {c}}}{{d: {Math.Round(a: (double)d)}, e: {Math.Round(a: (double)e)}, f: {Math.Round(a: (double)f)}}}{{g: {Math.Round(a: (double)g)}"); | ||
Console.ForegroundColor = ConsoleColor.White; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |