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
i = 0 | |
numbers = [] | |
new_variable = int(raw_input("What is the number you want to go up to? >>> ")) | |
while i < new_variable: | |
print "At the top i is %d" % i | |
numbers.append(i) | |
i = i + 1 | |
print "Numbers now: ", numbers |
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
### Assignment ### | |
# | |
# Your assignment is to implement the | |
# following function: `find_next_prime`. | |
# As the name states, given the number `n` the | |
# function should return the next closest prime. | |
# | |
# Examples: | |
# * `find_next_prime(6)` should return 7. | |
# * `find_next_prime(10)` should return 11. |
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
# answer = A * B + C | |
# Return the sum of the digits of the answer | |
def sum_of_digits(number): | |
digits = [int(digit) for digit in list(str(number))] # Create a list of digits | |
return sum(digits) q # Then return the sum of the digits | |
number_of_cases = int(input()) | |
for case in range(number_of_cases): |
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
# Modular Calculator | |
# I looked through a couple of other people's answers and it seems that most people had used a while loop. | |
# There is a much simpler solution using dictionaries/hash tables. | |
# http://www.codeabbey.com/index/task_view/modular-calculator | |
total = int(input()) # initial value | |
solved = False | |
while not solved: | |
operation, value = input().split() | |
if operation == "+": | |
total += int(value) |
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
# Link: http://www.codeabbey.com/index/task_view/palindromes | |
# Outline: | |
# 1. Find the number of cases that will be in the problem. | |
# 2. For each case: | |
# 3. Either create a string or find a list of only letters | |
# 4. Remove case-sensitivity | |
# 5. Compare the string/list to its reversed version | |
# 6. Print "Y" if the comparisons are equal and "N" otherwise. | |
# 7. Run and check. |
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
number_of_cases = int(input()) | |
for case in range(number_of_cases): | |
new_case = input() | |
# new_case is a new line of data. | |
# CODE HERE | |
# Want to usually print(ANSWER, end=' ') which prints out an answer | |
# but also a space at the end so it's nicely formatted for submission. |
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
number_of_cases = int(input()) | |
for case in range(number_of_cases): | |
games = [outcome for outcome in input().split()] | |
player1_score = 0 | |
player2_score = 0 | |
player1_wins = ["PR", "RS", "SP"] | |
player2_wins = ["RP", "SR", "PS"] | |
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
words = input().split() | |
repeats = [] | |
for code_word in words: | |
if words.count(code_word) > 1 and code_word not in repeats: | |
repeats.append(code_word) | |
print(" ".join(sorted(repeats))) |
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
// write myMap(array, callback) | |
Assessment.myMap = function(array, callback) { | |
var mappedArr = []; | |
for (n=0; n < array.length; n++) { | |
mappedArr.push(callback(array[n])); | |
} | |
return mappedArr; | |
}; | |
// write primes(n) |
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 __future__ import absolute_import | |
from __future__ import division | |
from __future__ import print_function | |
import argparse | |
import os.path | |
import re | |
import sys | |
import tarfile |
OlderNewer