Skip to content

Instantly share code, notes, and snippets.

View surajhell88's full-sized avatar
🏠
Working from home

Suraj Jadhav surajhell88

🏠
Working from home
View GitHub Profile
@surajhell88
surajhell88 / README.md
Last active May 20, 2018 16:49
Calculate Attempts until Kaprekar's Constant from a 4-digit Integer

Get Attempts until Kaprekar's Constant

Given a 4-digit integer to the function, calculate the number of attempts until it reaches kaprekar's constant i.e. 6174

Few Examples

  1. KaprekarsConstant(8) // 6
  2. KaprekarsConstant(1324) // 3
  3. KaprekarsConstant(3322) // 4
@surajhell88
surajhell88 / README.md
Last active May 19, 2018 09:07
Simple Promise Implementation

Simple Promise Implementation

A simple javascript implmentation of promise object. It isn't the best solution but does solve the given problem statement. The probable todo items/improvements would be to refer MDN doc for Promise

Listing a few here:

  1. .all(iterable)
  2. .reject(promiseInstance)
  3. .resolve(promiseInstance)
  4. .finally(callback)
@surajhell88
surajhell88 / README.md
Last active May 19, 2018 09:03
Get the first missing positive integer

Search Missing Integer in a given array of Integers

For eg.

  1. searchMissingPositiveInteger([1,4,123]) // should give 2
  2. searchMissingPositiveInteger([-12, -3]) // should give 1
  3. searchMissingPositiveInteger([1, 2, ... , 999]) // should give 1000