Skip to content

Instantly share code, notes, and snippets.

View abdulateef's full-sized avatar

Abdulateef abdulateef

  • sekat technologies
  • Lagos Nigeria
View GitHub Profile
@abdulateef
abdulateef / consoleTerminate.cs
Last active July 2, 2017 06:58
how to terminate a console program on a button click
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);
@abdulateef
abdulateef / newLinesCount.cs
Last active July 2, 2017 06:57
how to count new line in a text file
public static int Rowcount(string filepath)
{
int lineCount = 0;
using(var reader = File.OpenText(filepath))
{
while(reader.ReadLine() != null)
{
lineCount++;
}
@abdulateef
abdulateef / QuicksortInPlace.cs
Last active November 5, 2016 12:55
Quicksort In-Place Solution in c#
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);
@abdulateef
abdulateef / InsertionSort2.cs
Created November 4, 2016 17:46
Hanker Rank Insertion Sort - Part 2 Solution in C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Algorithms
{
class InsertionSort2
{
@abdulateef
abdulateef / MaximumDraw
Last active November 1, 2016 12:05
Jim is off to a party and is searching for a matching pair of socks. His drawer is filled with socks, each pair of a different color. In its worst case scenario, how many socks (x) should Jim remove from his drawer until he finds a matching pair?
using System;
using System.Collections.Generic;
using System.IO;
class Solution {
static void Main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution */
// Console.WriteLine("Enter the Nmber of Test Case");
int Size = int.Parse(Console.ReadLine());
int[] input = new int[Size];
int i;
import java.util.Scanner;
import jdk.nashorn.internal.parser.TokenType;
public class ConditionStatement {
public static void main(String [] args){
/// scanner to read input name and number
///though name not neccessary
///happy coding.....
Scanner input = new Scanner(System.in);
System.out.println("Enter your Name");
String name = input.next();
@abdulateef
abdulateef / WordCount.cs
Last active August 5, 2016 10:32
how to count the occurrence of a word in a text file using c#
public static void WordCount(string word, string path)
{
int index;
int occurrence = 0;
try
{
StreamReader reader = new StreamReader(path);
using(reader)
@abdulateef
abdulateef / HourGlass
Last active October 17, 2020 19:30
Solution to Calculate the hourglass sum for every hourglass in A, then print the maximum hourglass sum.
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution
{
public static void main(String[] args)
@abdulateef
abdulateef / binary.java
Last active November 23, 2017 19:39
Given a base- 10 integer, n , convert it to binary (base-2). Then find and print the base- 10 integer denoting the maximum number of consecutive 1's in n's binary representation.
import java.util.Scanner;
public class Binary
{
public static String convertToBinary(int decnumber)
{
String binaryString = " ";
if (decnumber > 0)
{
binaryString = Integer.toBinaryString(decnumber);