Skip to content

Instantly share code, notes, and snippets.

View anoopdixith's full-sized avatar

Anoop Dixith anoopdixith

View GitHub Profile
package com.c3po.own;
public class Puzzle17 {
public static void main(String args[]) {
Puzzle17 puz = new Puzzle17();
int NUMBER_OF_PEOPLE = 1000;
int[] handshakes = new int[NUMBER_OF_PEOPLE+1];
for(int i=1; i <= NUMBER_OF_PEOPLE; i++) {
handshakes[i] = puz.numberOfHandshakes(i);
}
@anoopdixith
anoopdixith / brexrainbowgan.py
Last active July 4, 2020 20:10
GAN that tries to create a rainbow. (For Brex's Rainbow campaign: https://www.facebook.com/BrexHQ/posts/932319587222145)
# -*- coding: utf-8 -*-
"""BrexRainbowGAN.ipynb
Author: Anoop Dixith
For Brex Rainbow initiative: https://www.facebook.com/BrexHQ/posts/932319587222145
"""
import tensorflow as tf
import glob
@anoopdixith
anoopdixith / dangerous_cities.py
Created November 29, 2016 16:06
Code that gets warnings about traveling to different destinations.
import urllib2, re
from BeautifulSoup import BeautifulSoup
def find_warnings(*urls):
for url in urls:
soup = BeautifulSoup(urllib2.urlopen(url).read())
for a in soup.findAll('a', href=True):
if(a['href'].startswith("/en/") and ":" not in a['href']):
city_soup = BeautifulSoup(urllib2.urlopen("http://wikitravel.org" + str(a['href'])).read())
for elem in city_soup(text=re.compile(r'WARNING:|NOTE:')):
@anoopdixith
anoopdixith / PrintValuesInReverseOrder
Last active August 29, 2015 14:12
Print reversed values of a LinkedList without extra space.
package com.practice.algorithms;
import com.datastructures.buildingblocks.LinkedListNode;
public class ReverseListWithoutExtraSpace {
public <T> void printInReverseOrder(LinkedListNode<T> head, LinkedListNode<T> tail) {
LinkedListNode<T> next = null;
while(head != null) {
next = head.next;
head.next = tail;
@anoopdixith
anoopdixith / CheckCounting
Created January 2, 2015 08:35
For Loop Performance
package com.practice.algorithms;
public class CheckCounting {
public static void countUp(int n) {
for(int i=0; i <=n; i++);
}
public static void countDown(int n) {
for(int i=n; i >=0; i--);
}
@anoopdixith
anoopdixith / Digits.java
Created December 29, 2014 01:19
Number of digits representing each digit in a number. (Uses backtracking)
package com.practice.algorithms;
public class NumberOfDigits {
public static void main(String args[]) {
for(int i= 1; i <= 10; i++) {
new NumberOfDigits().getAllNumbers(i);
}
}
public void getAllNumbers(int limit) {
int[] output = new int[limit];