Skip to content

Instantly share code, notes, and snippets.

View AndyMoreland's full-sized avatar

Andrew Moreland AndyMoreland

View GitHub Profile

Keybase proof

I hereby claim:

  • I am andymoreland on github.
  • I am andymoreland (https://keybase.io/andymoreland) on keybase.
  • I have a public key ASCa2VlKr2QStLgs-6Yv1RS2eE1HBpM0okzaqzrnSHKa2go

To claim this, I am signing this object:

@AndyMoreland
AndyMoreland / init.el
Created December 21, 2015 23:53
Typescript compiler error regexp for emacs M-x compile
(add-hook 'typescript-mode-hook
(lambda ()
(add-to-list 'compilation-error-regexp-alist
'("^\\([_.[:alnum:]-/]*.ts\\)(\\([[:digit:]]+\\),\\([[:digit:]]+\\)).*$" 1 2 3))))
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
gem 'mysql2'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
@AndyMoreland
AndyMoreland / gist:5394654
Last active December 16, 2015 06:49
Expects socket.io-client, mongodb and ws to be installed with npm.
var WebSocket = require('ws')
var io = require('socket.io-client');
var MongoClient = require('mongodb').MongoClient;
console.log("Building websocket");
ws = io.connect('https://socketio.mtgox.com/mtgox')
console.log(ws);
// FOUND IN src/java/com/andymoreland/GoogleSpreadsheet/
package com.andymoreland.GoogleSpreadsheet;
import java.io.IOException;
import java.net.URL;
import java.util.List;
import com.google.gdata.client.Service;
import com.google.gdata.client.spreadsheet.SpreadsheetService;
var html = require('fs').readFileSync(__dirname+'/index.html');
var fs = require('fs');
var server = require('http').createServer(function(req, res){
res.end(html);
});
server.listen(8080);
$( function () {
var ws = new WebSocket("ws://localhost:3001/sockjs/websocket");
ws.onopen = function() {
ws.send('{"msg":"connect","id":"1"}');
ws.send('{"msg":"method","method":"pageHit","params":["'+window.location.href+'","'+document.referrer+'","'+document.title+'"],"id":"2"}');
ws.close();
}
}
|------------------------------
| \ |
| \ x x \ \ G |
| \ \ \ |
| \ x x \ \|
|\ \ \ |
| \ \ x x \ |
| \ \ x x \ |
| \ \ \ |
| G \ \ \ |
Let's assume optimal strategy. If there is only one stack, then the first player to move can win if he wants to by taking all of the stones. IF both players want to lose, then the first player still wins because the second player can take all of the stones except for one that the first player leaves.
Okay, so how does this transfer to a two stack game?
The first person to make a move on the last stack remaining wins.
So basically, if you want to win, you need to lose the first stack.
As shown above, the first player always wins the first stack, regardless of his decision.
$.post(this.action+ ".js", data).complete(function () { alert("yo?"); }).success(
function () {
alert("Hello");
$(this).parent().hide().prev("tr").show();
});