This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.Scanner; | |
class HashingTable{ | |
static String userchoice; | |
static int capacity; | |
static int array[]; | |
//constructor function called | |
public HashingTable(int capacity){ | |
this.capacity = nextPrime(capacity); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
public class SelectionSort{ | |
static int i; | |
static int temp,element; | |
//selection sorting done here | |
public static void SelectionSort(int[] arr,int n){ | |
//while condtion to check the loop and increment | |
int smallest = arr[0]; | |
int init = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//brute force algorithm | |
//string matching | |
import java.io.*; | |
import java.util.Scanner; | |
class Bruteforce{ | |
//called function | |
public static int bruteforce(String text,String tobematched){ | |
int length = text.length();//length of the text | |
int plength = tobematched.length();//length of the pattern; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//spiral matrix method is used | |
import java.io.*; | |
import java.util.Scanner; | |
public class BrainTeaser{ | |
static int[] array = new int[200]; | |
static int userchoice; | |
//brainFunction called here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node: | |
#creation of node | |
def __init__(self,data): | |
self.data = data #assign data | |
self.next = None #initialize null | |
class LinkedList: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import defaultdict | |
class Graph(): | |
#initial declaration | |
def __init__(self): | |
self.graph = defaultdict(list) | |
#add edge between two vertices | |
def addedge(self,src,dist): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Sentence segmentation, means, to split a given paragraph of text into sentences, by identifying the sentence boundaries. | |
In many cases, a full stop is all that is required to identify the end of a sentence, but the task is not all that simple. | |
This is an open ended challenge to which there are no perfect solutions. Try to break up given paragraphs into text into | |
individual sentences. Even if you don't manage to segment the text perfectly, the more sentences you identify and display | |
correctly, the more you will score.""" | |
import nltk | |
from nltk.corpus import stopwords | |
from nltk.tokenize import word_tokenize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#train model to count number of 1's present in the string | |
import numpy as np | |
from random import shuffle | |
#import necessary libarary | |
import tensorflow as tf | |
training_data = ['{0:020b}'.format(i) for i in range(2**20)] | |
shuffle(training_data) | |
train_input = [map(int,i) for i in training_data] | |
ti = [] #list to store each tensor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gym | |
import numpy as np | |
env = gym.make("Pong-v0") | |
observation = env.reset() | |
#hyperparameters | |
episode_number = 0 | |
batch_size=10 #how many episodes to wait before moving the weights | |
gamma = 0.99 #discount factor for reward |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import numpy as np | |
class Game: | |
def __init__(self): | |
self.reset() | |
def reset(self): | |
self.current_number = random.randrange(1,12) |
OlderNewer