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: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:52270ae96537fc0149445a4cdcb593ed
Created August 7, 2019 13:39
Java - Coding Challenge 15 - Is Number a Palindrome?
public class NumberPalindrome {
public static boolean isPalindrome(int number){
if (number < 0){
number = number - (number*2);
}
String reverseNumber = "";
int newNumber = number;
@0ryant
0ryant / gist:841ac53a46e1392f975dd8e4d7d2e761
Last active August 7, 2019 14:08
Java - Coding Challenge 16 - Sum of First and Last Digit
public static int sumFirstAndLastDigit(int number){
if (number < 0 ) {
return -1;
}
int firstDigit = number%10;
int lastDigit=0;
for (int i = number; i != 0; i /= 10){
lastDigit = i%10;
@0ryant
0ryant / gist:269211e0aa586608bab8c1d81573ab39
Created August 7, 2019 14:19
Java - Coding Challenge - Sum of All Even Digits
public static int getEvenDigitSum(int number){
if (number < 0){
return -1;
}
int sum=0;
for (int i = number; i !=0; i /= 10){
if ((i%10)%2==0){
sum+=i%10;
@0ryant
0ryant / gist:3483c0f8c7df93704da7e56efe97440e
Created August 8, 2019 09:41
Java - Coding Challenge - Get Greatest Common Divisor
public static int getGreatestCommonDivisor(int first, int second){
if ((first<10)||(second<10)){
return -1;
}
int gtDivisor=1;
for (int i=2;i<=((first+second)/2);i++)
if ((first%i==0)&&(second%i==0)){
gtDivisor=i;
}
return gtDivisor;
@0ryant
0ryant / gist:e1219044ad766ac07244ea5a96849c34
Created August 12, 2019 14:48
Java - Coding Challenge - How many Buckets does Bob need?
public static int getBucketCount(double width, double height, double areaPerBucket, int extraBuckets) {
if ((width <= 0) || (height <= 0) || (areaPerBucket <= 0)||(extraBuckets<0)) {
return -1;
}
double wallArea = (width * height);
int bucketsNeeded = (int) ((wallArea / areaPerBucket) - extraBuckets);
if (bucketsNeeded < (wallArea/areaPerBucket)){
@0ryant
0ryant / gist:ddcbf9172c43a7e98170164c8d82df0d
Created August 13, 2019 08:12
Java - Coding Challenge - Classes; Simple Calculator
public class SimpleCalculator {
private double firstNumber;
private double secondNumber;
public double getFirstNumber(){
return firstNumber;
}
public double getSecondNumber(){
return secondNumber;
@0ryant
0ryant / gist:25cf8679ed62491d5bbcb173a214d8cd
Created August 13, 2019 11:50
Java - Coding Challenge - Classes; Wall Area
public class Wall {
// Params
private double width;
private double height;
// Constructors
public Wall() {
}
public Wall(double width,double height){