This file contains hidden or 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
# internal: generate permutation recursively | |
generatePermutation = (perm, pre, post, n) -> | |
if n > 0 | |
for i in [0...post.length] | |
rest = post.slice 0 | |
elem = rest.splice i, 1 | |
generatePermutation perm, pre.concat(elem), rest, n - 1 | |
else | |
perm.push pre | |
return |
This file contains hidden or 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
// JavaScript Array permutation generator | |
// (optimized from CoffeeScript output: see ArrayPermutation.coffee) | |
(function() { | |
var generatePermutation = function(perm, pre, post, n) { | |
var elem, i, rest, len; | |
if (n > 0) | |
for (i = 0, len = post.length; i < len; ++i) { | |
rest = post.slice(0); | |
elem = rest.splice(i, 1); | |
generatePermutation(perm, pre.concat(elem), rest, n - 1); |
This file contains hidden or 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
run Rack::Directory.new '.' |
This file contains hidden or 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
source 'https://rubygems.org' | |
ruby 2.0.0 | |
gem 'rack' |
This file contains hidden or 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
a = for x in [0..5] | |
x * x | |
console.log a # => [ 0, 1, 4, 9, 16, 25 ] | |
b = while a.length > 0 | |
a.pop() | |
console.log b # => [ 25, 16, 9, 4, 1, 0 ] |
This file contains hidden or 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
require 'set' | |
require 'mathn' | |
module Alphametics | |
def solve(puzzle) | |
puzzle = puzzle.upcase | |
words = puzzle.scan /[A-Z]+/ | |
chars = Set.new words.join.each_char | |
abort 'Too many letters' if chars.size > 10 | |
first_chars = Set.new words.select {|w| w.size > 1 }.map {|w| w[0] } |
This file contains hidden or 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
This is *emphasized* |
This file contains hidden or 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 Rack::ETag | |
use Rack::Deflater | |
use Rack::Static, urls: [''], root: 'public', index: 'index.html' | |
run lambda {|env|} # run proc {|env|} も可 |
This file contains hidden or 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
Accept-Encoding: gzip, deflate |
This file contains hidden or 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
<!-- Latest compiled and minified CSS --> | |
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> | |
<!-- Optional theme --> | |
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css"> | |
<!-- Latest compiled and minified JavaScript --> | |
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script> |
OlderNewer