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 / NewYearChaos.java
Created July 17, 2016 13:05
This java class solves the NewYearChaos problem. Check out code comments for description of problem and solution.
package newyearchaos;
import java.util.Scanner;
/**
*
* @author Slava
*
* It's New Year's Day and everyone's in line for the Wonderland rollercoaster ride!
*
@slavaceornea
slavaceornea / ServiceLane.java
Created June 25, 2016 10:09
This Java class solves the Service Lane problem. Check code comments for more details.
package servicelane;
import java.util.Scanner;
/**
*
* @author Slava
*
*/
public class ServiceLane {
@slavaceornea
slavaceornea / SherlockAndSquares.java
Created June 18, 2016 10:47
This java class solves the Sherlock and Squares problem. Check comments for description of the problem.
/*
* Watson gives two integers (A and B) to Sherlock and asks if he can count the number of square integers between A and B (both inclusive).
*
* Note: A square integer is an integer which is the square of any integer. For example, 1, 4, 9, and 16 are some of the square integers as they are squares of 1, 2, 3, and 4, respectively.
*
* Input Format
* The first line contains T, the number of test cases. T test cases follow, each in a new line.
* Each test case contains two space-separated integers denoting A and B.
*
* Output Format
@slavaceornea
slavaceornea / sqrtNewtonRaphson.c
Created June 12, 2016 15:33
C code calculates square root using Newton Raphson method.
#include <stdio.h>
// Function to get absolute value of the number given by user.
float absolute(float num)
{
if(num < 0){
num = -num;
}
return num;
}
// Function to calculate square root of the number using Newton-Raphson method
@slavaceornea
slavaceornea / sqrtBinarySearch.java
Last active June 12, 2016 15:34
Java function calculates square root using binary search.
float sqrtBinarySearch(n) {
low = 0.0;
high = (float)n+1;
while ((high-low) > 0.00001) {
mid = (low+high) / 2;
if (mid*mid < n) {
low = mid;
}
else {
high = mid;
@slavaceornea
slavaceornea / ChangeAzureVMInstanceSize.ps1
Created June 9, 2016 10:51
Changes VM instance size in Azure.
#Change VM instance size
Get-AzureVM -ServiceName slavaceorneavm1 -Name slavaceorneavm1 |
Set-AzureVMSize -InstanceSize ExtraSmall |
Update-AzureVM
@slavaceornea
slavaceornea / SelectCurrentAzureSubscription.ps1
Created June 9, 2016 10:50
Selects the current Azure subscription.
#Select current azure subscription
Select-AzureSubscription -SubscriptionName 'Visual Studio Professional with MSDN' -Current
@slavaceornea
slavaceornea / ImportPublishSettingsFile.ps1
Created June 9, 2016 10:49
Imports Azure publish settings file from local file.
#Import publish settings
Import-AzurePublishSettingsFile C:\temp\azureaccount.publishsettings
@slavaceornea
slavaceornea / GetAzurePublishSettingsFile.ps1
Created June 9, 2016 10:48
Gets Azure publish settings file
#Get publish settings file
Get-AzurePublishSettingsFile
@slavaceornea
slavaceornea / FindDigits.java
Created June 8, 2016 09:52
Java class that solves the FindDigits problem. Check code comments for description of problem and solution.
package finddigits;
import java.util.Scanner;
/**
*
* @author Slava
*
* Given an integer, N , traverse its digits (d1,d2,...,dn)
* and determine how many digits evenly divide N