Skip to content

Commit 52a7b03

Browse files
author
codehouseindia
authored
Merge branch 'master' into master
2 parents 794063d + a54a4bd commit 52a7b03

96 files changed

Lines changed: 3250 additions & 17 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Add Elements Using add().java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import java.util.LinkedList;
2+
3+
class Main {
4+
public static void main(String[] args){
5+
6+
// create a linkedlist
7+
LinkedList<String> languages = new LinkedList<>();
8+
9+
// Add elements to LinkedList
10+
languages.add("Java");
11+
languages.add("Python");
12+
languages.add("JavaScript");
13+
System.out.println("LinkedList: " + languages);
14+
}
15+
}

Add Number

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
public class AddTwoNumbers {
2+
3+
public static void main(String[] args) {
4+
5+
int num1 = 5, num2 = 15, sum;
6+
sum = num1 + num2;
7+
8+
System.out.println("Sum of these numbers: "+sum);
9+
}
10+
}

Addition.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#https://www.facebook.com/mayankgbrc/post/2726954114288546
2+
#subscribe by code house
3+
import java.util.*;
4+
5+
public class addition
6+
{
7+
public static void main(String[] args)
8+
{
9+
//write your code here
10+
11+
scanner digit=new scanner(system.in);
12+
int n,m,c;
13+
system.out.println("enter the two number");
14+
n=digit.nextint();
15+
m=digit.nextint();
16+
c=m+n;
17+
system.out.println("the sum of the number is "+c);
18+
}
19+
}

Amstrom.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# https//www.facebook.com/yashwantbisht/73738473829
2+
# subscribed by codehouse
3+
In [13]: open?
4+
Type:           builtin_function_or_method
5+
Base Class:     <type 'builtin_function_or_method'>
6+
String Form:    <built­in function open>
7+
Namespace:      Python builtin
8+
Docstring:
9+
    open(name[, mode[, buffering]]) ­> file object
10+
    Open a file using the file() typereturns a file 
11+
object.
12+
Constructor Docstring:
13+
    x.__init__(...) initializes xsee 
14+
x.__class__.__doc__ for signature

Anagram.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#https://www.facebook.com/permalink.php?story_fbid=2038372642966043&id=100003799820060
2+
#Subscribed by Kattebaaz
3+
import java.util.Arrays;
4+
5+
public class AnagramString {
6+
static void isAnagram(String str1, String str2) {
7+
String s1 = str1.replaceAll("\\s", "");
8+
String s2 = str2.replaceAll("\\s", "");
9+
boolean status = true;
10+
if (s1.length() != s2.length()) {
11+
status = false;
12+
} else {
13+
char[] ArrayS1 = s1.toLowerCase().toCharArray();
14+
char[] ArrayS2 = s2.toLowerCase().toCharArray();
15+
Arrays.sort(ArrayS1);
16+
Arrays.sort(ArrayS2);
17+
status = Arrays.equals(ArrayS1, ArrayS2);
18+
}
19+
if (status) {
20+
System.out.println(s1 + " and " + s2 + " are anagrams");
21+
} else {
22+
System.out.println(s1 + " and " + s2 + " are not anagrams");
23+
}
24+
}
25+
26+
public static void main(String[] args) {
27+
isAnagram("Keep", "Peek");
28+
isAnagram("Mother In Law", "Hitler Woman");
29+
}
30+
}

Armstrong Number

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class ArmstrongExample{
2+
public static void main(String[] args) {
3+
int c=0,a,temp;
4+
int n=153;//It is the number to check armstrong
5+
temp=n;
6+
while(n>0)
7+
{
8+
a=n%10;
9+
n=n/10;
10+
c=c+(a*a*a);
11+
}
12+
if(temp==c)
13+
System.out.println("armstrong number");
14+
else
15+
System.out.println("Not armstrong number");
16+
}
17+
}

Armstrong.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class ArmstrongExample{
2+
public static void main(String[] args) {
3+
int c=0,a,temp;
4+
int n=153;//It is the number to check armstrong
5+
temp=n;
6+
while(n>0)
7+
{
8+
a=n%10;
9+
n=n/10;
10+
c=c+(a*a*a);
11+
}
12+
if(temp==c)
13+
System.out.println("armstrong number");
14+
else
15+
System.out.println("Not armstrong number");
16+
}
17+
}

ArrayListDuplicateApp.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// https://www.facebook.com/smkmallik/posts/3415890411793806
2+
// Subscribed by Code House
3+
import java.util.ArrayList;
4+
import java.util.LinkedHashSet;
5+
import java.util.List;
6+
import java.util.Set
7+
8+
class ArrayListDuplicateApp {
9+
public static void main(String[] args) {
10+
List<Integer> primes = new ArrayList<Integer>();
11+
12+
primes.add(2);
13+
primes.add(3);
14+
primes.add(5);
15+
primes.add(7);
16+
primes.add(7);
17+
primes.add(11);
18+
19+
System.out.println("List of Prime Numbers: " + primes);
20+
21+
Set<Integer> primesWithoutDuplicates = new LinkedHashSet<Integer>(primes);
22+
23+
primes.clear();
24+
25+
primes.addAll(primesWithoutDuplicates);
26+
27+
System.out.println("List of primes without duplicates: " + primes);
28+
}
29+
}

Avengers

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
public class Avengers
2+
{
3+
public static void main(String[]args)
4+
{
5+
int a,b,c
6+
System.out.println("Enter a number for A")
7+
a=in.nextInt()
8+
System.out.println("Enter a number for B")
9+
b=in.nextInt()
10+
c=a+b
11+
System.out.println("Your answer is="+c)
12+
}
13+
}

Binary Search Algorithm.

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package test;
2+
public class BinarySearch {
3+
// Java implementation of recursive Binary Search
4+
// Returns index of x if it is present in arr[l..
5+
// r], else return -1
6+
int binarySearch(int arr[], int l, int r, int x)
7+
{
8+
if (r >= l) {
9+
int mid = l + (r - l) / 2;
10+
// If the element is present at the
11+
// middle itself
12+
if (arr[mid] == x)
13+
return mid;
14+
// If element is smaller than mid, then
15+
// it can only be present in left subarray
16+
if (arr[mid] >x)
17+
return binarySearch(arr, l, mid - 1, x);
18+
// Else the element can only be present
19+
// in right subarray
20+
return binarySearch(arr, mid + 1, r, x);
21+
}
22+
// We reach here when element is not present
23+
// in array
24+
return -1;
25+
}
26+
public static void main(String args[])
27+
{
28+
BinarySearch ob = new BinarySearch();
29+
int arr[] = { 2, 3, 4, 10, 40 };
30+
int n = arr.length;
31+
int x = 40;
32+
int result = ob.binarySearch(arr, 0, n - 1, x);
33+
if (result == -1)
34+
System.out.println("Element not present");
35+
else
36+
System.out.println("Element found at index " + result);
37+
}
38+
}

0 commit comments

Comments
 (0)