This file contains hidden or 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
| #!/usr/local/bin/perl | |
| use strict; | |
| use warnings; | |
| print "Enter file name :: "; | |
| my $infile = <STDIN>; | |
| open(INP,"<$infile") or die "can not open file for reading"; |
This file contains hidden or 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
| def is_prime(n) | |
| return false if n <= 1 | |
| 2.upto(Math.sqrt(n).to_i) do |x| | |
| return false if n%x == 0 | |
| end | |
| true | |
| end |
This file contains hidden or 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
| Math.sqrt(600851475143).to_i.downto(2) do |n| | |
| if is_prime(n) && 600851475143%n ==0 | |
| puts "Maximum prime factor for this number is #{n}" | |
| break | |
| end |
This file contains hidden or 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
| package browserstack; | |
| public class SeriesCompute { | |
| /** | |
| * My program assumes you always pass valid alphabets. | |
| * For Non alphabet strings, program may behave wierd as no error handle is done for them | |
| * @param args | |
| */ | |
| public static void main(String[] args) { | |
| SeriesCompute computer = new SeriesCompute(); |
This file contains hidden or 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
| require 'anemone' | |
| puts "Enter the value of N" | |
| n = gets.chomp.to_i | |
| patterns = [] | |
| 1.upto(n) {|i| patterns << /chttp_tt_#{i}$/ } | |
| cast = movies = {} | |
| puts "Please wait crawling in progress" | |
| Anemone.crawl('http://www.imdb.com/chart/top', :depth_limit=>1) do |anemone| |
This file contains hidden or 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.*; | |
| public class NovelFinder { | |
| public static void main(String[] args) throws Exception { | |
| File inputFile = new File("novel.in"); | |
| Scanner scanner = new Scanner(inputFile); | |
| BufferedWriter out = new BufferedWriter(new FileWriter("novel.out")); | |
| NovelFinder finder = new NovelFinder(); | |
| while (scanner.hasNextLine()) |
This file contains hidden or 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
| package dsa.btree; | |
| import java.awt.Dimension; | |
| import java.awt.FontMetrics; | |
| import java.awt.Graphics; | |
| import java.awt.Graphics2D; | |
| import java.awt.Rectangle; | |
| import java.util.HashMap; | |
| import javax.swing.JPanel; |
This file contains hidden or 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
| package dsa.btree; | |
| /** | |
| * A class representing one node of the tree. | |
| */ | |
| public class Node { | |
| private String content = null; | |
| private Node left = null; | |
| private Node right = null; | |
This file contains hidden or 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
| package dsa.btree; | |
| import javax.swing.JFrame; | |
| public class PreOrderInOrderReconstructor { | |
| public static void main(String[] args) { | |
| PreOrderInOrderReconstructor pir = new PreOrderInOrderReconstructor(); | |
| String[] preOrderSequence = { "A", "B", "D", "E", "C", "F", "G", "H", "I" }; | |
| String[] inOrderSequence = { "D", "B", "E", "A", "F", "C", "H", "G", "I" }; | |
| Node root = pir.reConstruct(preOrderSequence, 0, |