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
p=print | |
r=str | |
m=',\n' | |
b=' bottles of beer' | |
w=' on the wall' | |
f='Take one down, pass it around'+m | |
n='.\n' | |
q=w+n | |
y=w+m | |
k=n+f |
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 PIL import Image | |
import random as r | |
import math | |
def distance(point1, point2, manhattan_dist=False): | |
if manhattan_dist: | |
return abs(point2[0]-point1[0]) + abs(point2[1]-point1[1]) | |
else: | |
return math.sqrt( (point2[0] - point1[0])**2 + (point2[1] - point1[1])**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
''' | |
Write a function/procedure/subroutine that is called with an integer value and returns the middle three digits of the integer if possible or a clear indication of an error if this is not possible. | |
Note: The order of the middle digits should be preserved. | |
Your function should be tested with the following values; the first line should return valid answers, those of the second line should return clear indications of an error: | |
123, 12345, 1234567, 987654321, 10001, -10001, -123, -100, 100, -12345 | |
1, 2, -1, -10, 2002, -2002, 0 |
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
''' | |
Task | |
Multisplit | |
You are encouraged to solve this task according to the task description, using any language you may know. | |
It is often necessary to split a string into pieces based on several different (potentially multi-character) separator strings, while still retaining the information about which separators were present in the input. | |
This is particularly useful when doing small parsing tasks. | |
The task is to write code to demonstrate this. |
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 pangram is a sentence that contains all the letters of the English alphabet at least once. | |
For example: The quick brown fox jumps over the lazy dog. | |
Task | |
Write a function or method to check a sentence to see if it is a pangram (or not) and show its use. | |
''' |
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
''' | |
On console input you will be given a string that represents the abbreviated chat message. | |
Output. Output should consist of the expanded sentence.Wordlist | |
lol - laugh out loud | |
dw - don't worry | |
hf - have fun | |
gg - good game | |
brb - be right back | |
g2g - got to go |
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
''' | |
http://rosettacode.org/wiki/Sudoku | |
''' | |
import copy | |
square_ranges = { | |
0: [0, 1, 2], | |
1: [0, 1, 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
''' | |
Write a program that takes input text from standard input and outputs the text -- transposed. | |
Roughly explained, the transpose of a matrix | |
A B C | |
D E F | |
is given by |
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
''' | |
http://rosettacode.org/wiki/Count_in_factors | |
Write a program which counts up from 1, displaying each number as the multiplication of its prime factors. | |
For the purpose of this task, 1 (unity) may be shown as itself. | |
Example |
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
''' | |
http://rosettacode.org/wiki/Ethiopian_multiplication | |
Take two numbers to be multiplied and write them down at the top of two columns. | |
In the left-hand column repeatedly halve the last number, discarding any remainders, and write the result below the last in the same column, until you write a value of 1. | |
In the right-hand column repeatedly double the last number and write the result below. stop when you add a result in the same row as where the left hand column shows 1. | |
Examine the table produced and discard any row where the value in the left column is even. | |
Sum the values in the right-hand column that remain to produce the result of multiplying the original two numbers together | |
''' |
NewerOlder