Skip to content

Instantly share code, notes, and snippets.

View bijay-shrestha's full-sized avatar
👨‍🎓
MSCS Compro

Bijay Shrestha bijay-shrestha

👨‍🎓
MSCS Compro
  • Bank of America
  • SF, CA
View GitHub Profile
package com.hawa.practice;
import lombok.extern.slf4j.Slf4j;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
@Slf4j
public class Trivalent {
@bijay-shrestha
bijay-shrestha / IsolatedNumber.java
Created May 22, 2021 11:36
A positive number is said to be isolated if none of the digits in its square are in its cube.
package com.hawa.practice;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class IsolatedNumber {
public static void main(String[] args) {
long number = 63;
log.info("Checking if given number {} is isolated or not. " +
@bijay-shrestha
bijay-shrestha / SequentiallyBounded.java
Created May 22, 2021 12:40
An integer array is defined to be sequentially-bounded if it is in ascending order and each value, n, in the array occurs less than n times in the array.
package com.hawa.practice;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class SequentiallyBounded {
public static void main(String[] args) {
// int[] arrayOfNumbers = {1, 2, 3, 3, 3, 99, 99, 99, 99};
@bijay-shrestha
bijay-shrestha / StackedNumber.java
Created May 22, 2021 12:51
A stacked number is a number that is the sum of the first n positive integers for some n.
package com.hawa.practice;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class StackedNumber {
public static void main(String[] args) {
int number = 7;
log.info("Checking if given number {} is stacked or not. " +
"--> Result: 1 for yes and 0 for no.",
package com.hawa.practice;
import lombok.extern.slf4j.Slf4j;
import java.util.ArrayList;
@Slf4j
public class SumSafe {
public static void main(String[] args) {
package com.hawa.practice;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class MadhavArray {
public static void main(String[] args) {
// int[] arrayOfNumbers = {2, 1, 1, 4, -1, -1};
// int[] arrayOfNumbers = {6, 2, 4, 2, 2, 2, 1, 5, 0, 0};
/**
* A number n>0 is called cube-powerful if it is equal to the sum of the cubes of its digits.
* Write a function named isCubePowerful that returns 1 if its argument is cube-powerful; otherwise it returns 0.
* The function prototype is
* int isCubePowerful(int n);
* Hint: use modulo 10 arithmetic to get the digits of the number.
*/
package com.hawa.practice;
/**
* Define an array to be a 121 array if all its elements are either 1 or 2 and it begins with one or more 1s followed by a one or more 2s
* and then ends with the same number of 1s that it begins with. Write a method named is121Array that returns 1 if its array argument is
* a 121 array, otherwise, it returns 0.
*/
package com.hawa.practice;
import lombok.extern.slf4j.Slf4j;
/**
*
* It is a fact that there exist two numbers x and y such that x! + y! = 10!.
* Write a method named solve10 that returns the values x and y in an array.
* The notation n! is called n factorial and is equal to n * n-1 * n-2 * … 2 * 1, e.g., 5! = 5*4*3*2*1 = 120.
*
*/
package com.hawa.practice;
@bijay-shrestha
bijay-shrestha / PrimeCount.java
Created May 25, 2021 14:42
Remember: Prime numbers have only two factors.
package com.hawa.practice;
import lombok.extern.slf4j.Slf4j;
import java.util.ArrayList;
@Slf4j
public class PrimeCount {