Skip to content

Instantly share code, notes, and snippets.

View KvanTTT's full-sized avatar

Ivan Kochurkin KvanTTT

View GitHub Profile
@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 / SwitchByObjectVsInt.cs
Created March 13, 2020 13:22
Compare generated code for switch by object vs switch by int
using System;
public class C {
public const int C1Type = 1;
public const int C2Type = 2;
public const int C3Type = 3;
public const int C4Type = 4;
public abstract class Base
{
@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
class Program
{
class Animal
{
}
class Cat : Animal
{
public void Meow()
{
@KvanTTT
KvanTTT / Kochurkins.cmd
Created September 12, 2018 21:00
Script for generating genealogy tree inside Git repository
chcp 65001
mkdir Kochurkins
cd Kochurkins
git init
git checkout --orphan @I36@
git commit -m "Татьяна : Birth F" --date "01/01/1970 00:00:00" --author "Татьяна <>" --allow-empty
git checkout --orphan @I35@
git commit -m "Степан Голобоков : Birth M" --date "01/01/1970 00:00:00" --author "Степан Голобоков <>" --allow-empty
git checkout --orphan @I33@
@KvanTTT
KvanTTT / remarks.md
Created February 25, 2018 20:28
seva-calculator

Функциональность

  • Некорректная обработка чисел больше размерности int. Например, 9999999999999999999=-1981284353.
  • IndexOutOfRangeException в случае пустого ввода и в случае если оператор умножения или сложения находятся в начале: +2, *2.
  • Программа не покрыта тестами.
  • Дублирование логики в switch - case. Символьный тип элементарно перевести в число, а блок с проверкой от '0' до '9' заменяется одной строчкой. То же самое относится к операторам '*' и '+'.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using static System.Console;
using static System.Math;
using static System.DayOfWeek;
using static System.Linq.Enumerable;
namespace CSharp6Samples
{
public class Test
{
// Initializers for auto-properties
@KvanTTT
KvanTTT / Expression.cs
Created September 12, 2017 09:02
Parser that can add and sum integer numbers
using System.Collections.Generic;
using static System.Console;
namespace Expressions
{
public enum Operation
{
Add,
Mult,
Int
@KvanTTT
KvanTTT / CSharp6FeaturiesWalker.cs
Last active July 7, 2017 20:05
Walker for detection C# 6 syntax features
public class CSharp6FeaturiesWalker : CSharpSyntaxWalker
{
public bool CSharp6Featuries { get; private set; }
public CSharp6FeatureWalker()
{
}
public override void VisitPropertyDeclaration(PropertyDeclarationSyntax node)
{