Skip to content

Instantly share code, notes, and snippets.

View railsstudent's full-sized avatar
🏠
Researching third-party library

Connie Leung railsstudent

🏠
Researching third-party library
View GitHub Profile
@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;
}
@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;
}

Keybase proof

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:

@railsstudent
railsstudent / parseModule.coffee
Last active November 13, 2016 15:11
Modules to atoms in codewars
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
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)]
@railsstudent
railsstudent / validBraces.coffee
Created November 13, 2016 16:19
Valid Braces kata published in codewars
validBraces = (braces) ->
bracesMap = {
']': '[',
')': '(',
'}': '{'
}
stack = [];
for i in [0...braces.length]
if braces[i] in ['(', '{', '['] then stack.push braces[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
# 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 = (string) ->
# Complete me!
alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
strCamelCase = ''
for s in string
if s not in alphabet then strCamelCase += s
else strCamelCase += ' ' + s
strCamelCase
snail = (array) ->
# enjoy
traversal = []
if array.length is 1 and array[0].length is 0 then return []
row = 0
col = 0
turn = 0
direction = 'E'
while traversal.length < (array.length * array.length)