Skip to content

Instantly share code, notes, and snippets.

View ex's full-sized avatar
💭
I may be slow to respond.

me ex

💭
I may be slow to respond.
View GitHub Profile
@ex
ex / gist:3824991
Created October 3, 2012 04:24
Decrypt a message
// The text to decipher. It was created using a substitution cipher
var text = """
Fxr nb, ekb dmrdxjb xf upfb pj, ie ubije direuo, ex kizb txo.
Drxlrinnbrj xfeby fbbu txo akby ekbo qiy qxyqbyerieb xy ekb qrbiepzb
jpwb xf drxlrinnpyl, Jx Rmho pj wbjplybw ex nigb drxlrinnbrj kiddo.
Rmho pykbrpebw ekb Dbru dkpuxjxdko xf kizpyl nxrb ekiy xyb aio
ex wx ekb jinb ekpyl. P pykbrpebw ekie dkpuxjxdko frxn Uirro Aiuu,
akx pj no kbrx iqemiuuo. P aiye ex nigb Rmho mjbrj frbb. P aiye ex
lpzb ekbn ekb frbbwxn ex qkxxjb. Dbxdub irb wpffbrbye. Dbxdub qkxxjb
wpffbrbye qrpebrpi. Hme pf ekbrb pj i hbeebr aio inxyl niyo
@ex
ex / gist:3768883
Created September 23, 2012 04:34
Decrypt a message
// The text to decipher. It was created using a substitution cipher
var text = [[
Uid nx, aex jcdjipx iu wzux zp, ta wxtpa jtdaws, ai etkx vis.
Dcos zyexdzaxr aex Jxdw jezwipijes iu etkzyg nidx aety iyx hts
ai ri aex ptnx aezyg. Z zyexdzaxr aeta jezwipijes udin Wtdds Htww,
hei zp ns exdi tqactwws. Z htya ai ntfx Dcos cpxdp udxx. Z htya ai
gzkx aexn aex udxxrin ai qeiipx. Jxijwx tdx rzuuxdxya. Jxijwx qeiipx
rzuuxdxya qdzaxdzt. Oca zu aexdx zp t oxaaxd hts tniyg ntys
twaxdytazkxp, Z htya ai xyqicdtgx aeta hts os ntfzyg za qinuidatowx.
@ex
ex / euler393.html
Created September 23, 2012 02:15
Graphic display of problem Euler 393 with (n = 8)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Euler 393</title>
</head>
<body>
<div style="text-align: center;">
<canvas height="902" id="canvas" width="660"></canvas></div>
@ex
ex / gist:3734653
Created September 16, 2012 22:36
Project Euler 393
var count // number of final positions
var N // total cells in the board
var n // grid partition
function dfs(now, next) {
for (var k = 0; k < N; k += 1) {
// Find an ant to move.
if (now[k] > 0) {
// Try to move it to the right.
if ((k % n < n - 1) && (next[k + 1] == 0)
@ex
ex / Mandel.c
Created May 27, 2012 01:28
DOS Borland-C++ old source code of mine
//---------------------------------------------------------------
// Mandel.c
//---------------------------------------------------------------
// Fractal de Mandelbrot - Esau R.O
//---------------------------------------------------------------
#include "mandel.h"
#include "graficos.h"
extern double gf_x1;
@ex
ex / gist:781376
Last active September 24, 2015 17:08
public function solve():void {
txtResult.text = "";
// Create array of permutations of students.
var p:Array = permutations(students.split(""));
// Check every possibility.
for (var k:int = 0; k <= p.length; ++k) {
var s1:int = singleCorrectPredictions(p[k], guess1.split(""))
var d1:int = doubleConsecutivePredictions(p[k], guess1.split(""))
var s2:int = singleCorrectPredictions(p[k], guess2.split(""))
var d2:int = doubleConsecutivePredictions(p[k], guess2.split(""))
@ex
ex / gist:781372
Created January 15, 2011 23:31
permutation
def permutations(array)
n = array.length
return [array] if n < 2
rt = Array.new
for i in 0...n
## Create a new array from [array] where the
## [i]-th term has been ignored.
t = Array.new(array)
t.delete_at(i)
@ex
ex / gist:781369
Last active September 24, 2015 17:08
IMO 1962 Problem 01
public function solve():void {
txtResult.text = "";
var k:int = 1;
var k_up:int = 10; // Minimum (10^p) greater that k.
while (true) {
var n:int = (10 * k) + 6;
var m:int = (6 * k_up) + k;
// Check
if (m == 4 * n) {
txtResult.text += "ANSWER: " + n;
@ex
ex / gist:781366
Last active September 24, 2015 17:08
IMO 1960 Problem 01
public function solve():void {
txtResult.text = "";
var count:int = 1;
var k:int = 10;
while (k * 11 < 1000) {
// Calculate sum of the squares of the digits
var sumSquares:int = 0;
var n:int = k * 11;
while (n > 0) {
var digit:int = n % 10;
@echo off
SET count=1
#FOR /f "tokens=*" %%G IN ('dir /B /A-D') DO (
FOR /f "tokens=*" %%G IN ('dir *.as /B') DO (
call :move_svn %%G target_dir
)
GOTO :eof
:move_svn
echo %count%: %1 %2