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
# Definition for a binary tree node. | |
# class TreeNode: | |
# def __init__(self, x): | |
# self.val = x | |
# self.left = None | |
# self.right = None | |
class BSTIterator: | |
def __init__(self, root: TreeNode): |
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
$PROMPT='{env_name:{} }{BOLD_GREEN}{user}@{hostname}{BOLD_BLUE} {cwd}{branch_color}{curr_branch: {}}{NO_COLOR} {BOLD_BLUE}\n{prompt_end}{NO_COLOR} ' |
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.awt.image.BufferedImage; | |
import java.awt.image.DataBufferByte; | |
import java.io.File; | |
import java.io.IOException; | |
import javax.imageio.ImageIO; | |
public class NergativeImage { | |
public static BufferedImage saveImageFromPixels(int[][][] pixels, String name, String format, int width, int height, int type) { | |
BufferedImage temp = new BufferedImage(width, height, type); |
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 task90(M, N, A, B, cords): | |
massive = [["*" if any((cord[0]==x and cord[1]==y) | |
or (x in range(cord[0]-A+1, cord[0]+1) and y in range(cord[1]-B+1, cord[1]+1)) | |
or (x in range(M-A+1, M+1)) | |
or (y in range(N-B+1, N+1)) | |
for cord in cords) else "_" for x in range(M)] for y in range(N)] | |
# print(*massive, sep = "\n") # Uncomment this for visualization | |
res = 0 | |
for row in massive: | |
for elem in row: |
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
function task87(N){ | |
let mem = []; | |
let sum = 0; | |
for (j = 0; j < N; j++ ){ | |
sum += 1; | |
if (j>1){ | |
sum+=mem[j-2]; | |
} | |
mem.push(sum); | |
} |
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
function calculations(a, b){ | |
if (a >= b*3) { // When a is so big, that a/3 don't fit into b, so we get one row of squares with width b | |
return b; | |
/* | |
* ###. | |
*/ | |
}else if (a < b*3 && a > b*3/2) { // This is when a/3 is smaller than b, so it fit's into the b, but is bigger than b/2, so we still get one row with width a/3 | |
return a/3; | |
/* | |
* ### |
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
function task85(k){ | |
console.log((-1+Math.sqrt(1+8*k))/2) | |
z = Math.ceil((-1+Math.sqrt(1+8*k))/2); | |
if (k%2==0){ | |
while (z%4!=3 && z%4!=0){ | |
z++; | |
} | |
}else{ | |
while (z%4!=1 && z%4!=2){ | |
z++; |
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
function get_factorial(num){ | |
res = 1; | |
for (i = 1; i <= num; i++){ | |
res *= i; | |
} | |
return res; | |
} | |
function task84 (word){ | |
res = get_factorial(word.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
import math | |
def task81(n): | |
d = {} | |
last_prime = 2 | |
if n == 2: | |
d = {2 : 1} | |
else: | |
while n > 1: | |
if n%last_prime == 0 and d.get(last_prime) == None: |
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 get_rel(arr, i, i1 = -1): | |
if i!=0 or i1!=-1: | |
if i1==-1: | |
i1 = i-1 | |
if arr[i]>arr[i1]: | |
return +1 | |
elif arr[i]<=arr[i1]: | |
return -1 | |
else: | |
return 0 |