Skip to content

Instantly share code, notes, and snippets.

@blh0021
blh0021 / keybase.md
Created February 9, 2017 16:28
keybase

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@blh0021
blh0021 / sum.rb
Last active August 29, 2015 14:02
Sum of Digits in Ruby
#too slow
def sum(s)
s=s.to_s
a=s.split("").map(&:to_i)
a.inject{|sum, a| sum+a}
end
#much faster sum
def sumd(n)
return 0 if n==0
@blh0021
blh0021 / Main.java
Created June 15, 2014 09:47
Code Eval base for Java solutions
import java.io.*;
public class Main {
public static void main(String[] args) {
File file = new File(args[0]);
try {
BufferedReader in = new BufferedReader(new FileReader(file));
String line;
while ((line = in.readLine()) != null) {
@blh0021
blh0021 / bash_math
Created June 14, 2014 13:12
Math functions using BASH
# pow 2 3
# 8
function pow
{
for ((x=1, p=$1; x<$2; x++)); do ((p *= $1)); done
echo $p
}
# sqrt 4