Skip to content

Instantly share code, notes, and snippets.

View kupp1's full-sized avatar
๐ŸŽ“
ITMO

Dmitrii Kupershtein kupp1

๐ŸŽ“
ITMO
View GitHub Profile
@kupp1
kupp1 / uniqueSym.c
Created September 2, 2018 12:05
UniLecs #1. Unique symbols
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
bool checkUniqueSymbols(char* string) {
for (int i = 0; i < strlen(string); i++) {
for (int j = i + 1; j < strlen(string); j++) {
if (string[i] == string[j]) {
return false;
}
@kupp1
kupp1 / kadane.py
Created September 1, 2018 19:15
UniLecs #122. max submatrix sum
# def check_rectangle_matrix(matrix: list):
# """
# Check if matrix is rectangle list matrix
# """
# if matrix and isinstance(matrix, list):
# x_len = len(matrix[0])
# for array in matrix:
# if len(array) != x_len or not isinstance(array, list):
# return False
# return True
@kupp1
kupp1 / erato.py
Last active August 31, 2018 06:27
Sieve of Eratosthenes
"""
Sieve of Eratosthenes
"""
import math
def erato_bool(n: int):
"""
Returned list of primary numbers form 2 to n-1
"""
if n <= 2:
@kupp1
kupp1 / task121.c
Created August 30, 2018 09:05
UniLecs #121. cAPS LOCK
#include <stdio.h>
int main (int argc, char* argv[]) {
if (argc < 2) {
return -1, printf("missing argument\n");
}
for (int i = 1; i < argc; i++) {
while (*argv[i] != '\0') {
if (*argv[i] >= 65 && *argv[i] <= 90)
putchar(*argv[i] + 32);
@kupp1
kupp1 / boll.cpp
Last active August 27, 2018 07:16
SFML C++ SAMPLE
#include <iostream>
#include <SFML/Graphics.hpp>
#include <SFML/System/Vector2.hpp>
#include <SFML/Window/Keyboard.hpp>
bool chkFunc(sf::Vector2i pos, sf::Vector2f pos_c) {
if ( sf::Mouse::isButtonPressed(sf::Mouse::Left) && pos.x >= pos_c.x && pos.x <= pos_c.x+100 && pos.y >= pos_c.y && pos.y <= pos_c.y+100 ) {
std::cout << "ya1" << "\n";
return true;
} else {
@kupp1
kupp1 / irc.coffee
Last active August 16, 2018 06:43
coffeescript irc (telnet) sample
net = require 'net'
host = 'irc.run.net'
port = 6660
pingRegExp = RegExp("^PING : #{host}\r\n$")
sendMsg = (socket, data) ->
socket.write(data + '\r\n')
matchPing = (data) ->
@kupp1
kupp1 / ircparse.coffee
Last active August 15, 2018 18:32
A regular expression that parses RFC2812 (IRC protocol)
# original work by Michael F. Lamb. License: GPLv3.
# added optional tilde before !user by kupp
RFC2812Matcher = ///
^ # We'll match the whole line. Start.
# Optional prefix and the space that separates it
# from the next thing. Prefix can be a servername,
# or nick[[!user]@host]
(?::( # This whole set is optional but if it's
# here it begins with : and ends with space
@kupp1
kupp1 / gauss.py
Created August 7, 2018 12:07
Gauss circle problem
# brute-force solution 1
radius = float(input('Enter radius: '))
square_radius = radius * radius
int_count = 0
max_int = int(radius)
min_int = (-1) * max_int
for i in range(min_int, max_int + 1):
for j in range(min_int, max_int + 1):
if (i*i) + (j*j) <= square_radius:
int_count += 1
@kupp1
kupp1 / sorts_n2.hpp
Last active September 26, 2018 16:36
Sort Methods
#include <vector>
template <class T>
void bubble_sort(std::vector<T> &vec) {
//Bubble Sort
T tmp;
for (unsigned int i = 0; i < vec.size(); i++) {
for (unsigned int j = 0; j < vec.size()-1; j++) {
if (vec[j] > vec[j+1]) {
tmp = vec[j];
#!/bin/bash
#Install sl package and enjoy!
while :
do
sl
done