示例#1
0
var globals = require('../globals');

var python = require('node-python');
os = python.import('os'),
sysp = python.import('sys'),
cwd = os.getcwd(),
sysp.path.append(cwd + "/question");
var runner = python.import('run_wrapper')

var questions = [
{
	"title":"Pairs",
	"details":"Given N integers [N<=10^5], count the total pairs of integers that have a difference of K. [K>0 and K< 1e9]. Each of the N integers will be greater than 0 and at least K away from 2^31-1 (Everything can be done with 32 bit integers)."
},
{
	"title":"FizzBuzz",
	"details":"Write a program that prints the integers from 1 to 100. But for multiples of three print 'Fizz' instead of the number and for the multiples of five print 'Buzz'. For numbers which are multiples of both three and five print 'FizzBuzz'.",
},
{
        "title":"Color RGB Int to Hex",
        "details":"Given three integers rgb, output hexadecimal representation as a string.",
},
{
        "title":"Emulate a MOS 6502 CPU",
        "details":"The challenge is to write your own 6502 CPU emulator. This involves, of course, understanding it's instruction set and it's encoding format. Resources are linked at the bottom of this. The 6502 is one of the easiest real-world processors to emulate. For the purposes of this challenge, you won't need to worry about cycle timing if you don't want to -- but that's always a plus to include!",
},
{
        "title":"Implement division using only addition",
        "details":"What this means is basically: addition is the only operator or function allowed that operates on numbers and returns other numbers (i.e. no subtraction, multiplication, exponentiation, bitwise inversion, etc.). Stuff like if statements, assignment and comparison operators, and for loops are still allowed, provided that within those, you still only use addition.",
},
{
示例#2
0
var TWITTER_HASHTAG = "#apple";
//var TWITTER_HASHTAG = "#cdm2014";
////////////////////////////////////////////////////////////////////////////////
//var EMULATOR_APP_NAME = "TextEdit";
var EMULATOR_APP_NAME = "Snes9x";
var EMULATOR_COMMAND_DEFAULT_DURATION = 100;
var EMULATOR_BUTTONS = {a: "a", b : "b", x: "x", y : "y", up : "u", down : "d", left : "l", right : "r", start : "s", select : "f"};
//var EMULATOR_COMMANDS = {jump: "jump", left: "left", right: "right", up: "up", down: "down"}; // real
var EMULATOR_COMMANDS = {jump: "j", left: "l", right: "r", up: "u", down: "d"}; // test commands

////////////////////////////////////////////////////////////////////////////////
// INIT
////////////////////////////////////////////////////////////////////////////////
var colors = require("colors");
var python = require("node-python");
var pykeyboard = python.import("pykeyboard").PyKeyboard(); //https://github.com/SavinaRoja/PyUserInput
var sleep = require("sleep");
var applescript = require("applescript");
var twit = require("twit");
var app = require("express")();
var server = require("http").createServer(app);
var io = require("socket.io")(server);

////////////////////////////////////////////////////////////////////////////////
// INIT
////////////////////////////////////////////////////////////////////////////////
setupServer();
activateEmulator(setupTwitter);

////////////////////////////////////////////////////////////////////////////////
function setupServer() {