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
public class PascalTriangle { | |
public static final int LINES = 10; | |
public static void main(String[] args) { | |
int[][] a = new int[LINES][]; | |
for (int i = 0, j = 1; i < LINES; i++, j++) { | |
a[i] = new int[j]; | |
for (int k = 0; k < j; k++) { | |
a[i][k] = (i == 0 || k == 0 || k == j - 1) ? 1 : a[i - 1][k - 1] + a[i - 1][k]; | |
} |
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 edu.emory.mathcs.jtransforms.fft.DoubleFFT_1D; | |
public class FftTest { | |
public static void main(String[] args) { | |
double[] input = new double[]{ | |
0.0176, | |
-0.0620, | |
0.2467, | |
0.4599, | |
-0.0582, |
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
;; possible moves of a knight | |
(def possible-moves [[2 1] [2 -1] [1 2] [1 -2] [-1 -2] [-1 2] [-2 -1] [-2 1]]) | |
;; he doesn't want to fall down | |
(defn valid-pos [xs] | |
(let [[x y] xs] | |
(and (<= 0 x 7) (<= 0 y 7)))) | |
;; he makes one random move | |
(defn one-step [xy] |
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
(defn shift13 [start n] | |
(let [s (int start) | |
c (int n)] | |
(char (if (<= s c (+ s 25)) | |
(+ s (mod (+ (- c s) 13) 26)) | |
n)))) | |
(defn rot13 [st] | |
(->> (map (fn [x] | |
(let [n (int x)] |
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
(defn euclid-gcd [m n] | |
(let [r (mod m n)] | |
(if (zero? r) | |
n | |
(euclid-gcd n r)))) | |
;; (euclid-gcd 2166 6099) => 57 | |
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
(defn extended-euclid [m n] | |
(loop [ap 1 | |
a 0 | |
bp 0 | |
b 1 | |
c m | |
d n] | |
(let [q (int (/ c d)) | |
r (mod c d)] | |
(if (zero? r) |
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; | |
use autodie; | |
use WWW::Mechanize; | |
use Getopt::Long; | |
use URI; | |
use Math::Random qw/random_exponential/; | |
my $url = ''; | |
my $interval = 5; | |
my $save = 'fetched'; |