Skip to content

Instantly share code, notes, and snippets.

View Per48edjes's full-sized avatar
👉
This is a good point.

Ravi Dayabhai Per48edjes

👉
This is a good point.
View GitHub Profile
@Per48edjes
Per48edjes / Spreading Udaciousness
Last active January 18, 2017 07:53
Simple Recursion Problem
# 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
@Per48edjes
Per48edjes / Khayyam Triangle
Last active June 1, 2017 18:20
Using recursion to generate list form of Pascal's Triangle
# 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:
@Per48edjes
Per48edjes / Only a Little Lucky
Created January 21, 2017 21:51
Returning pages returned by keyword lookup by ranks
# 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.
@Per48edjes
Per48edjes / Longest Repetition in a List
Last active January 27, 2017 20:01
Find the element in a list that has the most consecutive repetitions
# 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):
@Per48edjes
Per48edjes / Gamer's Network
Last active February 15, 2017 20:29
Udacity CS 101: Final Project
# --------------------------- #
# 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
@Per48edjes
Per48edjes / Combating Link Spam
Last active February 19, 2017 09:14
Adjust ranks for collusion
@Per48edjes
Per48edjes / Elementary Cellular Automation
Last active February 19, 2017 22:34
Transforms input string based on rules set determined by a 'pattern number'
# 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
@Per48edjes
Per48edjes / pythonlinelength.json
Created March 3, 2017 19:08
Atom Beautify - Debugging Info
# 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)
@Per48edjes
Per48edjes / caesar_cipher_1
Created May 12, 2017 15:27
Caesar's Cipher (v.1)
#!/bin/python
import sys
n = int(raw_input().strip())
s = raw_input().strip()
k = int(raw_input().strip())
@Per48edjes
Per48edjes / TowerHanoi.py
Created August 27, 2017 20:03
Recursive solution to the Tower of Hanoi problem with N discs
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)