def anna():
import random
upper_or_lower = random.randint(0, 1)
if upper_or_lower >= 1:
return 'h'.upper()
else:
return 'h'.lower()
def andrej():
k = 1
s = 0
for i in range(10000000):
if i % 2 == 0:
s += 4/k
else:
s -= 4/k
k += 2
pi = s
return list('andrej')[int(pi * 0)]
def daniel():
"""
Nothing in this world happens without a gcc
"""
import subprocess
with open('magic.c', 'w') as f:
f.write('#include <stdio.h>\nint main() { printf("pp"); return 0;}')
subprocess.run(['gcc', 'magic.c'])
p = subprocess.run(['/work/a.out'], capture_output=True)
return str(p.stdout, encoding='utf8')
best_letter
def elizabeth():
return best_letter
import random
def filip():
length = random.randint(1,10)
spaces = [' ' for x in range(length)]
return ''.join(spaces)
def jakubz():
import numpy as np
from tensorflow import keras
from tensorflow.keras import layers
num_classes = 10
input_shape = (28, 28, 1)
(x_train, y_train), (x_test, y_test) = keras.datasets.mnist.load_data()
x_train = x_train.astype("float32") / 255
x_test = x_test.astype("float32") / 255
x_train = np.expand_dims(x_train, -1)
x_test = np.expand_dims(x_test, -1)
y_train = keras.utils.to_categorical(y_train, num_classes)
y_test = keras.utils.to_categorical(y_test, num_classes)
model = keras.Sequential(
[
keras.Input(shape=input_shape),
layers.Conv2D(32, kernel_size=(3, 3), activation="relu"),
layers.MaxPooling2D(pool_size=(2, 2)),
layers.Conv2D(64, kernel_size=(3, 3), activation="relu"),
layers.MaxPooling2D(pool_size=(2, 2)),
layers.Flatten(),
layers.Dropout(0.5),
layers.Dense(num_classes, activation="softmax"),
]
)
batch_size = 128
epochs = 3
#model.compile(loss="categorical_crossentropy", optimizer="adam", metrics=["accuracy"])
#model.fit(x_train, y_train, batch_size=batch_size, epochs=epochs, validation_split=0.1)
num = 10
images = x_test[:num]
index = 2 # np.argmax(model.predict(images)[1]) damn the slow
return ['a', 'b', 'c', 'd'][index - 1]
def jakubj():
'''Generate a unique letter but also make sure it passes the tests'''
import string
import random
letters = string.ascii_lowercase
selected_letter = None
while (selected_letter != 'i'):
selected_letter = random.choice(letters)
return selected_letter
def honza():
"""
Return 'r' in the most efficient way
"""
import requests
teapot_rfc_url = "https://tools.ietf.org/rfc/rfc2324.txt"
res = requests.get(teapot_rfc_url)
return res.text[11]
def jirka(bday_boy, new_age):
"""
Calculate bday boy's letter
TODO: Make it work for bday girls
"""
name_average = sum([ord(x) for x in bday_boy])/len(bday_boy)
age_index = new_age/len(bday_boy)
magic_number = name_average + age_index
return chr(int(magic_number))
def ondrej():
return 'h'
def patrik():
return type({}).__name__[0]
def petr():
return 'a'
def robo():
return [x for x in 'y'''][0]
def itto():
from lxml import html
import requests
page = requests.get('https://en.wikipedia.org/wiki/Comma')
tree = html.fromstring(page.content)
for item in tree.xpath('//*[@id="mw-content-text"]/div[1]/table[1]/tbody/tr[1]/th'):
return (item.text)
def jano():
MEANING_OF_LIFE = 42
CONSTANT_TO_MAKE_THIS_WORK = 10
return chr(MEANING_OF_LIFE ^ CONSTANT_TO_MAKE_THIS_WORK)
''.join([anna(), andrej(), daniel(), elizabeth(), filip(), jakubz(), jakubj(), honza(), jirka('simon', 32), ondrej(), patrik(), petr(), robo(), itto(), jano(), 'Simon!'])
from IPython.core.display import display, HTML
display(HTML('\
<script>\
var Synth = window.Synth; \
var BPM = 120; \
var QUARTER_NOTE = 60 / BPM; \
var HALF_NOTE = QUARTER_NOTE * 2; \
var EIGHTH_NOTE = QUARTER_NOTE / 2; \
var notes = [ \
["G", 3, EIGHTH_NOTE], \
["G", 3, EIGHTH_NOTE], \
["A", 3, QUARTER_NOTE], \
["G", 3, QUARTER_NOTE], \
["C", 4, QUARTER_NOTE], \
["B", 3, HALF_NOTE], \
["G", 3, EIGHTH_NOTE], \
["G", 3, EIGHTH_NOTE], \
["A", 3, QUARTER_NOTE], \
["G", 3, QUARTER_NOTE], \
["D", 4, QUARTER_NOTE], \
["C", 4, HALF_NOTE], \
["G", 3, EIGHTH_NOTE], \
["G", 3, EIGHTH_NOTE], \
["G", 4, QUARTER_NOTE], \
["E", 4, QUARTER_NOTE], \
["C", 4, QUARTER_NOTE], \
["B", 3, QUARTER_NOTE], \
["A", 3, HALF_NOTE], \
["F", 4, EIGHTH_NOTE], \
["F", 4, EIGHTH_NOTE], \
["E", 4, QUARTER_NOTE], \
["C", 4, QUARTER_NOTE], \
["D", 4, QUARTER_NOTE], \
["C", 4, HALF_NOTE] \
]; \
var isPlaying = false; \
var timer = null; \
function playNotes(instrument, notes, index) { \
index = index || 0; \
if (index >= notes.length) { \
isPlaying = false; \
return; \
} \
var note = notes[index]; \
instrument.play.apply(instrument, note); \
timer = setTimeout(function() { \
playNotes(instrument, notes, index + 1); \
}, note[2] * 1000); \
} \
var piano = Synth.createInstrument("piano"); \
document.getElementById("music-playd").onclick = function() { \
if (isPlaying) return; \
isPlaying = true; \
playNotes(piano, notes); \
}; \
document.getElementById("music-stopd").onclick = function() { \
clearTimeout(timer); \
isPlaying = false; \
} \
</script>\
<script src="https://cdnjs.cloudflare.com/ajax/libs/audiosynth/1.0.0/audiosynth.min.js"></script>\
<button id="music-playd">Play the music</button> \
<button id="music-stopd">Stop</button> \
'))