Skip to content

Instantly share code, notes, and snippets.

@empeje
empeje / README.md
Created December 17, 2017 05:58
[SNIPPET-02] Home Exercises Links
@empeje
empeje / README.md
Last active December 17, 2017 11:09
[SNIPPET-06] My Windows Configuration

Tools

Git for Windows

It can be downloaded here

Amix Vimrc

It can be downloaded here

@empeje
empeje / WihoutLoop.java
Last active December 17, 2017 11:10
[SNIPPET-09] Printing Number Without Loops Java
public class WihoutLoop{
public static void main(String []args){
reachfinal(0,100);
}
public static void reachfinal(int startpoint, int finalpoint){
if (startpoint != finalpoint){
System.out.println(startpoint);
reachfinal(startpoint+1, finalpoint);
@empeje
empeje / spiral_matrix.py
Last active December 17, 2017 11:11
[SNIPPET-12] Spiral Matrix in Python
def create_matrix(width, height):
result = []
for i in range(height):
result.append([0 for i in range(width)])
print (result)
# TOP BOTTOM LEFT RIGHT
T = 0
B = height - 1
@empeje
empeje / exercise1.jsx
Last active December 17, 2017 11:11
[SNIPPET-13] Samer Buna - ReactJs Getting Started
class Button extends React.Component {
// constructor (props) {
// super(props);
// this.state = { counter: 0 };
// }
state = { counter: 0 }
handleClick = () => {
// this.state.counter++
this.setState((prevState) => ({
@empeje
empeje / database_command.txt
Last active December 17, 2017 11:12
[SNIPPET-16] Ubuntu Linux Command for Most Dabases
sudo apt-get install redis-server
sudo /etc/init.d/redis-server restart
neo4j start
neo4j status
sudo apt-get install mongodb-server
sudo apt-get install mongodb-clients
killall mongod
cd ~
@empeje
empeje / codility_frogjump.py
Last active December 17, 2017 11:13
[SNIPPET-17] Codility - Frog Jump
def solution(X, Y, D):
# write your code in Python 2.7
gap = Y-X
if gap % D == 0:
return gap / D
else:
return gap / D + 1
@empeje
empeje / codility_cyclicrotation.py
Last active December 17, 2017 11:13
[SNIPPET-18] Codility - Cyclic Rotation
from collections import deque
# you can write to stdout for debugging purposes, e.g.
# print "this is a debug message"
def solution(A, K):
# write your code in Python 2.7
d=deque(A)
d.rotate(K)
return list(d)
@empeje
empeje / codility_binarygap.py
Last active December 17, 2017 11:13
[SNIPPET-19] Codility - Binary Gap
def solution(N):
# write your code in Python 2.7
bin_representation = "{0:b}".format(N)
bin_representation = 'x' + bin_representation
bin_representation = bin_representation + 'x'
start_index = [i for i in range(0, len(bin_representation)) if ((bin_representation[i] == '1') and (bin_representation[i+1]=='0'))]
end_index = [i for i in range(0, len(bin_representation)) if ((bin_representation[i] == '1') and (bin_representation[i-1]=='0'))]
print(start_index)
@empeje
empeje / hackerrank_breakingtherecords.py
Last active December 17, 2017 11:14
[SNIPPET-20] HackerRank - Breaking the Records
#!/bin/python3
import sys
n = int(input().strip())
scores = list(map(int, input().strip().split(' ')))
# your code goes here
# highest score
max = -float("inf")