This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as mongoose from 'mongoose' | |
import {AdressDbModel} from './types' | |
const adressSchema = new mongoose.Schema({ | |
country: { | |
type: String, | |
required: true | |
}, | |
city: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const probs = { | |
0: { | |
0: 0.7, | |
1: 0.14, | |
2: 0.1, | |
3: 0.03, | |
4: 0.02, | |
5: 0.01 | |
}, | |
1: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let teams = [ | |
'Tigers', | |
'Foofels', | |
'Drampamdom', | |
'Lakebaka' | |
] | |
const roundRobin = (teams) => { | |
let schedule = [] | |
let league = teams.slice() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
NewerOlder