Skip to content

Instantly share code, notes, and snippets.

Satya Jugran satya-jugran

  • India
Block or report user

Report or block satya-jugran

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@satya-jugran
satya-jugran / MostFreeTime.js
Created Sep 21, 2018
Find most free time of the day. Input string will represent full day filled with events that span from time X to time Y. Test case : 1) Input - "12:15PM-02:00PM","09:00AM-10:00AM","10:30AM-12:00PM" | Output - 00:30 2) Input - "12:15PM-02:00PM","09:00AM-12:11PM","02:02PM-04:00PM" | Output - 00:04
View MostFreeTime.js
function MostFreeTime(str) {
var dates = [];
str.split(",").forEach(d => {
dt = d.substring(1, d.length - 1).split("-");
s = dt[0];
dt[0] = s.substr(s.length - 2, 2) == "AM" ? s.substr(0, 5) :
(Number.parseInt(s.substr(0, 2)) < 12 ? Number.parseInt(s.substr(0, 2)) + 12 + ":" + s.substr(3, 2) : s.substr(0, 5));
s = dt[1];
@satya-jugran
satya-jugran / roulette.py
Created Nov 6, 2017
Python code for Roulette wheel selection
View roulette.py
#!/usr/bin/env python
import sys, time, numpy, random
# Individual has a genome and fitness and knows how to print itself
class Individual:
def __init__(self, genome):
if genome is None:
self.genome = numpy.array(numpy.random.random_integers(0, 1, LEN), dtype='bool')
else:
@satya-jugran
satya-jugran / GeoLocation.html
Created Mar 27, 2017
Code to view current location on Google Maps using HTML5 Geolocation
View GeoLocation.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<div id="geo-wrapper" width="600" height="400"></div>
<span id="geo-error"></span>
You can’t perform that action at this time.