Skip to content

Instantly share code, notes, and snippets.

View obbap1's full-sized avatar

Obba Paschal obbap1

View GitHub Profile
func main() {
gen := func(ctx context.Context) <-chan int {
dst := make(chan int)
n := 1
go func() {
for {
select {
case <-ctx.Done():
fmt.Println("done", ctx.Err())
os.Exit(0)
function swap(firstNumber, secondNumber) {
// put your code here, so that firstNumber is the secondNumber and secondNumber and is the firstNumber
// -------------- DO NOT TOUCH BELOW HERE -----------------------------
console.log(firstNumber) // should be 6
console.log(secondNumber) // should be 5
}
swap(5,6)
// The chinese remainder theorem finds the number that
// satisfies a set of equations where the divisors are pairwise coprime
// (where the highest common factor between the divisors is 1) and the remainder is own.
// Eg. x = 2 (mod 3) = 3 (mod 5) = 2 (mod 7). Where 3,5, and 7 are pairwise coprime.
package main
import "fmt"
// Eg. x = b1(mod n1) = b2(mod n2) = b3(mod n3)
let str = "i am a boy and i am happy to be in your midst"
const final = {}
str.split(" ").map((s, index, arr) => {
// remove the commas
// make lowercase
// console.log({s})
if(s == "am") {
if(!final[s]) {
interface IEdge {
key: string
from: string
to: string
}
interface IVertex {
key: string
label: string
}
/******************** HELPER FUNCTION **********************/
//Filter array for any distinct values --- STACKOVERFLOW
function isDistinct(array) {
return new Set(array).size === array.length;
}
// Use combination sum to get all the possible combinations
function combinationSum(candidates, target) {
var result = [];
@obbap1
obbap1 / solution.js
Last active January 14, 2022 21:41
Hacker rank's 'Stock Open Close Price' Solution with JS
const https = require("https");
const monthNames = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
const { expect } = require('chai')
const createCategoryFactory = require('../create-category')
const ProductCategory = require('./mocks/product-category.mock')
const req = require('./mocks/req.mock')
const res = require('./mocks/res.mock')
describe('create-category', () => {
const createCategory = createCategoryFactory({ ProductCategory })
beforeEach(() => {
const newCategory = {
Thumbnail: undefined,
checkFile (category, file) {
file ?
category.categoryThumbnail = {name: file.public_id, url: file.url}
: category.categoryThumbnail = null
this.Thumbnail = category.categoryThumbnail;
return this;
const typeDefs = gql`
scalar Date
# Make a type user
type User {
email: String!
password: String!
data: [Graph!]
}