Skip to content

Instantly share code, notes, and snippets.

View slavaceornea's full-sized avatar

Slava Ceornea slavaceornea

  • Stockholm, Sweden
View GitHub Profile
@slavaceornea
slavaceornea / IntegerToArray.cpp
Last active June 8, 2016 09:25
C/C++/C#/Java code that puts all the digits of a number n into an array for further processing.
int[] inputArray = new int[10];
int i = 0;
while (n != 0) {
inputArray[i] = n%10;
n /= 10;
i++;
}
@slavaceornea
slavaceornea / UtopianTree.java
Created June 7, 2016 14:00
Java class solves the Utopian Tree problem. It contains a regular and a binary operations solution.
package utopiantree;
import java.util.Scanner;
/**
*
* @author Slava
*
* The Utopian Tree goes through 2 cycles of growth every year. Each spring, it doubles in height.
* Each summer, its height increases by 1 meter.
@slavaceornea
slavaceornea / SherlockAndTheBeast.java
Last active June 6, 2016 19:39
Java class solves the Sherlock And The Beast problem. The solution has O(1) complexity.
package sherlockandthebeast;
import java.util.Scanner;
/**
*
* @author Slava
*
* Sherlock and The Beast
*
@slavaceornea
slavaceornea / SherlockAndTheBeastBruteforce.java
Last active June 6, 2016 19:30
Java class solves the Sherlock And The Beast problem by pure bruteforce approach. The solution is of O(n) complexity. There is a mathematical solution that makes it a O(1) instead.
package sherlockandthebeast;
import java.util.Scanner;
/**
*
* @author Slava
*
* Sherlock and The Beast
*
@slavaceornea
slavaceornea / TimeConversion.java
Last active June 3, 2016 15:32
Given a time in AM/PM format, convert it to military (24-hour) time.
import java.util.Scanner;
/**
*
* @author Slava
*
* Given a time in AM/PM format, convert it to military (24-hour) time.
*
* Note: Midnight is 12:00:00AM on a 12-hour clock, and 00:00:00 on a 24-hour clock.
*
@slavaceornea
slavaceornea / Staircase.java
Last active June 3, 2016 14:37
Java class outputs a staircase structure of height n that it gets from stdin.
import java.util.Scanner;
/**
*
* @author Slava
*
* Your teacher has given you the task of drawing a staircase structure. Being an expert programmer, you decided to make a program to draw it for you instead. Given the required height, can you print a staircase as shown in the example?
*
* Input
* You are given an integer depicting the height of the staircase.
@slavaceornea
slavaceornea / FractionsOfPositivesNegativesAndZeroesInArray.java
Created June 3, 2016 12:45
Java class that prints the fractions of positives, negatives and zeroes in an array.
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class FractionsOfPositivesNegativesAndZeroesInArray {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
@slavaceornea
slavaceornea / matrixDiagonalDifference.java
Last active June 3, 2016 11:57
Java class that calculates the absolute valuefor the difference between the sums of two diagonals of a matrix of size NxN.
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
//Java class that calculates the absolute value for the difference between the sums of two diagonals of a matrix of size NxN.
public class matrixDiagonalDifference {
public static void main(String[] args) {
@slavaceornea
slavaceornea / JollyJumpers.java
Last active June 2, 2016 14:03
Java class that analyses whether a sequence of integers is a JollyJumper or not.
package jollyjumpers;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.regex.Pattern;
/**
*
* @author Slava Ceornea
*
@slavaceornea
slavaceornea / CreateExport_SelfSignedCertificate.ps1
Last active June 2, 2016 11:06
Powershell script creates and exports self-signed certificate as .pfx file.
New-SelfSignedCertificate -certstorelocation cert:\localmachine\my -dnsname selfsignedcertificate.internal
# change Pa$$word with your own
$pwd = ConvertTo-SecureString -String "{Pa$$word}" -Force -AsPlainText
# in between parantheses on the next line use the ID you get by running the first command
Export-PfxCertificate -cert Cert:\localMachine\my\{15034633B1C5D9FB68EAD7984B7816C1D73D27E2} -FilePath c:\temp\selfsignedcertificate.internal.pfx -Password $pwd