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
| <a href='https://play.google.com/store/apps/details?id=esme.parkinson.tabatatimer&utm_source=global_co&utm_medium=prtnr&utm_content=Mar2515&utm_campaign=PartBadge&pcampaignid=MKT-Other-global-all-co-prtnr-py-PartBadge-Mar2515-1'><img alt='Get it on Google Play' src='https://play.google.com/intl/en_gb/badges/images/generic/en_badge_web_generic.eps'/></a> |
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
| ''' | |
| Caesar Cipher - encrypt and decrypt | |
| Takes as input: 'e'/'d', key, plaintext/ciphertext | |
| Outputs: ciphertext/plaintext | |
| ''' | |
| import os | |
| def encrypt(plaintext, key): | |
| plaintext = plaintext.lower() | |
| shiftBy = key - 32 |
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 Data.List | |
| f :: Int -> [Int] -> [Int] | |
| f n arr = filter (<n) arr |
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 Data.List | |
| f :: Int -> [Int] -> [Int] | |
| f n arr = filter (<n) arr | |
| -- The Input/Output section. You do not need to change or modify this part | |
| main = do | |
| n <- readLn :: IO Int | |
| inputdata <- getContents | |
| let | |
| numbers = map read (lines inputdata) :: [Int] |
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
| #15 minutes | |
| ''' | |
| Input: 2 sets ascending order sorted, separated by semi-colon. | |
| Comma delimited values. | |
| Output: Print out the ascending order sorted intersection of the two lists, one per line. | |
| If no intersection, print empty. | |
| ''' | |
| file = open('testValues.txt', 'r') |
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
| ''' | |
| Input: user enters string consisting of words without spaces | |
| Output: each word is printed on a different line. | |
| In case of overlap, favours shorter words on left hand side. | |
| words.txt is file containing all valid words to check against | |
| ''' | |
| def checkIfReal(word): | |
| real = False | |
| file = open('words.txt', 'r') |
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
| f :: Int -> [Int] -> [Int] | |
| f n arr = concatMap (replicate n) arr | |
| main :: IO () | |
| main = getContents >>= | |
| mapM_ print. (\(n:arr) -> f n arr). map read. words |
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
| n = int(input()) | |
| if n % 2 == 0: | |
| total = (n^2 + n)/2 | |
| else: | |
| total = (n + 1)*math.floor(n/2) + math.ceiling(n/2) |
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 | |
| n = int(input()) | |
| running_total = 0 | |
| def make_answer(i, n, running_total): | |
| if i > n: | |
| print(running_total) | |
| else: | |
| make_answer(i+1,n,running_total+i) | |
| make_answer(i, n, running_total) |
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
| n = int(input()) | |
| running_total = 0 | |
| for i in range(0,n+1): | |
| running_total += i | |
| print(running_total) |
NewerOlder