This file contains 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
const expression1 = '5+16-((9-6)-(4-2))+1'; | |
const expression2 = '22+(2-4)'; | |
const expression3 = '6+9-12'; | |
const expression4 = '((1024))'; | |
const expression5 = '1+(2+3)-(4-5)+6'; | |
const expression6 = '255'; | |
const operations1 = [['5', '+', '16', '-'], [['9', '-', '6'], '-', ['4', '-', '2']], ['+', '1']]; | |
const operations2 = [['22', '+'], ['2', '-', '4']]; | |
const operations3 = [['6', '+', '9', '-', '12']]; |
This file contains 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
const expression1 = '6+9-12'; | |
const expression2 = '1+2-3+4-5+6-7'; | |
const expression3 = '100+200+300'; | |
const expression4 = '1-2-3-0'; | |
const expression5 = '255'; | |
const expression6 = '0-1-2-3'; | |
function calculate(input) { | |
return reduceOperations(buildOperations(input)); | |
} |
This file contains 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
// go run mine.go | |
// RESOURCES: | |
// http://www.righto.com/2014/02/bitcoin-mining-hard-way-algorithms.html | |
// https://en.bitcoin.it/wiki/Block_hashing_algorithm | |
// https://gist.github.com/Gerst20051/30d76e657fe8767fb5b57fb814d97341 | |
// `mining.notify` stratum message | |
// https://en.bitcoin.it/wiki/Stratum_mining_protocol | |
// https://github.com/aeternity/protocol/blob/master/STRATUM.md#mining-notify | |
// https://github.com/MintPond/mtp-stratum-mining-protocol/blob/master/04_MINING.NOTIFY.md |
This file contains 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 hashlib, struct, codecs | |
ver = 2 | |
prev_block = "000000000000000117c80378b8da0e33559b5997f2ad55e2f7d18ec1975b9717" | |
mrkl_root = "871714dcbae6c8193a2bb9b2a69fe1c0440399f38d94b3a0f1b447275a29978a" | |
time_ = 0x53058b35 # 2014-02-20 04:57:25 | |
bits = 0x19015f53 | |
# https://en.bitcoin.it/wiki/Difficulty | |
exp = bits >> 24 |
This file contains 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 hashlib, struct | |
ver = 2 | |
prev_block = "000000000000000117c80378b8da0e33559b5997f2ad55e2f7d18ec1975b9717" | |
mrkl_root = "871714dcbae6c8193a2bb9b2a69fe1c0440399f38d94b3a0f1b447275a29978a" | |
time_ = 0x53058b35 # 2014-02-20 04:57:25 | |
bits = 0x19015f53 | |
# https://en.bitcoin.it/wiki/Difficulty | |
exp = bits >> 24 |
This file contains 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 python3 | |
import random | |
import unittest | |
def generate_template(group_id, template_data): | |
""" | |
Randomly generates a string based on the given group_id & template_data | |
:param group_id: int - ID for one of the groups in template_data | |
:param template_data: list - List of templates (see example in description) |
This file contains 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 python3 | |
import unittest | |
def sort_binaries(arr): | |
j, l = -1, len(arr) | |
for i in range(l): | |
if arr[i] == 0: | |
j += 1 | |
arr[i], arr[j] = arr[j], arr[i] |
This file contains 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
/* | |
Given a random subset of a standard deck of cards, return the length of the longest straight flush. | |
A standard deck of cards contains a total of 52 cards with 4 suits (Spades, Hearts, Clubs, Diamonds) and 13 cards for each suit (Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King). | |
A straight flush is a set of cards that have the same suit and are in sequential order. The minimum hand size for this problem is 1. | |
*/ | |
const testCards1 = [ | |
{ suit: 'Hearts', rank: '3' }, | |
{ suit: 'Clubs', rank: '10' }, | |
{ suit: 'Spades', rank: 'Ace' }, |
This file contains 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
#!/bin/python3 | |
# | |
# Complete the 'addStrings' function below. | |
# | |
# The function is expected to return a STRING. | |
# The function accepts following parameters: | |
# 1. STRING string1 | |
# 2. STRING string2 | |
# |
This file contains 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
const CustomPromise = { | |
all: function (promises) { | |
return new Promise((resolve, reject) => { | |
const resolved = []; | |
promises.forEach((promise, index) => { | |
Promise.resolve(promise).then(result => { | |
resolved[index] = result; | |
if (resolved.length === promises.length) { | |
resolve(resolved); | |
} |