Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View gatarelib's full-sized avatar
Codin'

Gatare Libère gatarelib

Codin'
View GitHub Profile
@gatarelib
gatarelib / main.py
Created October 8, 2018 05:43
insertion_sort Algo created by ligat - https://repl.it/@ligat/insertionsort-Algo
# Insertion Sort In Python
#
# Performance Complexity = O(n^2)
# Space Complexity = O(n)
def insertionSort(my_list):
# for every element in our array
for index in range(1, len(my_list)):
current = my_list[index]
position = index
@gatarelib
gatarelib / InsertionSortAlgo.py
Last active October 8, 2018 05:58
insertion_sort Algo created by ligat - https://repl.it/@ligat/insertionsort-Algo
# Insertion Sort In Python
#
# Performance Complexity = O(n^2)
# Space Complexity = O(n)
def insertionSort(my_list):
# for every element in our array
for index in range(1, len(my_list)):
current = my_list[index]
position = index
@gatarelib
gatarelib / comment.js
Created August 14, 2019 12:31
Andela-assessment
class User {
constructor(name) {
this._name = name;
this._loggedIn = false;
this._lastLoggedInAt = null;
}
isLoggedIn() {
return this._loggedIn;
}
getLastLoggedInAt() {
@gatarelib
gatarelib / digitize.js
Created August 14, 2019 12:32
Andela assessment Question
const digitize = (n) => {
r = n.toString().split('');
r.forEach((el, i, a) => { a[i] = parseInt(el); })
return r
}
digitize(715) // [7, 1, 5]
@gatarelib
gatarelib / sorting.js
Created August 14, 2019 12:33
Andela assessment
function mySort(nums) {
let evens = [];
let odds = [];
for (let i = 0; i < nums.length; i++) {
if(typeof nums[i] === "number"){
if ((nums[i] % 2) === 1) {
odds.push(parseInt(nums[i]));
}
else {
@gatarelib
gatarelib / ordinal.js
Created August 14, 2019 12:39
Andela assessment
function numberToOrdinal(n) {
if (n==0) {
return n;
}
var j = n % 10,
k = n % 100;
if (j == 1 && k != 11) {
@gatarelib
gatarelib / change.js
Last active August 14, 2019 12:40
Andela assessment
var countChange = function(money, coins) {
return findComboCount(money, coins, 0);
}
function findComboCount(money, coin, index) {
if(money === 0){
return 1;
}
else if (money < 0 || coin.length == index) {
return 0;
@gatarelib
gatarelib / power.js
Last active August 14, 2019 12:41
Andela assessment
let power = (a,b) => {
if (b <= 1) {
return a;
} else {
return a * power(a, b-1);
}
};
power(3, 4);
@gatarelib
gatarelib / intspliter.py
Created August 14, 2019 13:02
Andela - Python D2 Software Developer
def splitInteger(num,parts):
quotient, remainder = divmod(num, parts)
lower_elements = [quotient] * (parts - remainder)
higher_elements = [quotient + 1] * remainder
return lower_elements + higher_elements
@gatarelib
gatarelib / min_swaps.py
Created August 14, 2019 13:03
Andela - Python D2 Software Developer
def minimum_swaps(ratings):
if sorted(ratings, reverse=True) == ratings:
return 0
swaps = 1
while sorted(ratings, reverse=True) != sorter(ratings):
swaps += 1
return swaps
def sorter(array):