Skip to content

Instantly share code, notes, and snippets.

View KvanTTT's full-sized avatar

Ivan Kochurkin KvanTTT

View GitHub Profile
@KvanTTT
KvanTTT / QuineClock.bat
Created July 12, 2015 16:34
QuineClock
echo off
:LOOP
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe" "QuineClock.cs"
"QuineClock.exe" > "QuineClock.cs"
type "QuineClock.cs"
goto LOOP
:END
@KvanTTT
KvanTTT / QuineSnake.bat
Last active September 16, 2019 13:08
Game Snake in source code (Quine). One can play this with batch or power scripts. The game can be finished =)
echo off
:LOOP
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe" "QuineSnake.cs"
"QuineSnake.exe" > "QuineSnake.cs"
type "QuineSnake.cs"
goto LOOP
:END
echo off
:LOOP
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe" "Asciimation_1_3.cs"
"Asciimation_1_3.exe" > "Asciimation_1_3.cs"
type "Asciimation_1_3.cs"
goto LOOP
:END
@KvanTTT
KvanTTT / PolygonTriangulator.cs
Created October 8, 2012 21:31
Short solution for splitting concave polygon on convex polygons or triangles with other utils (SelfIntersection checking).
using System.Collections.Generic;
using System.Drawing;
public class PolygonTriangulator
{
/// <summary>
/// Calculate list of convex polygons or triangles.
/// </summary>
/// <param name="Polygon">Input polygon without self-intersections (it can be checked with SelfIntersection().</param>
/// <param name="triangulate">true: splitting on triangles; false: splitting on convex polygons.</param>
@KvanTTT
KvanTTT / PolynomialRegression.cs
Last active July 28, 2020 07:48
Implementation of Polynomial regression (http://en.wikipedia.org/wiki/Polynomial_regression) with Math.NET library (http://www.mathdotnet.com/)
using MathNet.Numerics.LinearAlgebra.Double;
using MathNet.Numerics.LinearAlgebra.Generic;
public class PolynomialRegression
{
private int _order;
private Vector<double> _coefs;
/// <summary>
/// Calculates polynom regression for xData = [x1, x2, ... , xn] and yData = [y1, y2, ... , yn].
@KvanTTT
KvanTTT / RationalNumberCounting.cs
Created September 22, 2012 09:04
Rational numbers counting (with inverse)
public static long RationalNumber(long i, long j)
{
if (j == 1)
{
if (i == 0)
return 1;
else if (i == 1)
return 2;
}