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
#07/10/16 | |
#https://www.hackerrank.com/challenges/find-a-string | |
s1 = raw_input() | |
s2 = raw_input() | |
tam = len(s2) | |
c = 0 | |
for i in range(0,len(s1)): | |
if s1[i] == s2[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
#7/15/16 | |
#https://www.hackerrank.com/challenges/text-alignment | |
ti = int(raw_input()) #an odd number | |
c = '@' | |
w = ' ' | |
#Top | |
for i in range(ti): |
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
{ | |
"AWSTemplateFormatVersion" : "2010-09-09", | |
"Description" : "Create an Amazon EC2 instance running the Amazon Linux AMI. The AMI is chosen | |
based on the region in which the stack is run. This example creates an EC2 security group for the instance | |
to give you SSH access.", | |
"Parameters" : { | |
"KeyName": { | |
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instance", |
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
#08/1/16 | |
#https://www.hackerrank.com/challenges/designer-door-mat | |
N, M = map(int,input().split()) # More than 6 lines of code will result in 0 score. Blank lines are not counted. | |
for i in range(1,N,2): | |
print ((i*".|.").center(M,"-")) | |
print ("WELCOME".center(M,"-")) | |
for i in range(N-2,-1,-2): | |
print ((i*".|.").center(M,"-")) |
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
#8/1/16 | |
#https://www.hackerrank.com/challenges/itertools-permutations | |
from itertools import permutations | |
s = raw_input().split() | |
l = (permutations(sorted(s[0]),int(s[1]))) | |
for i in l: | |
print ''.join(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
#08/3/16 | |
#https://www.hackerrank.com/challenges/collections-counter | |
from collections import Counter | |
n = int(raw_input()) | |
l = map(int,raw_input().split()) | |
c = int(raw_input()) | |
s = 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
5.times {puts 'bizz buzz'} | |
beez by | |
beez by | |
beez by | |
beez by | |
beez by | |
=> 5 | |
5.times do |
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
CRUD Review | |
Operations with SQLAlchemy | |
In this lesson, we performed all of our CRUD operations with SQLAlchemy on an SQLite database. Before we perform any operations, we must first import the necessary libraries, connect to our restaurantMenu.db, and create a session to interface with the database: | |
from sqlalchemy import create_engine | |
from sqlalchemy.orm import sessionmaker | |
from database_setup import Base, Restaurant, MenuItem |
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 time | |
#Example of counting days to an event: | |
from datetime import date | |
today = date.today() | |
today | |
today == date.fromtimestamp(time.time()) |
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 BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer | |
class WebserverHandler(BaseHTTPRequestHandler): | |
def do_GET(self): | |
try: | |
if self.path.endswith('/hello'): | |
self.send_response(200) | |
self.send_header('Content-type', 'text/html') | |
self.end_headers() |