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
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| using System.Threading.Tasks; | |
| namespace Algorithms | |
| { | |
| class InsertionSort2 | |
| { |
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
| using System; | |
| using System.Collections.Generic; | |
| using System.IO; | |
| class Solution { | |
| static void Main(String[] args) | |
| { | |
| int N = Convert.ToInt32(Console.ReadLine()); | |
| string[] arr_temp = Console.ReadLine().Split(' '); | |
| int[] list1 = Array.ConvertAll(arr_temp,Int32.Parse); | |
| Solution.quickSortInPlace(list1); |
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
| public static int Rowcount(string filepath) | |
| { | |
| int lineCount = 0; | |
| using(var reader = File.OpenText(filepath)) | |
| { | |
| while(reader.ReadLine() != null) | |
| { | |
| lineCount++; | |
| } |
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
| Console.WriteLine("Oop!! an error has occured"); | |
| Console.WriteLine("Press Enter to exit the program..." + "OR" + "Press Back Space to see the error"); | |
| ConsoleKeyInfo keyinfor = Console.ReadKey(true); | |
| if(keyinfor.Key == ConsoleKey.Enter) | |
| { | |
| System.Environment.Exit(0); | |
| } | |
| else if(keyinfor.Key == ConsoleKey.Backspace) | |
| { | |
| Console.WriteLine(ex.Message); |
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
| 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 |
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
| 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 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
| 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 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
| 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 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
| def remove_duplicates(string): | |
| unique = ''.join(sorted(set(string))) | |
| removed = len(string) - len(unique) | |
| return unique, removed | |
| print(remove_duplicates('accccount')) |
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
| 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])) |