Skip to content

Instantly share code, notes, and snippets.

View eveem's full-sized avatar
😊
Happy coding

Monpriya T. eveem

😊
Happy coding
View GitHub Profile
@eveem
eveem / fb_c.py
Created September 1, 2021 13:04
Problem B: Xs and Os Facebook Hacker Cup 2021
t = int(input())
for r in range(1, t + 1):
n = int(input())
m = []
for _ in range(n):
m.append(input())
fin_by = set()
@eveem
eveem / fb_b.py
Created September 1, 2021 12:57
Problem A2: Consistency - Chapter 2 Facebook Hacker Cup 2021
t = int(input())
for r in range(1, t + 1):
s = input()
k = int(input())
mapper = {}
target = set()
level = {f"{i}{i}": 0 for i in s}
for _ in range(k):
@eveem
eveem / fb_a.py
Created September 1, 2021 12:38
Problem A1: Consistency - Chapter 1 Facebook Hacker Cup 2021
t = int(input())
for r in range(1, t + 1):
s = input()
n = len(s)
m = float("inf")
for i in range(26):
counter = 0
curr = chr(ord("A") + i)
test_images[['image', 'annotated_predictions']].explore()
# load model
model = tc.load_model('./pokemon_5000.model')
# read images
test_images = tc.SFrame({'image':[tc.Image('dataset/pokemon_test1.jpg'),
tc.Image('dataset/pokemon_test2.jpeg'),
tc.Image('dataset/pokemon_test3.jpg'),
tc.Image('dataset/pokemon_test4.jpeg')]})
# predict
import turicreate as tc
starter_images = tc.SFrame({'image':[tc.Image('dataset/pokemon.png')], 'label':['pokemon']})
model = tc.one_shot_object_detector.create(starter_images, 'label', max_iterations=5000)
model.save('pokemon_5000.model')
f = open('ach_output.txt', 'w')
t = int(input())
for i in range(t):
n = int(input())
s = input()
a = s.count('A')
b = s.count('B')
f = open('output.txt', 'w')
t = int(input())
for a in range(t):
n = int(input())
i = input()
o = input()
result = []
for b in range(n):
model = Sequential()
model.add(Bidirectional(LSTM(128), input_shape=(SEQUENCE_LEN, len(words))))
model.add(Dense(len(words)))
model.add(Activation("softmax"))
model.compile(loss="categorical_crossentropy", optimizer="adam", metrics=["accuracy"])
model.fit_generator(
generator(sentences, next_words, BATCH_SIZE),
steps_per_epoch=int(len(sentences) / BATCH_SIZE) + 1,
epochs=EPOCHS,
word_indices = dict((c, i) for i, c in enumerate(words))
indices_word = dict((i, c) for i, c in enumerate(words))
for i in range(0, len(text_in_words) - SEQUENCE_LEN):
if (len(set(text_in_words[i : i + SEQUENCE_LEN + 1]).intersection(ignored_words)) == 0):
sentences.append(text_in_words[i : i + SEQUENCE_LEN])
next_words.append(text_in_words[i + SEQUENCE_LEN])