Skip to content

Instantly share code, notes, and snippets.

View bragboy's full-sized avatar
🧘
Inner peace

Bragadeesh bragboy

🧘
Inner peace
View GitHub Profile
package nasa.main;
import java.util.StringTokenizer;
import nasa.exceptions.InvalidInputException;
import nasa.exceptions.OutOfRangeException;
public class Heading {
private int x;
private int y;
package nasa.main;
import nasa.exceptions.InvalidInputException;
import nasa.exceptions.OutOfRangeException;
public class Nasa {
private ISignal signal;
private ControlPanel controlPanel;
package misc.integers;
public class RevNum {
public static void main(String args[]){
int sampleNum = 12345678;
System.out.println("Input Num : "+sampleNum);
int reversedNum = 0;
while(sampleNum!=0){
reversedNum = reversedNum*10 + sampleNum%10;
sampleNum = sampleNum/10;
package dsa.arrays;
import java.util.HashSet;
import java.util.Set;
public class FindSumHashSet {
public static void main(String a[]){
FindSumHashSet sumFinder = new FindSumHashSet();
sumFinder.begin();
}
public class CompactArray {
public static void main(String[] args) {
CompactArray c = new CompactArray();
int[] sampleArray = {-1,5,3,-1,3,5,2,1,-1,6};
System.out.print(" Input : ");printArray(sampleArray, sampleArray.length);
int validIndex = c.compact(sampleArray);
System.out.print("Output : ");printArray(sampleArray, validIndex);
}
private int compact(int[] arr){
def find_prime(n)
return false if n <= 1
2.upto(Math.sqrt(n).to_i) do |x|
return false if n%x == 0
end
true
end
large = []
1.upto(1000000) { |each_num| large[each_num] = true if find_prime(each_num) }
count = 0
(101010107..199999999).step(10) do |n|
if ((n*n).to_s.gsub /(.)./,'\1') == "123456789" || (((n-4)*(n-4)).to_s.gsub /(.)./,'\1') == "123456789"
puts "The unique positive number is #{n*10}"
break
end
end
def is_lynchrel(n)
50.times do
n += n.to_s.reverse.to_i
return false if n.to_s == n.to_s.reverse
end
true
end
count = 0
1.upto(9999) do |n|
count +=1 if is_lynchrel(n)
def divisors_count(n)
return 1 if n==1
count = 0
1.upto(Math.sqrt(n)) do |x|
if n%x == 0
count+=1 unless n.to_f/x == x
count+=1
end
end
count
n_s, d_s = [1,1]
12.upto(97) do |n|
13.upto(98) do |d|
next if n/10 == n%10 || d/10 == d%10 || n%10 ==0 || d%10 ==0 || n>=d
a,b = [n.to_s.split(//), d.to_s.split(//)]
if (a&b).size == 1 && (a-(a&b))[0].to_f / (b-(a&b))[0].to_f == n.to_f/d.to_f
n_s*=(a-(a&b))[0].to_i
d_s*=(b-(a&b))[0].to_i
end
end