Skip to content

Instantly share code, notes, and snippets.

View max-kov's full-sized avatar

Max Kovalovs max-kov

View GitHub Profile
@max-kov
max-kov / sierpetsky_triangle.py
Last active May 21, 2020 18:20
sierpetsky triangle drawing using pygame and python
import pygame, math, sys
def draw(dot1,dot2,dot3,order):
pygame.draw.lines(screen, (255,0,0), True, [dot1,dot2,dot3], 1)
if order>0:
newDot1 = (int((dot1[0]+dot2[0])*0.5),int((dot1[1]+dot2[1])*0.5))
newDot2 = (int((dot2[0]+dot3[0])*0.5),int((dot2[1]+dot3[1])*0.5))
newDot3 = (int((dot3[0]+dot1[0])*0.5),int((dot3[1]+dot1[1])*0.5))
pygame.draw.lines(screen, (255,0,0), True, [newDot1,newDot2,newDot3], 1)
@max-kov
max-kov / calculator.lex
Created November 15, 2015 17:36
stack calculator lex implementation
%option noyywrap
%{
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
%}
%%
int nums[100],i=0;
[\-0-9]*|[0-9]* {
i++;
@max-kov
max-kov / matrix.pas
Last active November 21, 2015 07:04
matrix falling code sim
program matrix;
uses
graph,
SysUtils;
const
colnum = 15;
var
GrDriver, GrMode, GrError: smallint;
@max-kov
max-kov / matrix.py
Last active July 2, 2022 02:13
matrix falling code in python using pygame
import pygame, pygame.font
import random
def IsWritten():
defTemp = True
for x in xrange((lettersOnScreen[0] / 2) - (len(str) / 2), (lettersOnScreen[0] / 2) + (len(str) / 2) + 1):
if xHeads[x] == -1:
defTemp = False
return defTemp
@max-kov
max-kov / rucksack.pas
Last active May 21, 2020 18:18
The rucksack problem solution in Pascal
program rucksack;
uses math;
type THistory = array [0..10000,0..10000] of integer;
tItem= record
val,size:integer;
end;
TItems = array [1..10000] of tItem;
var fin,fout: text;
maxSize,maxItems,curSize,counter,counter2:integer;
History:THIstory;
@max-kov
max-kov / mandelbrot.py
Created March 8, 2016 08:18
bad mandelbrot implement using python
__author__ = 'mk070_000'
#R KEY - INCREASE FUNCTION LOOPS OR ACCURACY
#LEFT MOUSE, HOLD, MOVE, RELEASE - CHOOSE FUNCTION MERITS (max values, can be use to zoom in)
#RIGHT MOUSE - CREATE A JULIA SET , USING THE MOUSE COORDINATES
import math, pygame, cmath, sys
from pygame import gfxdraw
def mandelbrot(point ,koeff , n):
if abs(point) > 5:
return 254-(254.0/accuracy)*n
@max-kov
max-kov / cycloid.py
Created November 7, 2016 22:39
cycloid animation
import pygame, math
pygame.init()
windowsSurfaceObj = pygame.display.set_mode((750,300))
fpsClock = pygame.time.Clock()
whiteColor = (255,255,255)
greenColor = (0,255,0)
blackColor = (0,0,0)
import pygame
import numpy as np
# change these values
points = 10000
circles = 30.0
radius = 200.0
resolution = np.array([1000, 500])
@max-kov
max-kov / circles2.py
Created March 21, 2017 22:23
drawing circles on a circle (which is moving)
import pygame
import numpy as np
# change these values
points_temp = 1000
radius1 = 100
radius2 = 100
angular_speed_1 = 0.01
angular_speed_2 = 0.0002
@max-kov
max-kov / circles3
Created March 21, 2017 22:45
circle rolling in another circle
import pygame
import numpy as np
# change these values
points = 50000
radius1 = 100.0
radius2 = 70.0
point_disp = 100.0
angle_ratio =radius1/radius2