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
# -*- coding: UTF-8 -*- | |
#=============================================================================== | |
# IMPORTS | |
#=============================================================================== | |
import os | |
import json | |
import datetime | |
import string | |
import socket |
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
__youtube-dl() | |
{ | |
local cur prev opts | |
COMPREPLY=() | |
cur="${COMP_WORDS[COMP_CWORD]}" | |
opts="-h --help --version -U --update -i --ignore-errors -r --rate-limit -R --retries --dump-user-agent --list-extractors --playlist-start --playlist-end --match-title --reject-title --max-downloads -t --title -l --literal -A --auto-number -o --output -a --batch-file -w --no-overwrites -c --continue --no-continue --cookies --no-part --no-mtime --write-description --write-info-json -q --quiet -s --simulate --skip-download -g --get-url -e --get-title --get-thumbnail --get-description --get-filename --get-format --no-progress --console-title -v --verbose -f --format --all-formats --prefer-free-formats --max-quality -F --list-formats --write-srt --srt-lang -u --username -p --password -n --netrc --extract-audio --audio-format --audio-quality -k --keep-video" | |
if [[ ${cur} == * ]] ; then | |
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) | |
return 0 |
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
/* | |
* Main.java | |
* java program model for www.programming-challenges.com | |
*/ | |
import java.io.*; | |
import java.util.*; | |
class minesweeper implements Runnable{ |
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
/* | |
* Main.java | |
* java program model for www.programming-challenges.com | |
*/ | |
import java.io.*; | |
import java.util.*; | |
class Main implements Runnable{ |
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
/* | |
* Main.java | |
* java program model for www.programming-challenges.com | |
*/ | |
import java.io.*; | |
import java.util.*; | |
class hailstorm implements Runnable{ |
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
class Heap | |
def initialize arr, type=:min | |
@heap = arr | |
self.class.class_eval { alias_method "get#{type.to_s}", :getroot } | |
if type == :min | |
@op = :< | |
else | |
@op = :> | |
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
require 'set' | |
def twosum arr,sum_arr | |
a = Set.new(arr) | |
sum_arr.each do |sum| | |
count = 0 | |
arr.each do |elem| | |
puts("#{sum} = #{elem} + #{sum-elem}") if a.include? (sum-elem) | |
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
def search_arr arr,val | |
darr = arr+arr | |
sz = arr.size | |
start_loc = 0 | |
end_loc = sz - 1 | |
mid_loc = (end_loc - start_loc)/2 | |
while start_loc < end_loc |
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 nthsmallest arr,startpos,endpos,nth | |
def choose_pivot arr,startpos,endpos | |
#THis is for selecting median of three , you can return a random number as well. | |
if ((arr[startpos] < arr[endpos]) and (arr[startpos] > arr[startpos+ (endpos-startpos)/2])) or ((arr[startpos] > arr[endpos]) and (arr[startpos] < arr[startpos+ (endpos-startpos)/2])) | |
return startpos | |
elsif ((arr[endpos] < arr[startpos]) and (arr[endpos] > arr[startpos+ (endpos-startpos)/2])) or ((arr[endpos] > arr[startpos]) and (arr[endpos] < arr[startpos+ (endpos-startpos)/2])) | |
return endpos |
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 second_smallest arr | |
min_arr = [] | |
arr.each_slice(2) do |x,y| | |
if y.nil? or x < y | |
min_arr << x | |
else | |
min_arr << y | |
end |
NewerOlder