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
| # 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
| ''' | |
| 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
| ''' | |
| 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
| ip = input('Enter a string: ') | |
| op = ip[0] | |
| for i in range(len(ip) - 1): | |
| dist = ord(ip[i].lower()) - ord(ip[i+1].lower()) | |
| if dist > 0: op += ' > ' + ip[i+1] | |
| else: op += ' < ' + ip[i+1] | |
| print(op) |
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
| # Regex | HackerRank | |
| # https://www.hackerrank.com/domains/regex | |
| # Matching Anything But a Newline | |
| Regex_Pattern = r'...\....\....\....$' | |
| # Matching Specific String | |
| Regex_Pattern = r'hackerrank' |
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 numpy | |
| s1 = input('input: ').strip().lower(); l1 = len(s1) + 1 | |
| s2 = input('target: ').strip().lower(); l2 = len(s2) + 1 | |
| m = numpy.empty([l1, l2], dtype = int) | |
| for i in range(l1): | |
| m[i][0] = i |
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
| n, d = map(int, input().split()) # n = len(array), d = Number of rotation | |
| values = [i for i in input().split()][:n] | |
| print(" ".join(values[d:] + values[:d])) # left rotation | |
| print(" ".join(values[n-d:] + values[:n-d])) # right rotation |
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
| ... | |
| String QRcode = "..."; | |
| new generateQrcode(qrcodeImageview).execute(QRcode); | |
| ... | |
| private class generateQrcode extends AsyncTask<String, Void, Bitmap> { | |
| public final static int WIDTH = 400; | |
| ImageView bmImage; | |
| public generateQrcode(ImageView bmImage) { | |
| this.bmImage = bmImage; |
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
| <?xml version="1.0" encoding="utf-8"?> | |
| <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:app="http://schemas.android.com/apk/res-auto" | |
| xmlns:tools="http://schemas.android.com/tools" | |
| android:id="@+id/activity_facebook" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| android:paddingBottom="@dimen/activity_vertical_margin" | |
| android:paddingLeft="@dimen/activity_horizontal_margin" | |
| android:paddingRight="@dimen/activity_horizontal_margin" |