Skip to content

Instantly share code, notes, and snippets.

function GroupInvitations() {
this.event_id = 517949684905901;
this.member_ids = [];
this.semaphore = 0;
}
GroupInvitations.prototype = {
unlock: function() {
if (++(this.semaphore) === 3) {
resultStr = this.member_ids.join(',');
function GroupMining() {
this.member_ids = [];
this.semaphore = 0;
this.groupsCount = 1;
}
GroupMining.prototype = {
unlock: function() {
if (++(this.semaphore) === this.groupsCount) {
resultStr = this.member_ids.join(',');
@Hydrotoast
Hydrotoast / AdversarialSearchAI.java
Last active December 10, 2015 15:18
An pseudocode AI demonstrating the Minimax algorithm. Note that the algorithm has two helper functions: min and max.
class AdversarialSearchAI {
private PieceType piece;
public AdversarialSearchAI(PieceType piece) {
this.piece = piece;
}
/**
* Returns the best move given the state of the game
*/
-- Previous tables before this simply included members, events, projects and the auxiliaries.
-- I'm beginning to consider migrating this database from SQLite3 to MySQL 5.x
CREATE TABLE IF NOT EXISTS member_teams {
member_id INTEGER NOT NULL,
team_id INTEGER NOT NULL,
PRIMARY KEY (member_id, team_id),
FOREIGN KEY (member_id) REFERENCES members (member_id),
FOREIGN KEY (team_id) REFERENCES teams (team_id)
}
#include <thread>
#include <mutex>
class semaphore {
public:
semaphore(unsigned int count) : count_(count) {}
void wait() {
std::lock_guard<std::mutex> lock(mutex_);
while (!count_)
# No progress
def algo1():
while turn != i:
# no-op
# crit section
turn = j
# remainder section
# No progress
def algo2():
from math import sqrt
def prob10(mass, height, radius, mom_of_inertia, friction_work):
g = 9.8
# potential energy
mgh = mass * g * height
# total work after descent
work = mgh + friction_work
#ifndef BASECLASS_H
#define BASECLASS_H
#include <string>
#include <iostream>
template <class Derived>
class BaseClass
{
public:
#ifndef EVENT_H
#define EVENT_H
#include "DiscreteClock.h"
#include "SimulationState.h"
#include <functional>
class EventHandler;
@Hydrotoast
Hydrotoast / rhs.c
Created April 17, 2013 06:17
RHS Evaluation
int sum = 1;
for (int i = 0; i < 100; i++)
sum = sum + 1
return sum // returns 101