Skip to content

Instantly share code, notes, and snippets.

View deepak-terse's full-sized avatar
🏠
Working Remotely

Deepak Terse deepak-terse

🏠
Working Remotely
View GitHub Profile
@deepak-terse
deepak-terse / auto-increment-version.yaml
Created February 27, 2024 11:07
Auto increments package version on every branch merge to main branch
name: Auto Increment Version
on:
push:
branches:
- main
jobs:
increment_version:
runs-on: ubuntu-latest
/*
Problem Statement:
- To have a cost-effective data backup backup mechanism for mongodb on a daily basis.
Solution:
- To write a cron job that will backup data from all collections of a mongo db and store it on the server
- 7 days of backup will be maintained at any given point of time (post 7 days of successful backup). This is done so that the DB could be restored to any day in the last 7 days.
- Appropriate success/failure logs are maintained for further debugging.
- Alos log the number of records that are backed up.
- Library used:
@deepak-terse
deepak-terse / TimeConvert.js
Created March 25, 2021 16:39
Time Convert
/*
Problem Statement:
- Have the function TimeConvert(num) take the num parameter being passed and return the number of hours and minutes the parameter converts to (ie. if num = 63 then the output should be 1:3). Separate the number of hours and minutes with a colon.
Examples
Input: 126
Output: 2:6
Input: 45
Output: 0:45
*/
@deepak-terse
deepak-terse / TicTacToe.jsx
Created March 25, 2021 16:34
Tic Tac Toe
/*
Problem Statement:
- The goal is to create a functioning Tic Tac Toe game.
- It should work the following way: the first player to go places an X anywhere on the board by clicking a square, and then the next player will be able to place an O, and it continues alternating like this every turn.
- You should also implement a function to determine if any player won by getting 3 X's or O's in a row.
- If there is a winner, display a message at the top.
- If nobody wins, then do not display any message.
- Finally, you should also implement the reset function that resets the entire board.
- You should also not be able to override the other players move during the game.
*/
@deepak-terse
deepak-terse / Calculator.js
Last active March 25, 2021 16:27
Calculator
/*
Problem Statement:
- Have the function Calculator(str) take the str parameter being passed and evaluate the mathematical expression within in.
- For example, if str were "2+(3-1)*3" the output should be 8.
- Another example: if str were "(2-0)(6/2)" the output should be 6.
- There can be parenthesis within the string so you must evaluate it properly according to the rules of arithmetic.
- The string will contain the operators: +, -, /, *, (, and ).
- If you have a string like this: #/#*# or #+#(#)/#, then evaluate from left to right. So divide then multiply, and for the second one multiply, divide, then add.
- The evaluations will be such that there will not be any decimal operations, so you do not need to account for rounding and whatnot.
@deepak-terse
deepak-terse / EightQueens.js
Last active March 25, 2021 16:28
Eight Queens
/*
Problem Statement:
- Have the function EightQueens(strArr) read strArr which will be an array consisting of the locations of eight Queens on a standard 8x8 chess board with no other pieces on the board
- The structure of strArr will be the following: ["(x,y)", "(x,y)", ...] where (x,y) represents the position of the current queen on the chessboard (x and y will both range from 1 to 8 where 1,1 is the bottom-left of the chessboard and 8,8 is the top-right).
- Your program should determine if all of the queens are placed in such a way where none of them are attacking each other.
- If this is true for the given input, return the string true otherwise return the first queen in the list that is attacking another piece in the same format it was provided.
For example: if strArr is ["(2,1)", "(4,2)", "(6,3)", "(8,4)", "(3,5)", "(1,6)", "(7,7)", "(5,8)"] then your program should return the string true. The corresponding chessboard of queens for this input is below (taken from Wikipedia).
Examples
@deepak-terse
deepak-terse / object-traversal.js
Last active March 25, 2021 15:51
Object Traversal
/*
Problem Statement:
- To write a function 'findPath' which will traverse through the object 'obj' and print the output based on the path specified
- The sample I/P and O/P is given below in the console statement
*/
var obj = {
a: {
b: {
c: 12
}
let tarzan = new Car("Mercedez Benz", Color.BLACK);
tarzan.start();
tarzan.changeGears();
tarzan.stop();
class Car {
id: string;
modelName: string;
color: Color;
constructor(modelName: string, color: Color) {
this.modelName = modelName;
this.color = color;
}