This file contains hidden or 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 kotlinx.coroutines.* | |
import java.util.Random | |
import kotlin.system.exitProcess | |
// We have a worker who makes machines every 800ms as long as there is less than 5 of them | |
// Every machine produces a code using `produce` function every second. It saves this code to shared space. In case of an error, it ends working. | |
// We have a single manager that once a 2 seconds takes all produced codes and prints them all. After 5 times it ends all jobs (including machines and worker). | |
class Message(val id: String, val txt: String, var new: Boolean = true) { | |
override fun toString(): String { |
This file contains hidden or 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 xs = []; | |
const ys = [] | |
let poly = null; | |
const opt = tf.train.adam(0.001) | |
const iter = 1 | |
function polynomial (i, o, n) { | |
this.i = i | |
this.o = o | |
this.n = n |
This file contains hidden or 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
ns = [1750, 1602, 3954, 4716] | |
ans = [(1, 1), (1, 1), (1, 1), (1, 1)] | |
def bc (a, b): | |
bs = 0 | |
cs = 0 | |
for i1, i2 in zip(a, b): | |
if i1 == i2: | |
bs += 1 | |
elif i1 in b: |
This file contains hidden or 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
phi = 1 | |
precision = 0.5 | |
while True: | |
n1 = phi + precision | |
n2 = phi - precision | |
diff1 = abs((n1 - 1 / n1) - 1) | |
diff2 = abs((n2 - 1 / n2) - 1) | |
if diff1 < diff2: | |
precision = diff1 | |
phi = n1 |
This file contains hidden or 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 itertools import permutations | |
from functools import reduce | |
import sys | |
si = "" | |
print("Rebus SolvR by Neverik. Copyright 2018.") | |
print("Enter text or 'exit' to escape.") | |
while True: | |
sinp = input("Enter: ") | |
for i in sinp: |
This file contains hidden or 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
#self-adjusting clock class | |
class Clock: | |
def __init__(self,h,m,s): | |
self.s = s | |
self.m = m + self.s/60 | |
self.h = h + self.m/60 | |
def angle_hm(self): | |
return abs(self.h - self.m) | |
def angle_ms(self): | |
return abs(self.m - self.s) |