Skip to content

Instantly share code, notes, and snippets.

@JamWils
JamWils / _.md
Last active Aug 29, 2015
reddit base
View _.md
View _.md
@JamWils
JamWils / _.md
Last active Aug 29, 2015
reddit base
View _.md
View _.md
@JamWils
JamWils / _.md
Last active Aug 29, 2015
reddit table
View _.md
View gist:3d88d82ad66371139c9765f24200f5e0
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 Jun 8, 2017
Small Chance Sample
View chanceSample.js
const item = {}
item.uid = chance.guid();
item.email = chance.email();
item.profileImageUrl = chance.avatar();
item.username = chance.name();
View randomChance.js
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 = {}
View exportChance.js
exports.schema = function () {
let parent = {}
parent.users = createUsers(3, 7);
return parent;
}
View generatingJSON.js
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."));
}
});