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
| (defn gcd | |
| [a b] | |
| (if (zero? b) | |
| a | |
| (gcd b (rem a b)))) | |
| (reduce (fn [a b] (/ (* a b) (gcd a b))) (range 1 21)) |
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
| (defn reverse-str | |
| [s] | |
| (apply str (reverse s))) | |
| (defn palindromic? | |
| [n] | |
| (let [s (str n)] | |
| (= (reverse-str s) s))) | |
| (apply max (filter palindromic? (for [x (range 100 1000) y (range 100 1000)] (* x y)))) |
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
| object Issue5 { | |
| def gcd(a: Long, b: Long): Long = { | |
| if (b == 0) a else gcd(b, a % b) | |
| } | |
| def lcm(a: Long, b: Long) = { | |
| a * b / (gcd(a, b)) | |
| } | |
| def smallestLcm(l: List[Long]) = { |
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
| object Issue4 { | |
| val MIN = 100 | |
| val MAX = 999 | |
| def isPalindromic(n: Int) = { | |
| val s = n.toString | |
| s == s.reverse | |
| } | |
| def maxPalindromic() = { |
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
| import java.lang.Math | |
| object Issue3 { | |
| def isPrime(n: Long) = { | |
| if (n <= 1) false | |
| else if (n == 2) true | |
| else if (n % 2 == 0) false | |
| else { | |
| val max = Math.sqrt(n).toInt | |
| !3.to(max, 2).exists(n % _ == 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
| <?xml version="1.0"?> | |
| <settings> | |
| <mirrors> | |
| <mirror> | |
| <id>nexus</id> | |
| <url>http://172.25.21.93:8081/nexus/content/groups/public</url> | |
| <mirrorOf>*</mirrorOf> | |
| </mirror> | |
| <mirror> | |
| <id>Midas-snapshot</id> |
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
| #!/bin/bash | |
| #attach the EBS to /dev/sdf before running it | |
| #format EBS | |
| mkfs -t ext4 /dev/xvdf | |
| #copy original /var to /dev/xvdf | |
| mkdir /mnt/new | |
| mount /dev/xvdf /mnt/new | |
| cd /var |
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
| class OnlyFullGc { | |
| private static final int _1M = 1024 * 1024; | |
| //java -verbose:gc -XX:+PrintGCDetails -XX:PretenureSizeThreshold=3145728 -Xms20M -Xmx20M -Xmn10M OnlyFullGc | |
| //1 | |
| //2 | |
| //[GC [Tenured: 9216K->4237K(10240K), 0.0110910 secs] 9543K->4237K(19456K), [Perm : 91K->91K(12288K)], 0.0113940 secs] [Times: user=0.01 sys=0.00, real=0.01 secs] | |
| //3 | |
| //Heap |
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
| private static final int _1M = 1024 * 1024; | |
| /** | |
| * Test with -verbose:gc -XX:+PrintGCDetails -Xms20M -Xmx20M -Xmn10M -XX:MaxTenuringThreshold=1 | |
| */ | |
| public static void testMaxTenuringThreshold() { | |
| byte[] a1, a2, a3; | |
| a1 = new byte[_1M / 4]; | |
| System.out.println(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
| private static final int _1M = 1024 * 1024; | |
| /** | |
| * Test with -verbose:gc -XX:+PrintGCDetails -Xms20M -Xmx20M -Xmn10M | |
| */ | |
| public void testMinorGc() { | |
| byte[] a1, a2, a3, a4; | |
| a1 = new byte[_1MG / 2]; | |
| System.out.println(1); | |
| a2 = new byte[3 * _1MG]; |