Skip to content

Instantly share code, notes, and snippets.

View IEdiong's full-sized avatar
👨‍🍳
Cooking

Ediongsenyene Joseph IEdiong

👨‍🍳
Cooking
View GitHub Profile
@IEdiong
IEdiong / array_product.py
Last active May 2, 2021 22:36
Algorithm Fridays Week 4
def prodOfNums(nums):
if len(nums) == 0:
return "invalid array: input an array of numbers"
else:
prod = 1
ans = []
for i in nums:
prod *= i
for i in range(0,len(nums)):
ans.append(prod // nums[i])
@IEdiong
IEdiong / shuffleClass.py
Last active May 21, 2021 09:24
Algorithm Fridays Week 6
from collections import deque
def shuffleClass(listOfPupils, n):
#test if listOfPupils is a list, has none value or empty
if (not isinstance(listOfPupils, list)) or (not listOfPupils):
return []
#takes the last 'n' items to the front using 'deque'
else:
@IEdiong
IEdiong / minTimeDifference.py
Last active May 28, 2021 04:31
This program was created to help Esther (our fictitious client) to find the minimum time difference between any two of her wake up times recorded in her journal
from itertools import combinations
def minDifference(wakeTimes):
# if wakeTimes is an empty array
if not wakeTimes:
return 0
# creates an array of wakeTimes in minute
wakeTimesInMins = list(map( lambda x: int(x[0]) * 60 + int(x[1]), [ time.split(":") for time in wakeTimes ]))
@IEdiong
IEdiong / containsDuplicate.js
Created December 19, 2021 00:49
LeetCode Data Structure I: Day 1 - 001
// 217. Contains Duplicate
// Easy
// Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.
const containsDuplicate = (nums) => {
// create an empty dictionary
// iterate through the array
// for each integer in the array check if the integer position exists in the dictionary
// if 'yes' return 'true'
@IEdiong
IEdiong / removeKFromList.js
Last active April 17, 2022 15:18
Code Signal: removeKFromList solution -- Interview Practice__Linked List - 01 (Easy)
// Singly-linked lists are already defined with this interface:
// function ListNode(x) {
// this.value = x;
// this.next = null;
// }
//
function solution(l, k) {
if (l === null) return l; // return if the linked list is empty
let dummyNode = new ListNode(); // create a dummy node whose next points to the head of the given Linked List
@IEdiong
IEdiong / matrixElementsSum.js
Created April 18, 2022 20:50
Code Signal matrixElementsSum Solution in JS
function solution(matrix) {
const hauntedRoom = {};
const numberOfFloors = matrix.length;
const numberOfRooms = matrix[0].length;
let total = 0;
// 1. Loop through each row
for (let floor = 0; floor < numberOfFloors; floor++) {
// 2. For each element in the row
for (let room = 0; room < numberOfRooms; room++) {
@IEdiong
IEdiong / sort_diagonal.py
Last active April 20, 2022 15:39
Sort the diagonals in ascending order from bottom left to top right of a given a squared matrix of positive integers implemented in python
def solution(matrix):
M, N, diagonals = len(matrix), len(matrix[0]), []
# 1. Get all the diagonals
for row in range(0, M):
col, temp, i = 0, [], row
j = col
while i >= 0 and j < N:
temp.append(matrix[i][j])
using namespace System.Management.Automation
using namespace System.Management.Automation.Language
if ($host.Name -eq 'ConsoleHost')
{
Import-Module PSReadLine
}
#Import-Module PSColors
#Import-Module posh-git
Import-Module -Name Terminal-Icons
@IEdiong
IEdiong / revert-a-commit.md
Created August 26, 2022 06:13 — forked from gunjanpatel/revert-a-commit.md
Git HowTo: revert a commit already pushed to a remote repository

Revert the full commit

Sometimes you may want to undo a whole commit with all changes. Instead of going through all the changes manually, you can simply tell git to revert a commit, which does not even have to be the last one. Reverting a commit means to create a new commit that undoes all changes that were made in the bad commit. Just like above, the bad commit remains there, but it no longer affects the the current master and any future commits on top of it.

git revert {commit_id}

About History Rewriting

Delete the last commit

Deleting the last commit is the easiest case. Let's say we have a remote origin with branch master that currently points to commit dd61ab32. We want to remove the top commit. Translated to git terminology, we want to force the master branch of the origin remote repository to the parent of dd61ab32:

@IEdiong
IEdiong / nodejs.errno.h
Created March 17, 2023 10:51 — forked from pbojinov/nodejs.errno.h
node.js errno descriptions. Useful for debugging.
/* Pulled from https://github.com/joyent/node/blob/master/deps/uv/include/uv.h */
/* Expand this list if necessary. */
#define UV_ERRNO_MAP(XX) \
XX(E2BIG, "argument list too long") \
XX(EACCES, "permission denied") \
XX(EADDRINUSE, "address already in use") \
XX(EADDRNOTAVAIL, "address not available") \
XX(EAFNOSUPPORT, "address family not supported") \
XX(EAGAIN, "resource temporarily unavailable") \
XX(EAI_ADDRFAMILY, "address family not supported") \