-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpacial.CS
More file actions
215 lines (194 loc) · 7.27 KB
/
Copy pathSpacial.CS
File metadata and controls
215 lines (194 loc) · 7.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
namespace A.C;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
public class S<T> : B
{
private static StringBuilder stringBuilder = new StringBuilder();
private static BigInteger Ten = new BigInteger(10);
private static BigInteger Two = new BigInteger(2);
private static char Peridot = '.';
private static char Percent = ';';
// Z
private (dynamic, dynamic) Center = (BigInteger.Zero, BigInteger.Zero);
private dynamic [ ] A = Array.Empty<dynamic>(); // PeddleRight: Positive, Right Top, Down Left, Red, Eight
private dynamic [ ] C = Array.Empty<dynamic>(); // BurnNodules: Negative, Bottom, Up Right, Blue, Ten
private dynamic [] D = Array.Empty<dynamic>();
private (BigInteger, BigInteger) Ratio = (BigInteger.Zero, BigInteger.Zero);
public S ( T X , T Y )
{
((BigInteger, BigInteger), (BigInteger, BigInteger)) Dt = Cross ( X , Y );
A = [ Dt.Item2.Item1 , Dt.Item2.Item2 ];
C = [ Dt.Item1.Item1 , Dt.Item1.Item2 ];
}
public T R ( int Dimension )
{
return ( T ) A.GetValue ( Dimension )!;
}
public void R ( int Dimension , T Quantify )
{
A.SetValue ( Quantify , Dimension );
}
public T B ( int Dimension )
{
return ( T ) C.GetValue ( Dimension )!;
}
public void B ( int Dimension , T Quantify )
{
C.SetValue ( Quantify , Dimension );
}
public void CLR ( )
{
A = Array.Empty<dynamic> ( );
}
public void CLB ( )
{
C = Array.Empty<dynamic> ( );
}
public void CLD ( )
{
D = Array.Empty<dynamic> ( );
}
public (BigInteger, BigInteger, BigInteger) Median ( BigInteger R , BigInteger B )
{
BigInteger Remainder = R + B;
BigInteger Quotient = BigInteger.Zero;
try
{
while ( ( Remainder = Remainder - Two ) >= Two )
{
Quotient++;
}
if ( Remainder == BigInteger.Zero )
{
Quotient++;
}
} catch { }
return (Quotient, Remainder, Two);
}
public static TimeSpan Time ( )
{
return TimeSpan.FromTicks ( TimeOnly.FromDateTime ( DateTime.Now.ToLocalTime ( ) ).ToTimeSpan ( ).Ticks );
}
public static string Fracture ( BigInteger Numerator , BigInteger Divisor , TimeSpan? PrecisionTimeout = null )
{
stringBuilder.Clear ( );
string Head = "";
BigInteger Remainder = Numerator;
BigInteger Quotient = BigInteger.One;
if ( Remainder - Divisor >= 0 )
{
while ( ( Remainder = Remainder - Divisor ) >= Divisor )
{
Quotient++;
}
}
else if ( Quotient.Equals ( BigInteger.One ) )
{
Quotient = BigInteger.Zero;
}
stringBuilder.Append ( Quotient.ToString ( ) );
stringBuilder.Append ( Peridot );
Head = stringBuilder.ToString ( );
stringBuilder.Clear ( );
if ( ( Remainder - Divisor ) <= Divisor )
{
bool Timeout = false;
bool Bar = false;
BigInteger Recent = BigInteger.Zero;
TimeSpan TimeSpace = Time();
while ( Bar is false && Timeout is false )
{
if ( PrecisionTimeout is not null && ( Time ( ).Subtract ( TimeSpace ).TotalNanoseconds > PrecisionTimeout.Value.TotalNanoseconds ) )
{
Timeout = true;
break;
throw new TimeoutException ( );
}
Remainder = BigInteger.Multiply ( Remainder , Ten );
if ( Remainder - Divisor > 0 )
{
while ( ( Remainder = Remainder - Divisor ) >= Divisor )
{
Recent++;
}
if ( Remainder < Divisor && Recent > 0 )
{
Recent++;
}
}
if ( Recent > BigInteger.Zero )
{
stringBuilder.Append ( Recent );
string Tail = stringBuilder.ToString ( );
if ( Tail.Length % 2 == 0 )
{
int Split = ( Tail.Length ) / 2;
if ( Tail.Skip ( Split ).ToArray ( ).AsMemory ( ).Span.StartsWith ( Tail.Take ( Split ).ToArray ( ) ) )
{
Bar = true;
break;
}
}
Recent = BigInteger.Zero;
}
else
{
stringBuilder.Append ( BigInteger.Zero );
}
}
if ( Remainder > BigInteger.Zero )
{
stringBuilder.Append ( Percent );
stringBuilder.Append ( Remainder.ToString ( ) );
}
}
return $"{Head}{stringBuilder.ToString ( ).TrimEnd ( BigInteger.Zero.ToString ( ).ToCharArray ( ).Last ( ) )}";
}
public ((BigInteger, BigInteger), (BigInteger, BigInteger)) Cross ( T R , T B )
{
if ( A.Length == C.Length )
{
// These two Ifs allow our relative positioning requirements for logic alignment to be met.
if ( A.Contains ( R ) || C.Contains ( R ) )
{
if ( C.Contains ( B ) || A.Contains ( B ) )
{
CLD ( );
BigInteger XR = BigInteger.Abs(BigInteger.Parse(new ReadOnlySpan<char>(R.ToString()!.ToCharArray())));
BigInteger YB = BigInteger.Abs(BigInteger.Parse(new ReadOnlySpan<char>(B.ToString()!.ToCharArray())));
BigInteger YR = BigInteger.Multiply(XR, BigInteger.MinusOne);
BigInteger XB = BigInteger.Multiply(YB, BigInteger.MinusOne);
(BigInteger,BigInteger,BigInteger) Length = Median(BigInteger.Abs(BigInteger.Min(YR, XB)), BigInteger.Abs(BigInteger.Max(XR, YB)));
D.Append ( Length );
return ((XR, YB), (YR, XB));
}
}
}
return ((BigInteger.Zero, BigInteger.Zero), (BigInteger.Zero, BigInteger.Zero));
}
public ((BigInteger, BigInteger, BigInteger), (BigInteger, BigInteger, BigInteger)) MedianWholeQuotientRemainder ( ((BigInteger, BigInteger), (BigInteger, BigInteger)) Pair )
{
// Mr_ = ( ( ( Y2 + Y1 ) / 2 ), ( ( X2 + X1 ) / 2 ) )
return (Median ( Pair.Item1.Item1 , Pair.Item2.Item1 ), Median ( Pair.Item1.Item2 , Pair.Item2.Item2 ));
}
public BigInteger Step ( ((BigInteger, BigInteger), (BigInteger, BigInteger)) Pair )
{
// S = Rise (R) / Bun (B)
return BigInteger.Parse ( Fracture ( Rise ( Pair ) , Burn ( Pair ) ) );
}
public BigInteger Rise ( ((BigInteger, BigInteger), (BigInteger, BigInteger)) Pair )
{
// R = (Y2 - Y1)
return ( Pair.Item1.Item2 - Pair.Item2.Item2 );
}
public BigInteger Burn ( ((BigInteger, BigInteger), (BigInteger, BigInteger)) Pair )
{
// B = (X2 - X1)
return ( Pair.Item1.Item1 - Pair.Item2.Item1 );
}
}