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 math | |
# Question: | |
# Steve has a carrot farm and a camel. He wants to transport 300 carrots to the market, | |
# which is located 100 miles away. The camel will carry the carrots. The camel can carry | |
# a maximum of 100 carrots at a time, and it needs to eat one carrot for every mile it | |
# travels. What is the maximum number of carrots can the camel deliver to the market? | |
# Answer: | |
# We essentially want to move all the carrots we can carry to midpoints until we reach |
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
""" | |
Original Author Ernesto P. Adorio, Ph.D | |
Original Source: http://my-other-life-as-programmer.blogspot.com/2012/02/python-finding-nearest-matching-color.html | |
Modifed By: JDiscar | |
This class maps an RGB value to the nearest color name it can find. Code is modified to include | |
ImageMagick names and WebColor names. | |
1. Modify the minimization criterion to use least sum of squares of the differences. | |
2. Provide error checking for input R, G, B values to be within the interval [0, 255]. |
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 os | |
import pyHook | |
import pythoncom | |
import threading | |
# Requires pyHook: http://sourceforge.net/apps/mediawiki/pyhook/ | |
# Requires pyWin32: http://sourceforge.net/projects/pywin32/ | |
# Kills the process if escape is pressed | |
class EscapeToKill(threading.Thread): |
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
/* | |
* This class simulates the functionality | |
* of the order() function in R for an | |
* array of doubles. | |
* | |
* It takes in a double array and sorts it, from lowest | |
* value to the highest value. Then it returns an int[] array | |
* of the indices from the unsorted array that match | |
* the values of the sorted array. | |
* |