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
# Rock-paper-scissors-lizard-Spock template | |
# The key idea of this program is to equate the strings | |
# "rock", "paper", "scissors", "lizard", "Spock" to numbers | |
# as follows: | |
# | |
# 0 - rock | |
# 1 - Spock | |
# 2 - paper |
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
# Guess the Number by Anirudh Jayaraman | |
# dated Thu Jun 11 11:54 PM IST | |
# import all functionalities from the modules mentioned below | |
from simplegui import * | |
from math import * | |
from random import * | |
# helper function to start and restart the game | |
def new_game(num_range = 100): |
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
# "Stopwatch: The Game" created by Anirudh Jayaraman | |
# dated Wed Jun 17, 2015 12:18 PM IST | |
import simplegui | |
# define global variables | |
canvas_width = 850; canvas_height = 300; button_size = 100 | |
timer_interval = 100; current_time = 0; played = 0; won = 0 | |
running = False | |
rules_first_line = "Number of successful stops at a whole second" | |
rules_second_line = "versus the total number of stops" |
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
# Implementation of classic arcade game Pong by Anirudh Jayaraman | |
# coded on 24 June 2015 10:20 PM | |
from simplegui import * | |
from random import * | |
# initialize globals - pos and vel encode vertical info for paddles | |
WIDTH = 600 | |
HEIGHT = 400 | |
BALL_RADIUS = 20 |
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 module for matrix operations | |
from numpy import * | |
# read the file with the matrix of numbers | |
filename = 'euler11.txt' | |
# store each line of the file into an array | |
with open(filename, "r") as ins: | |
array = [] | |
for line in ins: |
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 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 | |
49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00 | |
81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65 | |
52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91 | |
22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80 | |
24 47 32 60 99 03 45 02 44 75 33 53 78 36 84 20 35 17 12 50 | |
32 98 81 28 64 23 67 10 26 38 40 67 59 54 70 66 18 38 64 70 | |
67 26 20 68 02 62 12 20 95 63 94 39 63 08 40 91 66 49 94 21 | |
24 55 58 05 66 73 99 26 97 17 78 78 96 83 14 88 34 89 63 72 | |
21 36 23 09 75 00 76 44 20 45 35 14 00 61 33 97 34 31 33 95 |
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
# Question: Which prime, below one-million, can be written as the sum of the most consecutive primes | |
from primesieve import * | |
from math import * | |
# Generate list of primes under a million | |
primes_under_million = generate_primes(10**6) | |
# Sum of consecutive primes is of order 0.5(n^2)(logn) | |
# Calculate 'n' so that sum of consecutive primes is less than a million (and not necessarily prime) | |
nsum = 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
# 28 is the first triangle number to have over five divisors. | |
# What is the value of the first triangle number to have over five hundred divisors? | |
from math import * | |
# Function to calculate divisors | |
def divisors(n): | |
limit = int(sqrt(n)) | |
divisors_list = [] | |
for i in range(1, limit+1, 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
from math import * | |
# Function to calculate the number of divisors of integer n | |
def divisors(n): | |
limit = int(sqrt(n)) | |
divisors_list = [] | |
for i in range(1, limit+1, 1): | |
if n % i == 0: | |
divisors_list.append(i) | |
if i != n/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
# First Step | |
# First number 'check' to have 500 divisors | |
check = 2**4 * 3**4 * 5**4 * 7 * 11 | |
# Second Step | |
# Starting from 'check', iterate sequentially checking for the next 'triangle' number | |
while not isTriangleNumber(check): | |
check += 1 | |
# Third and Fourth Steps |
OlderNewer