Skip to content

Instantly share code, notes, and snippets.

@TApicella
TApicella / RosettaCode JaroDistance.py
Created May 9, 2017 18:29
RosettaCode JaroDistance created by tapicella - https://repl.it/Hous/36
'''
http://rosettacode.org/wiki/Jaro_distance
d = 0 if no matching characters
otherwise d = (1/3) * (m/len(s1) + m/len(s2) + (m-(transpose/2))/m )
characters match if distance >= (max(len(s1), len(s2))/2)-1
if distance != 0, counts as a transpose
'''
def JaroDistance(s1, s2):
@TApicella
TApicella / Daily Programmer 5-11-2017: Shorthand Range.py
Created May 11, 2017 13:58
Daily Programmer 5-11-2017: Shorthand Range created by tapicella - https://repl.it/HsuW/15
'''
Take the following inputs in shorthand range, and translate them to longhand range.
1,6,4,9,1,6 => [1, 6, 14, 19, 21, 26]
2,9..9,9 => [2, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 29]
5,7,0,1,9,4 => [5, 7, 10, 11, 19, 24]
'''
@TApicella
TApicella / RosettaCode- Hash Join.py
Created May 11, 2017 15:37
RosettaCode- Hash Join created by tapicella - https://repl.it/HtIS/31
'''
http://rosettacode.org/wiki/Hash_join
Implement the "hash join" algorithm, and demonstrate that it passes the test-case listed below.
You should represent the tables as data structures that feel natural in your programming language.
Guidance
The "hash join" algorithm consists of two steps:
Hash phase: Create a multimap from one of the two tables, mapping from each join column value to all the rows that contain it.
@TApicella
TApicella / RosettaCode- Knapsack problem.py
Created May 11, 2017 17:19
RosettaCode- Knapsack problem created by tapicella - https://repl.it/HtMj/28
'''
http://rosettacode.org/wiki/Knapsack_problem/0-1
Knapsack problem/0-1
A tourist wants to make a good trip at the weekend with his friends.
They will go to the mountains to see the wonders of nature, so he needs to pack well for the trip.
He has a good knapsack for carrying things, but knows that he can carry a maximum of only 4kg in it, and it will have to last the whole day.
@TApicella
TApicella / RosettaCode- Ethiopian multiplaction.py
Created May 11, 2017 19:18
RosettaCode- Ethiopian multiplaction created by tapicella - https://repl.it/Ht6L/6
'''
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
'''
@TApicella
TApicella / RosettaCode- Count in factors.py
Created May 11, 2017 20:20
RosettaCode- Count in factors created by tapicella - https://repl.it/Hthb/12
'''
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
@TApicella
TApicella / Daily Programmer 5-15-2017- matrix transpose.py
Created May 15, 2017 15:10
Daily Programmer 5-15-2017- matrix transpose created by tapicella - https://repl.it/Hy9H/37
'''
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
@TApicella
TApicella / RosettaCode- Sudoku.py
Created May 16, 2017 15:53
RosettaCode- Sudoku created by tapicella - https://repl.it/HzMK/82
'''
http://rosettacode.org/wiki/Sudoku
'''
import copy
square_ranges = {
0: [0, 1, 2],
1: [0, 1, 2],
@TApicella
TApicella / DailyProgrammer 5-16-2017 Txt acronyms.py
Created May 16, 2017 16:57
DailyProgrammer 5-16-2017 Txt acronyms created by tapicella - https://repl.it/IBGV/10
'''
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
@TApicella
TApicella / RosettaCode- pangram checker.py
Created May 16, 2017 17:20
RosettaCode- pangram checker created by tapicella - https://repl.it/IBRL/3
'''
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.
'''