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
''' | |
The table below gives the age (in year) and mileage (in KMs) of four used cars: | |
WARTBURG MOSKVICH LADA TRABI | |
Age: 5 7 15 28 | |
Mileage: 30530 90000 159899 270564 | |
1. Determine the weights w0 and w1 for a simple linear regression to predict mileage from age. | |
2. Use the model from (1) to predict the mileage for a 15-year old car. | |
''' |
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
''' | |
Professor Boolean is an evil villain who is up to no good. | |
It is your job to help bring her down. The is a gang working under her. | |
The chain of command of the gang is structured in such a way that each leader has 7 people working directly under him/her. | |
Your task is to find the total number of people in Prof. Boolean's workforce given the number of level of hierarchy. | |
''' | |
levels = int(input('Number of level(s): ')) | |
peoples = 1 | |
for i in range(levels): | |
peoples += (7 ** (i + 1)) |
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
# Usage: python convert.py glove_model.txt | |
import sys | |
import time | |
def file_len(fname): | |
line = col = 0 | |
with open(fname, encoding = 'UTF-8') as f: | |
for line, l in enumerate(f): | |
if col == 0: |
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
# Tutorial links: | |
# https://youtu.be/yMk_XtIEzH8?list=PLQVvvaa0QuDezJFIOU5wDdfy4e9vdnx-7 | |
# https://youtu.be/Gq1Azv_B4-4?list=PLQVvvaa0QuDezJFIOU5wDdfy4e9vdnx-7 | |
# https://youtu.be/CBTbifYx6a8?list=PLQVvvaa0QuDezJFIOU5wDdfy4e9vdnx-7 | |
import gym | |
import numpy as np | |
import matplotlib.pyplot as plt | |
env = gym.make('MountainCar-v0') |
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 random, time | |
def generate_random_number(): | |
number = list(map(str, str(time.time()).replace('.', ''))) | |
return int(''.join(random.sample(number, len(number)))) | |
print(generate_random_number()) |
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 random, json, requests, string, sys | |
def game(): | |
chain = 0 | |
usedWords = [] | |
answer_Word = None | |
chainGood = True | |
min_length = 3 | |
while chainGood: | |
# if chain != 0 and chain % 5 == 0: min_length += 1 |
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
# Video link: https://youtu.be/3P3TcKaegbA?list=PLxvWWIq3F0k0GE1EYvricLniNSdv9gvZS | |
import os | |
import time | |
from datetime import datetime | |
from github import Github | |
from curtsies.fmtfuncs import yellow | |
ACCESS_TOKEN = open('token', 'r').read() | |
g = Github(ACCESS_TOKEN) |
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
def solution(secret, guess): | |
while secret != guess: | |
correct_position_guessed = [0] * len(secret) | |
correct_color_guessed = [color for color in secret if color in guess] | |
for i in range(len(secret)): | |
if secret[i] == guess[i]: | |
correct_position_guessed[i] = 1 | |
print('Correct colors guessed: {}'.format(' '.join(color for color in correct_color_guessed))) |
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
# This Python script can be used to generate true Reber grammar sequences. | |
# To generate false Reber grammar sequences, just change tuple values in 'traversal' at line 8. | |
import numpy as np | |
chars = 'BTSXPVE' | |
traversal = [[('T', 'P'), (1, 4)], [('S', 'X'), (1, 2)], [('S', 'X'), (3, 4)], [('E'), (-1,)], [('V', 'T'), (5, 4)], [('V', 'P'), (3, 2)]] | |
def generate_seq(min_length): |
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 os | |
import pickle | |
import warnings | |
from functools import reduce | |
from operator import add | |
import numpy as np | |
import pandas as pd | |
import torch | |
from tqdm import tqdm |