Skip to content

Instantly share code, notes, and snippets.

View yashtibrewal's full-sized avatar
😃
Always smiling

Yash Tibrewal yashtibrewal

😃
Always smiling
View GitHub Profile
@yashtibrewal
yashtibrewal / multithreading.go
Created May 25, 2022 12:50
Multithreading Alternate (ZTM)
package main
import (
"bufio"
"fmt"
"io/ioutil"
"os"
"strings"
"sync"
)
@yashtibrewal
yashtibrewal / channels.go
Created May 25, 2022 09:45
Channels Alternative Solution (ZTM)
//--Summary:
// Create a program that utilizes goroutines to run the provided calculation
// function on a number of jobs. The results from the goroutines must be
// communicated back to the main thread using a channel, and then added
// together.
// Create reciever and send back
//--Requirements:
//* Run `longCalculation` for each job generated by the `makeJobs` function
//* Each job must be run in a separate goroutine
//* The result from `longCalculation` must be provided to the main function
@yashtibrewal
yashtibrewal / generics.go
Created May 24, 2022 13:40
Generics (ZTM)
//--Summary:
// Write a generic function to complete the existing code.
//
//--Requirements:
//* Write a single function named `clamp` that can restrict a value
// to a specific range
// - The function should work with floating point numbers, integers
// and arbitrary type aliases
// - Use the existing `clamp` function signature and comments as a
// starting point
@yashtibrewal
yashtibrewal / dashboard.go
Created May 24, 2022 12:10
Dashboard Alternative (ZTM)
//--Summary:
// Create a system monitoring dashboard using the existing dashboard
// component structures. Each array element in the components represent
// a 1-second sampling. e.g. for CPU, Network, Memory
//
//--Requirements:
//* Create functions to calculate averages for each dashboard component
//* Using struct embedding, create a Dashboard structure that contains
// each dashboard component
//* Print out a 5-second average from each component using promoted
@yashtibrewal
yashtibrewal / library.go
Created May 21, 2022 12:57
Library System in Go (ZTM Course)
//--Summary:
// Create a program to manage lending of library books.
//
//--Requirements:
//* The library must have books and members, and must include:
// - Which books have been checked out
// - What time the books were checked out
// - What time the books were returned
//* Perform the following:
// - Add at least 4 books and at least 3 members to the library
@yashtibrewal
yashtibrewal / Solution.java
Created February 12, 2022 20:55
Solution attempt to the question (google: Hackerrank poisonous biohazard allergic)
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
class Result {
private Result(){}
/*
* Complete the 'bioHazard' function below.
*