Skip to content

Instantly share code, notes, and snippets.

var start = 0;
this.test_Broken = function () {
alert('start! 5 seconds...');
start = (new Date()).getTime();
windmill.jsTest.actions.waits.forJS({
timeout: 60000,
js: function () {
alert('getting called...');
return 5000 < (new Date()).getTime() - start;
}
def generate_trips(route_names, start_hour, end_hour):
results = []
for route_name in route_names:
for hour in range(start_hour, end_hour):
results.append((route_name, hour))
return results
#!/usr/bin/env python
from collections import defaultdict
from pprint import pprint
import random
def generate_trips(route_names, start_hour, end_hour):
results = []
for route_name in route_names:
@d5h
d5h / cost.py
Last active September 22, 2018 22:15
def cost(duty):
"""
Assume units of pay is "hours". I.e. for each hour worked increment by 1.
Rules:
1. Drivers get paid for each hour they work, but not the break.
2. They get a minimum pay of eight hours for coming into work (known as guarantee pay).
3. They get 1.5x pay for each hour they work over eight hours(overtime pay).
4. Each duty over four hours should allow the driver to have a break.
"""
def solve(duties, trips):
problem = LpProblem('driver_scheduling', LpMinimize)
variables = []
costs = []
# Data structure to generate constraints for each trip.
variables_for_trip = {trip: [] for trip in trips}
# We have to make sure there's some set of duties that really do include all
# the trips. Since we randomly generate duties, we can't be sure. E.g., we
# could get unlucky and randomly generate duties that all only have trips on
#!/usr/bin/env python
from collections import defaultdict
from pprint import pprint
import random
from pulp import *
def generate_trips(route_names, start_hour, end_hour):
@d5h
d5h / sudoku.c
Created September 22, 2018 22:11
Sudoku solver in C
#include <error.h>
#include <stdio.h>
#include <string.h>
int board[9][9];
int rowmask[9];
int colmask[9];
int sqrmask[3][3];
int possible[9][9];
int numpos[9][9];