Skip to content

Instantly share code, notes, and snippets.

View Dimanaux's full-sized avatar

Dmitry Barskov Dimanaux

View GitHub Profile
@Dimanaux
Dimanaux / decToRoman.cpp
Last active August 13, 2017 13:50
there is a function that converts numbers from decimal to roman
#include <map>
#include <string>
std::string decimalToRoman(int n) {
std::string roman = "";
const std::map<int, std::string> rd = {
{1000, "M"},
{900, "CM"},
{500, "D"},
{400, "CD"},
@Dimanaux
Dimanaux / Braces.hpp
Last active August 17, 2017 18:04
function validBraces checks if string contains valid sequence of braces
#include <string>
// #include <algorithm>
// #include <iostream>
#include <vector>
#include <map>
#include <stack>
// #pragma once
#ifndef BRACES_H
@Dimanaux
Dimanaux / binarySearch.c
Last active September 30, 2017 17:19
math analisys homework
#include <stdio.h>
#include <math.h>
#define true 1
typedef double (*mathFn)(double);
const double EPS = 1e-9;
@Dimanaux
Dimanaux / InputHandler.java
Created October 12, 2017 13:01
How to clear screen (terminal)
public class InputHandler {
// clears the screen
public static void clearScreen() {
final String ANSI_CLS = "\u001b[2J";
final String ANSI_HOME = "\u001b[H";
System.out.print(ANSI_CLS + ANSI_HOME);
System.out.flush();
}
}
@Dimanaux
Dimanaux / Automata.java
Last active October 27, 2017 15:35
Validates whether assignment sequence is valid
public class Automata {
public static void main(String[] args) {
for (String chain : args) {
System.out.println(isValidAssignmentChain(chain));
}
}
public static boolean isValidAssignmentChain(String chain) {
public class Braces {
public static void main(String[] args) {
for (String line : args) {
System.out.println(isValidBracketsSeq(line));
}
}
static boolean isValidBracketsSeq(String brackets) {
@Dimanaux
Dimanaux / st.py
Last active December 7, 2017 19:38
Least squares. Math analysis homework #2
# -*- encoding: utf-8 -*-
import sys
import os
import matplotlib.pyplot as plt
import numpy as np # instead of math
def getFullPath(fileName, fileType):
return (os.getcwd() + '\\' + '{}.{}').format(fileName, fileType)
@Dimanaux
Dimanaux / least_squares.py
Created November 12, 2017 18:17 — forked from silgon/least_squares.py
Basic Least Squares Implementation with pseudo inverse
"""
Basic Least Squares Implementation with pseudo inverse
"""
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(0)
t = np.linspace(0, 3, 20) # horizontal axis
x = np.array([3, 0, 4]) # a,b,c of f(t)=a+b*t+c*t^2
f = lambda t, x: x[0]+x[1]*t+x[2]*t**2 # f(t)
public class BinarySearchDemoClass {
public static int binarySearch(String[] array, String value) {
int l = 0, r = array.length;
int mid = (l + r) / 2;
while (l < r) {
if (value.compareTo(array[mid]) == 0) {
return mid;
} else if (value.compareTo(array[mid]) > 0) {
#include <stdio.h>
#include <math.h>
typedef double (*function)(double);
double func(double);
double integral(function, double, double);
const int SECTIONS_QUANTITY = 1e4;
// const double EPS = 1e-6;