Skip to content

Instantly share code, notes, and snippets.

View arieltraver's full-sized avatar

Ariel Traver arieltraver

View GitHub Profile
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.**/
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
[alias]
share = gist create --public --copy --browse
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