Skip to content

Instantly share code, notes, and snippets.

@JamWils
JamWils / _.md
Last active August 29, 2015 14:14
reddit base
@JamWils
JamWils / _.md
Created February 6, 2015 00:56
reddit base
@JamWils
JamWils / _.md
Last active August 29, 2015 14:14
reddit base
@JamWils
JamWils / _.md
Created February 8, 2015 01:16
reddit base
@JamWils
JamWils / _.md
Last active August 29, 2015 14:15
reddit table
def h_levelsum(self) -> int:
'''The sum of the level costs of the individual goals (admissible if goals independent)
:return: int
'''
level_sum = 0
# TODO implement
# for each goal in the problem, determine the level cost, then add them together
for goal in self.problem.goal:
levels = [level for level in range(len(self.s_levels)) for state in self.s_levels[level] if goal == state.literal]
@JamWils
JamWils / chanceSample.js
Last active June 8, 2017 19:00
Small Chance Sample
const item = {}
item.uid = chance.guid();
item.email = chance.email();
item.profileImageUrl = chance.avatar();
item.username = chance.name();
function randomIntInc(low, high) {
return Math.floor(Math.random() * (high - low + 1) + low);
}
function createUsers(low, high) {
let items = {};
const generatedItems = randomIntInc(low, high);
for (let i = 0; i < generatedItems; i++) {
const item = {}
exports.schema = function () {
let parent = {}
parent.users = createUsers(3, 7);
return parent;
}
const json = mockDataSchema.schema();
const jsonFormatted = JSON.stringify(json);
fs.writeFile("./mockData/db.json", jsonFormatted, (err) => {
if (err) {
return console.log(chalk.red(err));
} else {
console.log(chalk.green("Mock data generated."));
}
});