Skip to content

Instantly share code, notes, and snippets.

View okplanbo's full-sized avatar
🏃‍♂️
Move!

Boris okplanbo

🏃‍♂️
Move!
View GitHub Profile
@okplanbo
okplanbo / getEquilibrium.java
Created May 14, 2018 14:26
Finding an equilibrium index in an int array
public int getEquilibrium(int[] array) {
long totalSum = sum(array);
long lowSum = 0L;
for (int i = 0; i < array.length; i++) {
totalSum -= array[i];
if (lowSum == totalSum) {
return i;
}
lowSum += array[i];
}
@okplanbo
okplanbo / OneLineFizzBuzz.py
Created May 12, 2018 16:00
Yet another solution to FizzBuzz in one line (Python3)
for m in range(1,100): print("FizzBuzz" if (m%15==0) else"Fizz" if (m%3==0) else "Buzz" if (m%5==0) else m)