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 merge_arrays(a, b, c): | |
index = 0 | |
b_index = 0 | |
b_len = len(b) | |
d = [] | |
for i in a: | |
d.append(i) | |
index += 1 | |
if index == c: |
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 challenge; | |
import java.util.HashMap; | |
/** | |
* You have 10,000/= bob, and you need to buy exactly 100 animals: | |
* - cows @1000/- | |
* - pigs @200/- | |
* - chicken @50/- |
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 challenge; | |
/** | |
* You have 10,000/= bob, and you need to buy exactly 100 animals: | |
* - cows @1000/- | |
* - pigs @200/- | |
* - chicken @50/- | |
* | |
* 1. You must have at least one of each animal | |
* 2. You must use up all Ksh. 10K |
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
""" | |
There are N countries {1,2,3,4....N} and N-1 roads(i.e depicting a tree) | |
Bishu lives in the Country 1 so this can be considered as the root of the tree. | |
Now there are Q girls who live in various countries (not equal to 1) . | |
All of them want to propose Bishu. But Bishu has some condition. | |
He will accept the proposal of the girl who lives at minimum distance from his country. |
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
DFS-iterative (G, s): //Where G is graph and s is source vertex | |
let S be stack | |
S.push( s ) //Inserting s in stack | |
mark s as visited. | |
while ( S is not empty): | |
//Pop a vertex from stack to visit next | |
v = S.top( ) | |
S.pop( ) | |
//Push all the neighbours of v in stack that are not visited | |
for all neighbours w of v in Graph G: |
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
BFS (G, s) //Where G is the graph and s is the source node | |
let Q be queue. | |
Q.enqueue( s ) //Inserting s in queue until all its neighbour vertices are marked. | |
mark s as traversed. | |
while ( Q is not empty) | |
//Removing that vertex from queue,whose neighbour will be visited now | |
v = Q.dequeue( ) | |
//processing all the neighbours of v |
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/bin/env bash | |
mkdir directory1 directory2 directory3 #create multiple directories | |
pwd #show the current directory | |
ls # list contents of a directory | |
cd directory1 # move to a particular directory | |
touch script.py # create a file | |
cp script.py ../directory2 # copy contents a file to another directory | |
echo "foo" | xargs touch #command with pipes |
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/bin/env ruby | |
message_file = ARGV[0] | |
message = File.read(message_file) | |
$regex = /\((\w+)\):/ | |
if !$regex.match(message) | |
puts "[POLICY] Your message is not formatted correctly" | |
puts "[STANDARD] Your message should be in the format: ‘feat(module): commit message’ " | |
exit 1 | |
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
$ mv pre-rebase.sample pre-rebase #renaming sample to pre-rebase. | |
#!/bin/sh | |
publish=next | |
basebranch="$1" | |
if test "$#" = 2 | |
then | |
topic="refs/heads/$2" | |
else | |
topic=`git symbolic-ref HEAD` || | |
exit 0 ;# we do not interrupt rebasing detached HEAD |
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
alias pythonfiles='find . -type f -name "*.py" | xargs git diff --cached --name-only $against' | |
if [ -n "$(pythonfiles)" ]; then | |
if pythonfiles | xargs grep --color --with-filename -n "import pdb"; then | |
echo "Error commiting changes: Please remove pdb and its usage" | |
exit 1 | |
fi | |
if pythonfiles | xargs grep --color --with-filename -n "pdb.set_trace()"; then | |
echo "Error commiting changes: Please remove pdb and its usage" | |
exit 1 | |
fi |
NewerOlder