I hereby claim:
- I am railsstudent on github.
- I am connieleung (https://keybase.io/connieleung) on keybase.
- I have a public key whose fingerprint is 4214 A3D9 A934 58FA 5082 4639 4876 31BE 0EB1 A0D1
To claim this, I am signing this object:
# sorry i cheat. Copy the idea from http://www.geeksforgeeks.org/merging-intervals/ | |
sumIntervals = (intervals) -> | |
# sort intervals by starting time in ascending order | |
sortedIntervals = intervals.sort((a, b) -> | |
return a[0] - b[0] | |
) | |
stack = [sortedIntervals[0]] | |
for i in [1...sortedIntervals.length] | |
stackTop = stack[stack.length - 1] | |
if sortedIntervals[i][0] > stackTop[1] then stack.push sortedIntervals[i] |
solution = (str) -> | |
newStr = str | |
if str.length % 2 is 1 then newStr += '_' | |
result = [] | |
for i in [0...newStr.length] by 2 | |
result.push (newStr[i..i+1]) | |
result |
validBraces = (braces) -> | |
bracesMap = { | |
']': '[', | |
')': '(', | |
'}': '{' | |
} | |
stack = []; | |
for i in [0...braces.length] | |
if braces[i] in ['(', '{', '['] then stack.push braces[i] |
add = (a, b) -> | |
strA = "#{a}" | |
strB = "#{b}" | |
lenA = strA.length | |
lenB = strB.length | |
# if length is different, prepend the shorter one with 0 | |
if lenA < lenB | |
strA = '0' + strA for i in [0...(lenB - lenA)] | |
else | |
strB = '0' + strB for i in [0...(lenA - lenB)] |
pushAtom = (stack, atom, index) -> | |
# push previous element if exists | |
a = {} | |
a[atom] = Number(index) if atom isnt '' and index isnt '' | |
a[atom] = 1 if atom isnt '' and index is '' | |
stack.push (a) if a[atom] | |
pushMoleculeBtwBrackets = (stack, openBracket, closeBracket, index) -> | |
moculeStack = [] | |
for i in [stack.length - 2..0] by -1 |
I hereby claim:
To claim this, I am signing this object:
@Override | |
protected void actionOnTouch(float x, float y) { | |
//Increase/decrease the speed of the ball making the ball move towards the touch | |
mBallX = x; | |
mBallY = y; | |
// mBallSpeedX = x - mBallX; | |
// mBallSpeedY = y - mBallY; | |
mBallSpeedX = (x - mBallX) * 2; | |
mBallSpeedY = (y - mBallY) * 2; | |
} |
@Override | |
protected void actionOnTouch(float x, float y) { | |
//Increase/decrease the speed of the ball making the ball move towards the touch | |
mBallX = x; | |
mBallY = y; | |
mBallSpeedX *= 2; | |
mBallSpeedY *= 2; | |
// mBallSpeedX = x - mBallX; | |
// mBallSpeedY = y - mBallY; | |
} |