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
public static void printBucksFizzOrNumber() | |
{ | |
for (int number = 1; number <= 100; number++) | |
{ | |
boolean hasThreeOrFiveAsMultiple = false; | |
// If number is a multiple of 3, print "Bucks" and set flag | |
if (number % 3 == 0) | |
{ | |
hasThreeOrFiveAsMultiple = true; |
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
from random import shuffle | |
class Hand: | |
def __init__(self): | |
self.cards = [] | |
self.possible_values = [0] | |
self.blackjacks = 0 | |
def can_add(self, card): | |
if (min(self.possible_values) + min(card)) <= 21: |
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 java.util.ArrayList; | |
public class Main | |
{ | |
public static ArrayList<Integer> mergeSort(ArrayList<Integer> ar) | |
{ | |
if (ar.size() <= 1) return ar; | |
ArrayList<Integer> left, right; | |
left = new ArrayList<Integer>(); |
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
public class Main | |
{ | |
public int maxSubArray(final List<Integer> a) | |
{ | |
int ans = a.get(0); | |
int sum = a.get(0); | |
for (int i = 1; i < a.size(); i++) | |
{ | |
if (sum + a.get(i) > a.get(i)) sum += a.get(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
# for workplaces that have planted ergosuite s/w in the computers... | |
# get ergonomics s/w processes | |
$smergo = get-process smergo -erroraction silentlycontinue | |
$ergosuite = get-process ergosuite -erroraction silentlycontinue | |
if ($smergo) { | |
$smergo | stop-process -force | |
} |
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
# Ballpark numbers of continuously lending | |
# out a given amount of BTC on Poloniex | |
########################################################## | |
# FILL THESE IN | |
start_btc = 150.0 # BTC - amount you're starting with | |
term = 2 # days - all loans will be for 2 day terms | |
daily_interest = 0.0025 # % expressed as 1.0 being 100% | |
run_days = 364 # how many days to run this for |
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
// Node.js HelloWorld | |
// Add the HTTP module - https://nodejs.org/api/http.html | |
var http = require('http'); | |
// Create a server | |
// It always expects to work with a request and response | |
var myServer = http.createServer(function(request, response) { | |
response.writeHead(200, {"Content-Type" : "text/plain"}); | |
response.end('Hello world'); |
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
# Basic merge sort | |
def merge_sort(list) | |
# Return the original array if its size is 1 or less. | |
return list if list.length <= 1 | |
# Split the array in half. | |
mid = list.length / 2 | |
left = list[0..mid - 1] | |
right = list[mid..-1] |
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
# Fibonacci sequence with and without recursion | |
def fibs(num) # Not recursive | |
return num if num <= 1 | |
fib = 1 | |
fib_prev = 1 | |
count = 2 | |
while count < num |
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
# Simple bubble sort for numbers | |
def bubble_sort(array_to_sort) | |
swap = true # Track whether swap has occurred | |
while swap | |
(0... array_to_sort.length - 1).each do |x| | |
# If we detect disorder... | |
if array_to_sort[x] > array_to_sort[x + 1] | |
# Perform a simple 3-step swap |