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
''' | |
Example usage: | |
grid = [ | |
[7,0,0, 0,0,9, 0,0,0], | |
[0,0,0, 6,0,0, 0,4,0], | |
[0,0,2, 0,0,0, 0,0,0], | |
[0,0,0, 0,0,0, 4,0,0], | |
[0,5,0, 0,4,6, 0,0,0], | |
[0,0,0, 0,0,0, 0,0,0], |
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 unittest | |
# Create the node class | |
class Node(object): | |
def __init__(self, d, n=None): | |
self.data = d | |
self.next_node = n | |
def get_next(self): | |
return self.next_node |
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 greet = function() { | |
let greeting = "h"; | |
greeting += "e".repeat(2); | |
greeting = greeting.slice(0, 2); | |
greeting += "l".repeat(5 + Math.ceil(Math.random() * 10)); | |
while (greeting !== "hell") | |
greeting = greeting.slice(0, -1); | |
greeting += "o"; | |
for (let i = 0; i < 7; i++) | |
greeting += " ".repeat(100 + Math.floor(Math.random() * 10)); |
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
'''A number is colorful if all products of the subsets of individual digits are unique | |
e.g. 263 is colorful: | |
2 * 6 * 3 = 36 | |
2 * 6 = 12 | |
6 * 3 = 18 | |
''' | |
def is_colorful(num): | |
# Account for negatives (results will be the same) | |
num = abs(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
class FizzBuzz(object): | |
def __init__(self, n): | |
self.size = n | |
# Define a dictionary containing the fizz buzzes | |
self.d = {3: "Fizz", | |
5: "Buzz"} | |
def get_fizzbuzz_sequence(self): | |
ls = [] | |
for i in range(1, self.size + 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
const greet = function() { | |
let greeting = ""; | |
while (greeting !== "hello world!") { | |
greeting = "h".repeat(Math.ceil(Math.random() * 5)); | |
greeting += "e".repeat(Math.ceil(Math.random() * 5)); | |
greeting += "l".repeat(Math.ceil(Math.random() * 5)); | |
greeting += "o".repeat(Math.ceil(Math.random() * 5)); | |
greeting += " ".repeat(Math.ceil(Math.random() * 5)); | |
greeting += "w".repeat(Math.ceil(Math.random() * 5)); | |
greeting += "o".repeat(Math.ceil(Math.random() * 5)); |