47 lines
1.5 KiB
C#
47 lines
1.5 KiB
C#
using Microsoft.Extensions.Logging;
|
|
using System.Collections.ObjectModel;
|
|
namespace File_Folder_Helper.ADO2024.PI3;
|
|
|
|
internal static partial class Helper20241029
|
|
{
|
|
|
|
private static ReadOnlyCollection<string> GetFibonacci(int length)
|
|
{
|
|
List<string> results = [];
|
|
int[] fibonacci =
|
|
[
|
|
1, // x-small
|
|
2, // small
|
|
3, // medium
|
|
5, // large
|
|
8, // x-large
|
|
13, // xx-large
|
|
20 // xxx-large
|
|
];
|
|
double factor = Math.Floor((double)(length / fibonacci.Length));
|
|
double sort = Math.Round(1 / factor, 6) - 0.001;
|
|
for (int j = 0; j < fibonacci.Length; j++)
|
|
{
|
|
results.Add((fibonacci[j] * 1000).ToString());
|
|
for (int i = 0; i < factor; i++)
|
|
results.Add(((int)Math.Round((fibonacci[j] + ((i + 1) * sort)) * 1000)).ToString());
|
|
}
|
|
if (results.Count < length)
|
|
throw new Exception();
|
|
results.Reverse();
|
|
return new(results);
|
|
}
|
|
|
|
internal static void GetFibonacci(ILogger<Worker> logger, List<string> args)
|
|
{
|
|
int length = int.Parse(args[2]);
|
|
ReadOnlyCollection<string> collection;
|
|
for (int i = 1; i < 200; i++)
|
|
_ = GetFibonacci(i);
|
|
collection = GetFibonacci(length);
|
|
foreach (string fibonacci in collection)
|
|
logger.LogInformation(fibonacci);
|
|
File.WriteAllText(".vscode/helper/.txt", string.Join(Environment.NewLine, collection));
|
|
}
|
|
|
|
} |