Skip to content

Instantly share code, notes, and snippets.

View mikeyakymenko's full-sized avatar
🏠
Working from home

Mike Yakymenko mikeyakymenko

🏠
Working from home
View GitHub Profile
@mikeyakymenko
mikeyakymenko / season.py
Last active May 5, 2024 22:07
schedule unbalanced season (sports)
from app.core.constants import Directions
class SeasonSchedule:
def __init__(self, units, season_shift=None):
self.units = units
self.north_units = [unit for unit in units if unit['division'] == Directions.North.value]
self.south_units = [unit for unit in units if unit['division'] == Directions.South.value]
self.season_shift = list(range(5)) if season_shift is None else season_shift
self.weeks = []
@mikeyakymenko
mikeyakymenko / robin_like_schedule.py
Last active October 21, 2021 15:42
Robin like schedule
def scheduleMatches(teams, rounds=1):
matches = []
if len(teams) % 2 == 1:
teams.append('None')
teamsNumbers = len(teams)
map = list(range(teamsNumbers))
middle = teamsNumbers // 2
for i in range((teamsNumbers-1)*rounds):
import * as mongoose from 'mongoose'
import {AdressDbModel} from './types'
const adressSchema = new mongoose.Schema({
country: {
type: String,
required: true
},
city: {
@mikeyakymenko
mikeyakymenko / package.json
Created February 7, 2020 15:50
Simple NodeJS + TS
{
"name": "someproject",
"version": "1.0.0",
"description": "someproject shop",
"main": "index.js",
"author": "Mike Yakymenko",
"license": "MIT",
"scripts": {
"dev": "nodemon --watch 'src/**/*.ts' --exec 'ts-node' server.ts",
"prod": "tsc -p api && node dist/server.js"
const probs = {
0: {
0: 0.7,
1: 0.14,
2: 0.1,
3: 0.03,
4: 0.02,
5: 0.01
},
1: {
@mikeyakymenko
mikeyakymenko / candies.js
Created September 22, 2019 15:08
Some candies ;)
var candies1 = [3, 4, 7, 7, 6, 6]
var candies2 = [5, 1, 12, 12, 12, 5, 6, 8, 8, 5]
var candies3 = [80, 80, 1000000000, 80, 80, 80, 80, 80, 80, 123456789]
var candies = [5, 1, 12, 12, 12, 5, 6, 8, 8, 5]
var typesOfCandies = function(arr) {
var finalResult = {};
var counting = arr.reduce(function(result, current) {
@mikeyakymenko
mikeyakymenko / robin.js
Created June 24, 2018 12:40
Round robin, league matches schedule on javascript
let teams = [
'Tigers',
'Foofels',
'Drampamdom',
'Lakebaka'
]
const roundRobin = (teams) => {
let schedule = []
let league = teams.slice()
@mikeyakymenko
mikeyakymenko / round-robin.py
Created May 29, 2018 21:30 — forked from ih84ds/round-robin.py
Generate Round Robin Schedule with Balanced Home/Away in Python
def create_balanced_round_robin(players):
""" Create a schedule for the players in the list and return it"""
s = []
if len(players) % 2 == 1: players = players + [None]
# manipulate map (array of indexes for list) instead of list itself
# this takes advantage of even/odd indexes to determine home vs. away
n = len(players)
map = list(range(n))
mid = n // 2
for i in range(n-1):
@mikeyakymenko
mikeyakymenko / roundRobin.py
Created May 29, 2018 21:30 — forked from Makistos/roundRobin.py
A round-robin algorithm implementation written in Python. #round-robin #scheduling #algorithm #python
#!/usr/bin/python
div1 = ["Lions", "Tigers", "Jaguars", "Cougars"]
div2 = ["Whales", "Sharks", "Piranhas", "Alligators"]
div3 = ["Cubs", "Kittens", "Puppies", "Calfs"]
def create_schedule(list):
""" Create a schedule for the teams in the list and return it"""
s = []
@mikeyakymenko
mikeyakymenko / someMatrix.js
Created March 29, 2018 18:03
some matrix generators (for Oleg)
const genMatrix = (args) => {
return Array.isArray(args) ? args.map((item) => genMatrix(item))
: Array.apply(null, {length: args}).map(() => false)
}
const genMatrix2 = (args) => {
if (Array.isArray(args)) {
return args.map((item) => genMatrix2(item))
}
else {