Skip to content

Instantly share code, notes, and snippets.

$crypto = @"
P k T r 2 s z 2 * c F -
r a z 7 G u D 4 w 6 U #
g c t K 3 E @ B t 1 a Y
Q P i c % 7 0 5 Z v A e
W 6 j e P R f p m I ) H
y ^ L o o w C n b J d O
S i 9 M b e r # ) i e U
* f 2 Z 6 M S h 7 V u D
5 a ( h s v 8 e l 1 o W
@0ryant
0ryant / gist:c48ce87a57e04c2462e45c78b183813a
Created August 1, 2019 09:38
Java - Coding Challenge 1 - Speed Converter
public class SpeedConverter {
public static long toMilesPerHour(double kilometersPerHour){
if (kilometersPerHour <0) {
return -1;
}
return Math.round(kilometersPerHour/1.609);
@0ryant
0ryant / gist:5d6d0809df8e9ec9234a7c9f50264a98
Created August 1, 2019 09:39
Java - Coding Challenge 2 - MegaBytes Converter
public class MegaBytesConverter {
public static void printMegaBytesAndKiloBytes(int kiloBytes){
if (kiloBytes < 0){
System.out.println("Invalid Value");
} else {
int megabytes = (kiloBytes/1024);
int kiloRemainder = kiloBytes%1024;
System.out.println(kiloBytes+" KB = "+megabytes+" MB and "+kiloRemainder+" KB");
@0ryant
0ryant / gist:ba8a845221d8b69b6d20750d882732d9
Created August 1, 2019 09:40
Java - Coding Challenge 3 - Barking dog
public class BarkingDog {
public static boolean shouldWakeUp(boolean barking,int hourOfDay){
if (hourOfDay <0 || hourOfDay >23){
return false;
}
if (barking == true && hourOfDay <8 || hourOfDay >22){
return true;
@0ryant
0ryant / gist:d624b8d0e68a3e1de0333a41bfd96bdc
Created August 1, 2019 10:07
Java - Coding Challenge 4 - LeapYear
public class LeapYear {
public static boolean isLeapYear(int year) {
if (year < 1 || year > 9999) {
return false;
}
if (year % 4 == 0) {
if (year % 100 == 0) {
@0ryant
0ryant / gist:79f0347dc6d1ec9c364749d448e09f90
Created August 1, 2019 11:28
Java - Coding Challenge 5 - Decimal Comparator
// numbers must be equal up to 3 decimal places
public class DecimalComparator {
public static boolean areEqualByThreeDecimalPlaces(double first,double second) {
if (first <0 && second >0 || first >0 && second <0){
return false;
}
@0ryant
0ryant / gist:e8d4d6323d96f960a4a3ad737991abb1
Created August 1, 2019 11:39
Java - Coding Challenge 6 - Equal Sum Checker
public class EqualSumChecker {
public static boolean hasEqualSum (int a, int b, int c) {
if (a+b==c){return true;}
return false;
}
}
@0ryant
0ryant / gist:a829b42a8a0c1c111097919967ef7b70
Last active August 1, 2019 15:20
Java - Coding Challenge 7 - TeenNumberChecker
public class TeenNumberChecker {
public static boolean hasTeen(int a,int b,int c){
if (a >=13 && a <=19 ||
b >=13 && b <=19 ||
c >=13 && c <=19 ) {
return true;
}
return false;
@0ryant
0ryant / gist:64e95caa93bb2c0cacf690f86edf3486
Created August 6, 2019 11:08
Java - Coding Challenge 8 - AreaCalculator (Method Overloading)
public class AreaCalculator {
public static double area (double radius) {
if (radius<0) {
return -1.0d;
}
double areaOfCircle = ((Math.PI * (radius*radius)));
return areaOfCircle;
@0ryant
0ryant / gist:d237cf56e98846576651580d3d22efc4
Created August 6, 2019 11:37
Java - Coding Challenge 9 - Minutes to Years and Days
public class MinutesToYearsDaysCalculator {
public static void printYearsAndDays(long minutes){
if (minutes <0) {
System.out.println("Invalid Value");
} else {
long years = minutes / 525600;
long minutesRemaining = (minutes - (years * 525600));
long daysRemaining = minutesRemaining / 1440;