This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_digits(num): | |
rem = num % 10 | |
it_num = num/10 | |
digits = [] | |
while(rem > 0 or it_num > 0): | |
if rem in digits: return None | |
digits.insert(0, rem) | |
rem = it_num % 10 | |
it_num = it_num/10 | |
return num |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import product | |
if __name__ == '__main__': | |
selections = 10 | |
blanks = 2 | |
select_range = range(1, selections+1) | |
all_unique = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
// this function creates an M+1xN+1 matrix where M is the length of the first string | |
// and N is the length of the second string and computes the number of changes it would | |
// require to convert string s to string t. The value at point (i,j) is the cost to | |
// compute s from [0..i] to t from [0..j] | |
function levenshtein(s, t) { | |
var m = s.length + 1; | |
var n = t.length + 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sudoku(puzzle) { | |
if (solved(puzzle)) { | |
return puzzle; | |
} | |
var copy = puzzle.slice(0); | |
for(var x=0;x<9; x++) { | |
for(var y=0;y<9;y++) { | |
if (puzzle[x][y] !== 0) continue; | |
var available = get_available(puzzle, x,y); | |
for(var i = 0; i < available.length;i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Just wanted to play around with creating addition and subtraction methods without using + and - | |
@author: David Brear | |
@date: 2015-05-11 | |
*/ | |
var add = function (x, y) { | |
while (y !== 0) { | |
var carry = x & y; | |
x = x ^ y; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.prototype.zeros = function() { return Array.apply(null, {length: this.length}).map(function(x){ return 0;}); }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
letters = [ l for l in 'abcdefghijklmnopqrstuvwxyz'] | |
sentence = 'Rz xvi jigt nzz v ncjmo ydnovixz vczvy, wpo rz xvi nzz kgziot oczmz ocvo izzyn oj wz yjiz. - Vgvi Opmdib' | |
def decrypt(letter): | |
if letter not in letters: return letter | |
return letters[((letters.index(letter) + 5) % len(letters))] | |
for word in sentence.split(' '): | |
print ''.join([decrypt(letter) for letter in word.lower()]), | |
# we can only see a short distance ahead, but we can see plenty there that needs to be done. - alan turing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component, PropTypes } from 'react'; | |
import logo from './logo.svg'; | |
import './App.css'; | |
import { connect } from 'react-redux'; | |
const mapStateToProps = (state) => ({ | |
name: state.name, | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from probability_solution import ( | |
make_power_plant_net, | |
set_probability, | |
get_alarm_prob, | |
get_gauge_prob, | |
get_temperature_prob, | |
get_marginal_temp_prob, | |
get_game_network, | |
calculate_posterior, | |
Gibbs_sampler, |
OlderNewer