This file contains 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
# Spreading Udaciousness | |
# One of our modest goals is to teach everyone in the world to program and | |
# understand computer science. To estimate how long this will take we have | |
# developed a (very flawed!) model: | |
# Everyone answering this question will convince a number, spread, (input to | |
# the model) of their friends to take the course next offering. This will | |
# continue, so that all of the newly recruited students, as well as the original | |
# students, will convince spread of their |
This file contains 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
# Khayyam Triangle | |
# The French mathematician, Blaise Pascal, who built a mechanical computer in | |
# the 17th century, studied a pattern of numbers now commonly known in parts of | |
# the world as Pascal's Triangle (it was also previously studied by many Indian, | |
# Chinese, and Persian mathematicians, and is known by different names in other | |
# parts of the world). | |
# The pattern is shown below: |
This file contains 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
# Triple Gold Star | |
# Only A Little Lucky | |
# The Feeling Lucky question (from the regular homework) assumed it was enough | |
# to find the best-ranked page for a given query. For most queries, though, we | |
# don't just want the best page (according to the page ranking algorithm), we | |
# want a list of many pages that match the query, ordered from the most likely | |
# to be useful to the least likely. |
This file contains 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
# Question 8: Longest Repetition | |
# Define a procedure, longest_repetition, that takes as input a | |
# list, and returns the element in the list that has the most | |
# consecutive repetitions. If there are multiple elements that | |
# have the same number of longest repetitions, the result should | |
# be the one that appears first. If the input list is empty, | |
# it should return None. | |
def longest_repetition(input_list): |
This file contains 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
# --------------------------- # | |
# Intro to CS Final Project # | |
# Gaming Social Network # | |
# --------------------------- # | |
# | |
# Background | |
# ========== | |
# You and your friend have decided to start a company that hosts a gaming | |
# social network site. Your friend will handle the website creation (they know |
This file contains 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
# Two Gold Stars | |
# Question 2: Combatting Link Spam | |
# One of the problems with our page ranking system is pages can | |
# collude with each other to improve their page ranks. We consider | |
# A->B a reciprocal link if there is a link path from B to A of length | |
# equal to or below the collusion level, k. The length of a link path | |
# is the number of links which are taken to travel from one page to the | |
# other. |
This file contains 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
# THREE GOLD STARS | |
# Question 3-star: Elementary Cellular Automaton | |
# Please see the video for additional explanation. | |
# A one-dimensional cellular automata takes in a string, which in our | |
# case, consists of the characters '.' and 'x', and changes it according | |
# to some predetermined rules. The rules consider three characters, which | |
# are a character at position k and its two neighbours, and determine | |
# what the character at the corresponding position k will be in the new |
This file contains 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
# Atom Beautify - Debugging information | |
The following debugging information was generated by `Atom Beautify` on `Fri Mar 03 2017 11:05:22 GMT-0800 (PST)`. | |
--- | |
## Table Of Contents | |
- [Versions](#versions) | |
- [Original file to be beautified](#original-file-to-be-beautified) | |
- [Original File Contents](#original-file-contents) |
This file contains 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
#!/bin/python | |
import sys | |
n = int(raw_input().strip()) | |
s = raw_input().strip() | |
k = int(raw_input().strip()) | |
This file contains 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 printMove(fr, to): | |
print('move from ' + str(fr) + ' to ' + str(to)) | |
def Towers(n, fr, to, spare): | |
if n == 1: | |
printMove(fr, to) | |
else: | |
Towers(n-1, fr, spare, to) | |
Towers(1, fr, to, spare) | |
Towers(n-1, spare, to, fr) |
OlderNewer