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
## ConcreteComponent | |
class SimpleWriter | |
def initialize(path) | |
@file = File.open(path, 'w') | |
end | |
def write_line(line) | |
@file.print(line) | |
@file.print('\n') |
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
var add = (function () { | |
let counter = 0; | |
return function() { | |
return counter += 1; | |
}; | |
})(); | |
console.log(add()); | |
console.log(add()); |
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
## Divide and Conquer Method | |
def partition(a, begining, ending) | |
pivot, pIndex = a[ending], begining | |
i = begining | |
while(i < ending) do | |
if a[i] <= pivot | |
## Swap a[i] and a[pIndex] with each other | |
a[i], a[pIndex] = a[pIndex], a[i] |
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
function merge(left, right, a) { | |
let i = 0; | |
let j = 0; | |
let k = 0; | |
while(i < left.length && j < right.length) { | |
if(left[i] <= right[j]) { | |
a[k] = left[i]; | |
i++; | |
} else { |
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(left, right, a) | |
i, j, k = 0, 0, 0 | |
while(i < left.length && j < right.length) do | |
if left[i] <= right[j] | |
a[k] = left[i] | |
i += 1 | |
else | |
a[k] = right[j] | |
j += 1 |
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 -*- | |
=begin | |
You are given an empty stack. Your task is to perform following three operations: | |
push a: Push an integer a, to the top of the stack | |
pop: Pop the top element from the stack. It is guaranteed that stack is not empty, when performing the pop operation. | |
inc x d: Add d to bottom x elements of the stack. | |
After each operation, print the top element of the stack, if after an operation, the stack becomes empty, then print EMPTY. | |
Input Format: | |
The first line of the input is n, total number of operations performed on the stack. |
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
/* | |
You are given an empty stack. Your task is to perform following three operations: | |
push a: Push an integer a, to the top of the stack | |
pop: Pop the top element from the stack. It is guaranteed that stack is not empty, when performing the pop operation. | |
inc x d: Add d to bottom x elements of the stack. | |
After each operation, print the top element of the stack, if after an operation, the stack becomes empty, then print EMPTY. | |
Input Format: | |
The first line of the input is n, total number of operations performed on the stack. | |
Each of the next n lines is one of the three operations listed above. |
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
public class Solution4 { | |
static int solve(String str) { | |
String programmer = "programmer"; | |
String head = programmer; | |
int i = 0; | |
// programmer | |
for (; i < str.length(); i++) { |
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 String | |
def maulin! n | |
slice! n | |
self | |
end | |
def maulin n | |
dup.maulin! n | |
end | |
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 'rest-client' | |
require 'json' | |
require 'byebug' | |
def upload | |
options = { | |
# Slack channel webhook integration token | |
token: '123456789-xxxaaaddffggbbb', | |
file: File.new("error_hotels.csv", 'rb'), | |
filename: "error_hotels.csv", |