Skip to content

Instantly share code, notes, and snippets.

Avatar
Codin'

Gatare Libère gatarelib

Codin'
View GitHub Profile
View JS-Question.md

Write a function:

function solution(A);

that, given an array A of N integers, returns the smallest positive integer (greater than 0) that does not occur in A.

For example, given A = [1, 3, 6, 4, 1, 2], the function should return 5.

Given A = [1, 2, 3], the function should return 4.

@gatarelib
gatarelib / andela_tech_challenge-cycle-11-kigali.markdown
Created Aug 21, 2019
Andela_Tech_Challenge - Cycle 11 (Kigali)
View andela_tech_challenge-cycle-11-kigali.markdown
@gatarelib
gatarelib / shopping_cart
Created Aug 14, 2019
Andela - Python D2 Software Developer
View shopping_cart
class ShoppingCart(object):
def __init__(self):
self.total = 0
self.items = {}
def add_item(self, item_name, quantity, price):
self.total += quantity * price
if type(item_name) == str and quantity > 0:
self.items.update({item_name: quantity})
@gatarelib
gatarelib / min_swaps.py
Created Aug 14, 2019
Andela - Python D2 Software Developer
View min_swaps.py
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):
@gatarelib
gatarelib / intspliter.py
Created Aug 14, 2019
Andela - Python D2 Software Developer
View intspliter.py
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 / ordinal.js
Created Aug 14, 2019
Andela assessment
View ordinal.js
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 Aug 14, 2019
Andela assessment
View change.js
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 Aug 14, 2019
Andela assessment
View power.js
let power = (a,b) => {
if (b <= 1) {
return a;
} else {
return a * power(a, b-1);
}
};
power(3, 4);
@gatarelib
gatarelib / sorting.js
Created Aug 14, 2019
Andela assessment
View sorting.js
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 {