I hereby claim:
- I am blh0021 on github.
- I am benharrington (https://keybase.io/benharrington) on keybase.
- I have a public key ASCEF4NlSJN8zD-A-If46uLTgbm7APL_hhcd-B8S8oqzXgo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
#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 |
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) { |
# pow 2 3 | |
# 8 | |
function pow | |
{ | |
for ((x=1, p=$1; x<$2; x++)); do ((p *= $1)); done | |
echo $p | |
} | |
# sqrt 4 |