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 | |
def find_swaps(num, n): | |
""" | |
Returns the switches made to the first lexicographic permutation, in order to get the desired permutation. | |
Param: | |
num(list): a list of all the numbers, in the very first order, such as [1, 2, 3, 4] | |
n(integer): the lexicographic permutation you're looking for. """ | |
n -= 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
[alias] | |
share = gist create --public --copy --browse |
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
def is_binary_palindrome(num): | |
number_string = str(num) | |
number_string = number_string[2:len(number_string)] | |
return number_string == number_string[len(number_string) - 1::-1] | |
print(is_binary_palindrome(0b101)) | |
#just testing it out | |
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.*; | |
/** | |
* @author Ariel Traver | |
* @version 1.0 | |
* Hello and welcome! | |
* Here Dijkstra's is implemented as an object. | |
* To run the algorithm, simply initialize an object with your input graph and desired source node. | |
* Then, use "printShortestPath" or "printDistance" on any destination. | |
* This algorithm assumes a fully connected graph.**/ |