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 kotlin.random.Random | |
class Node(var value: Int) { | |
var left: Node? = null | |
var right: Node? = null | |
} | |
class BinaryTree { | |
var root: Node? = null |
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 Node: | |
def __init__(self, name): | |
self.adjacent_nodes = [] | |
self.name = name | |
self.traversed = 0 | |
def add_adjacent_node(self, adjacent_node): | |
self.adjacent_nodes.append(adjacent_node) | |
def is_small_cave(self): |
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 Node: | |
def __init__(self, name): | |
self.adjacent_nodes = [] | |
self.name = name | |
self.traversed = 0 | |
def add_adjacent_node(self, adjacent_node): | |
self.adjacent_nodes.append(adjacent_node) | |
def is_small_cave(self): |
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 within_bounds(_y, _x, matrix): | |
return 0 <= _y < len(matrix) and 0 <= _x < len(matrix[0]) | |
def adjacent_cells(y, x, matrix): | |
for _y in range(y - 1, y + 2): | |
for _x in range(x - 1, x + 2): | |
if within_bounds(_y, _x, matrix): | |
yield _y, _x |
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 functools import reduce | |
def calc_basin_size(y, x, matrix, fill_matrix, size): | |
fill_matrix[y][x] = 1 | |
up_size = 0 | |
dn_size = 0 | |
lf_size = 0 | |
rt_size = 0 | |
if y > 0 and fill_matrix[y - 1][x] == 0 and matrix[y-1][x] != 9: |
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 contains_all(str, set): | |
return 0 not in [c in str for c in set] | |
def find_digits(input_parts): | |
digits = [""] * 10 | |
cands960 = set() | |
cands532 = set() | |
for input_part in input_parts: | |
if len(input_part) == 2: |
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
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
<d:devices xmlns:d="http://schemas.android.com/sdk/devices/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |
<d:device> | |
<d:name>HUAWEI Mate 20 X</d:name> | |
<d:manufacturer>HUAWEI</d:manufacturer> | |
<d:meta/> | |
<d:hardware> | |
<d:screen> | |
<d:screen-size>large</d:screen-size> | |
<d:diagonal-length>7.20</d:diagonal-length> |
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
@Test | |
void shouldCompressAndDecompress() throws IOException { | |
whenCompressingData(); | |
thenDataIsCompressed(); | |
thenCompressedDataShouldBeCorrectlyDecompressed(); | |
thenTheCompressionRatioIsPrintedOut(); | |
} | |
private void thenTheCompressionRatioIsPrintedOut() { | |
long inputSize = TEST_DATA.getBytes().length; |
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
package tdd.huffman; | |
import org.junit.jupiter.api.Test; | |
import java.io.ByteArrayInputStream; | |
import java.io.ByteArrayOutputStream; | |
import java.io.IOException; | |
import static org.assertj.core.api.Assertions.assertThat; |
NewerOlder