This file contains 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
public class TransactionManager_AntiOcp | |
{ | |
public TransactionManager() | |
{ | |
} | |
public void Payment(string paymentMethod) | |
{ | |
if(paymentMethod == "inbound") |
This file contains 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
public class BankPaymentService_AntiSrp | |
{ | |
public BankPaymentService_AntiSrp() | |
{ | |
} | |
public void Transfer() | |
{ | |
GetBalance(); | |
AccountLookUp(); |
This file contains 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
def longest(words): | |
tokens = words.split() | |
max_length = 0 | |
max_word="" | |
for token in tokens: | |
if len(token)> max_length: | |
max_length = len(token) | |
max_word = token | |
return max_word |
This file contains 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
def power(a,b): | |
if b == 0: | |
return 1 | |
else: | |
return eval(((str(a)+"*")*b)[:-1]) |
This file contains 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
def my_sort(numbers): | |
odd = [n for n in numbers if n % 2 != 0] | |
even = [n for n in numbers if n % 2 == 0] | |
return sorted(odd) + sorted(even) | |
print( my_sort([90, 45, 66])) |
This file contains 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
def remove_duplicates(string): | |
unique = ''.join(sorted(set(string))) | |
removed = len(string) - len(unique) | |
return unique, removed | |
print(remove_duplicates('accccount')) |
This file contains 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
class ShoppingCart(object): | |
def __init__(self): | |
self.total = 0 | |
self.items = {} | |
def add_item(self, item_name, quantity, price): | |
self.total += price*quantity | |
self.items.update({item_name: quantity}) | |
def remove_item(self, item_name, quantity, price): |
This file contains 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
def is_isogram(word): | |
#to get the type of word | |
if type(word)!=str: | |
#print error | |
raise TypeError("Argument should be a String") | |
#remove space | |
elif word.strip()=="": | |
return(word,False) | |
else: | |
#change to lower case |
This file contains 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
public static string[,] LoadCsv(string filename) | |
{ | |
//get the file text | |
string text = System.IO.File.ReadAllText(filename); | |
//split into Lines | |
text = text.Replace("\n", "\r"); | |
string[] lines = text.Split(new char[] { '\r' }, StringSplitOptions.RemoveEmptyEntries); | |
// to get how many rows and columns |
This file contains 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
public static int columnCount(string filepath) | |
{ | |
int numColumns = 0; | |
using(var reader = File.OpenText(filepath)) | |
{ | |
while(reader.ReadLine() != null ) | |
{ | |
string data = System.IO.File.ReadAllText(filepath); | |
// split the text |
NewerOlder