make filename
6 | to run =>./filename
7 | *************************
8 | To compile a file in c++
9 | g++ filename.cpp -o filename.out
10 | To run it -./filename.out
11 |
12 | **************************
13 | make filename
14 | ./filename
15 | **************************
16 | To compile a file in java
17 | javac filename.java
18 | (however it is necessary to give file name and java main class name same other wise it show error)
19 |
20 | To run a file in java-- java file
21 | here file is class name
22 | **********************************
23 |
24 | TO compile a file in python
25 | python filename.py
26 |
27 | This will run the file as well compile
28 |
29 | ************************************
30 |
--------------------------------------------------------------------------------
/codes/web tech/node/app.js:
--------------------------------------------------------------------------------
1 |
2 | const EventEmitter = require('events');
3 | const emitter = new EventEmitter();
4 | //Register a listener
5 |
6 | emitter.on('messageLogged', (arg) =>{
7 | console.log('Listener called', arg);
8 | });
9 |
10 | const log = require('./logger');
11 | log('message');
12 |
13 |
--------------------------------------------------------------------------------
/codes/web tech/node/logger.js:
--------------------------------------------------------------------------------
1 | const EventEmitter = require('events');
2 | const emitter = new EventEmitter();
3 |
4 | function log(message) {
5 | //send request
6 | console.log(message);
7 |
8 | //Raise an event
9 | emitter.emit('messageLogged', {id: 1, url:'https://'});
10 | }
11 |
12 | module.exports = log;
13 |
--------------------------------------------------------------------------------
/codes/web tech/pluralsight/web2.0/images/googl.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sauravjaiswalsj/Competitive-Programming/81aae2e43c484b21d2c495cd15d510a49771b92f/codes/web tech/pluralsight/web2.0/images/googl.png
--------------------------------------------------------------------------------
/codes/web tech/pluralsight/web2.0/index.css:
--------------------------------------------------------------------------------
1 | *{
2 | color:black;
3 | }
4 | body{
5 | background-color: antiquewhite;
6 | background-image: url(images/googl.png)
7 | }
8 | h1{
9 | background-color:aqua;
10 | font-family: fantasy;
11 | }
12 | h2{
13 | background-color: cornflowerblue;
14 | font-family: monospace;
15 | }
16 | .content{
17 | background-color: deepskyblue;
18 | font-family: cursive;
19 | }
20 | #menu{
21 | background-color: darkviolet;
22 | }
23 | /* mouse over link */
24 | #button{
25 | background-color: aquamarine;
26 | border-style: solid;
27 | border-color: black;
28 | border-width: 1mm;
29 | font-size: 1.5em;
30 | width:6%;
31 |
32 | }
33 | #button a:hover{
34 | color: blueviolet;
35 | }
--------------------------------------------------------------------------------
/codes/web tech/pluralsight/web2.0/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | PluralSight_CSS
5 |
6 |
7 |
8 |
11 |
12 | Heading 1
13 | Heading 2
14 |
15 |
17 |
19 |
20 |
--------------------------------------------------------------------------------
/codes/web tech/pluralsight/web3.0/images/googl.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sauravjaiswalsj/Competitive-Programming/81aae2e43c484b21d2c495cd15d510a49771b92f/codes/web tech/pluralsight/web3.0/images/googl.png
--------------------------------------------------------------------------------
/codes/web tech/pluralsight/web4.0/index.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sauravjaiswalsj/Competitive-Programming/81aae2e43c484b21d2c495cd15d510a49771b92f/codes/web tech/pluralsight/web4.0/index.css
--------------------------------------------------------------------------------
/codes/web tech/pluralsight/web4.0/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | My page
5 |
6 |
7 |
8 |
9 |
10 |
11 |
Absolute Division of Pages
12 | Saurav Jaiswal | August 17 2018
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/hackerearth/Parcel.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | class TestClass1{
3 | public static final Scanner cin=new Scanner(System.in);
4 | public static void main(String[] args){
5 | int sum,c=0;
6 | int n=cin.nextInt();
7 | cin.next();
8 | String s=cin.nextLine();
9 | for(int i=0;i0){
32 | System.out.println("invalid");
33 | }
34 | else{
35 | System.out.println("valid");
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/hackerrank/.ReachingPoint.java.swp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sauravjaiswalsj/Competitive-Programming/81aae2e43c484b21d2c495cd15d510a49771b92f/hackerrank/.ReachingPoint.java.swp
--------------------------------------------------------------------------------
/hackerrank/algo/.birds.java.swp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sauravjaiswalsj/Competitive-Programming/81aae2e43c484b21d2c495cd15d510a49771b92f/hackerrank/algo/.birds.java.swp
--------------------------------------------------------------------------------
/hackerrank/algo/birds.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | import java.lang.*;
3 | class migration{
4 | public static void migration(){
5 |
6 | }
7 | }
8 |
9 | public class birds
10 |
--------------------------------------------------------------------------------
/hackerrank/algo/sumPairs.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | import java.lang.*;
3 | class Solution{
4 | static void Solution(int[] a,int n, int k){
5 | int sum,count=0;
6 | for(int i=0;i arr[j+1]){
9 | int temp = arr[j];
10 | arr[j] = arr[j+1];
11 | arr[j+1] = temp;
12 | c++;
13 | }
14 | }
15 | }
16 | if(c>1){
17 | System.out.println(c);
18 | }
19 | else{
20 | System.out.println(c);
21 | }
22 | }
23 | }
24 | public class swap{
25 | public static final Scanner cin=new Scanner(System.in);
26 | public static void main(String[] args){
27 | int n=cin.nextInt();
28 | int[] arr=new int[n];
29 | for(int i=0;i
2 | using namespace std;
3 | int binarySearch(int A[],int n,int x){
4 | int start=0;
5 | int end=n-1;
6 | while(start<=end){
7 | int mid=(start+end)/2;
8 | if(A[mid]==x){
9 | return mid;
10 | }
11 | else if(x>A[mid]){
12 | start=mid+1;
13 | }
14 | else{
15 | end=mid-1;
16 | }
17 | }
18 | return -1;
19 | }
20 | int main(){
21 | int n,result;
22 | cin>>n;
23 | int A[n];
24 | for(int i=0;i>A[i];
26 | }
27 | int x;
28 | cin>>x;
29 | result=binarySearch(A,n,x);
30 | if(result==-1){
31 | x++;
32 | result=binarySearch(A,n,x);
33 | cout<<"No "<
2 | #include
3 | #include
4 | #include
5 |
6 | //Complete the following function.
7 |
8 | int marks_summation(int* marks, int number_of_students, char gender) {
9 | //Write your code here.
10 | int sum = 0, i = 0;
11 | if (gender == 'g') {
12 | i = 1;
13 | }
14 | for (; i < number_of_students;i+=2) {
15 | sum = sum + *(marks + i);
16 | }
17 | return sum;
18 | }
19 | int main() {
20 | int number_of_students;
21 | char gender;
22 | int sum;
23 |
24 | scanf("%d", &number_of_students);
25 | int *marks = (int *) malloc(number_of_students * sizeof (int));
26 |
27 | for (int student = 0; student < number_of_students; student++) {
28 | scanf("%d", (marks + student));
29 | }
30 |
31 | scanf(" %c", &gender);
32 | sum = marks_summation(marks, number_of_students, gender);
33 | printf("%d", sum);
34 | free(marks);
35 |
36 | return 0;
37 | }
--------------------------------------------------------------------------------
/hackerrank/compete/compete.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/hackerrank/compete/hourrank26/combomeal.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | given price of burger, can of soda and a combo meal.
3 | to compute the fixed price.
4 |
5 | */
6 | #include
7 | using namespace std;
8 | int main(){
9 | long int t,b,s,c,sum;
10 | cin>>t;
11 | while(t!=0){
12 | cin>>b>>s>>c;
13 | sum=(b+s)-c;
14 | cout<sum[i])&&(k
2 | #include
3 | using namespace std;
4 |
5 | int main() {
6 | long int n;
7 | int i,j;
8 | cin>>n;
9 | long int a[n];
10 | for(i=0;i>a[i];
13 | }
14 | long int temp;
15 | for(i=0; i a[j]){
18 | temp=a[i];
19 | a[i]=a[j];
20 | a[j]=temp;
21 | }
22 | }
23 | }
24 | long int c=1;
25 | for(i=0;i0)
34 | {
35 | cout<
6 |
7 | using namespace std;
8 |
9 | int main() {
10 | int tt;
11 | cin >> tt;
12 | long long ans = 0;
13 | while (tt--) {
14 | long long x;
15 | cin >> x;
16 | ans += (x > 1 ? x : 0);
17 | while (x > 1) {
18 | bool found = false;
19 | for (long long i = 2; i * i <= x; i++) {
20 | if (x % i == 0) {
21 | found = true;
22 | x /= i;
23 | ans += x;
24 | break;
25 | }
26 | }
27 | if (!found) {
28 | break;
29 | }
30 | }
31 | ans += 1;
32 | }
33 | cout << ans << endl;
34 | return 0;
35 | }
36 |
--------------------------------------------------------------------------------
/hackerrank/cpp/numbergroup.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | 1
3 | 3 5
4 | 7 9 11
5 | 13 15 17 19
6 | */
7 | #include
8 | using namespace std;
9 | void pattern(int a){
10 | int i,j,s=1;
11 |
12 | for(i=1;i<=a;i++)
13 | { int sum=0;
14 | for(j=1;j<=i;j++)
15 | {
16 | cout<>n;
31 | pattern(n);
32 | return 0;
33 | }
34 |
--------------------------------------------------------------------------------
/hackerrank/cpp/practice/hello.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int main(void){
4 | std::cout<<"Hello, World!"<
2 |
3 | using namespace std;
4 | /*
5 | * Create classes Rectangle and RectangleArea
6 | */
7 | class Rectangle{
8 | private: int width,height;
9 | public:
10 | void display(){
11 | std::cout<>width>>height;
17 | }
18 | };
19 |
20 | int main()
21 | {
22 | /*
23 | * Declare a RectangleArea object
24 | */
25 | RectangleArea r_area;
26 |
27 | /*
28 | * Read the width and height
29 | */
30 | r_area.read_input();
31 |
32 | /*
33 | * Print the width and height
34 | */
35 | r_area.Rectangle::display();
36 |
37 | /*
38 | * Print the area
39 | */
40 | r_area.display();
41 |
42 | return 0;
43 | }
44 |
--------------------------------------------------------------------------------
/hackerrank/cpp/strings:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sauravjaiswalsj/Competitive-Programming/81aae2e43c484b21d2c495cd15d510a49771b92f/hackerrank/cpp/strings
--------------------------------------------------------------------------------
/hackerrank/cpp/strings.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #define String std::string
4 | int main(){
5 | String a,b;
6 | std::getline(std::cin,a);
7 | std::getline(std::cin,b);
8 | String c=b.substr(0,1);
9 | c=c.append(a.substr(1,a.size()));
10 | std::cout<
2 | using namespace std;
3 |
4 | void mintime(){
5 | int n,temp;
6 | cin>>n;
7 | int a[n];
8 | for(int i=0;i>a[i];
10 | }
11 | for(int i=0;ia[j]){
14 | temp=a[i];
15 | a[i]=a[j];
16 | a[j]=temp;
17 | }
18 | }
19 | }
20 | int min=a[0];
21 |
22 | for(int i=0;ia[i]){
24 | min=a[i];
25 | }
26 | }
27 | cout<>t;
35 | while(t!=0){
36 | mintime();
37 | t--;
38 | }
39 | return 0;
40 | }
41 |
--------------------------------------------------------------------------------
/hackerrank/cpp/vector.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | int main(){
5 | int n,t;
6 | std::cin>>n;
7 | std::vector list;
8 | for(int i=0;i>t;
10 | list.push_back(t);
11 | }
12 | sort(list.begin(),list.end());
13 | for(int i=0;i
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/hackerrank/java/ArrayQuery.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | import java.lang.Math;
3 | public class ArrayQuery{
4 | public static final Scanner cin=new Scanner(System.in);
5 | public static void calculation(){
6 | int a,b,n;
7 | a=cin.nextInt();
8 | b=cin.nextInt();
9 | n=cin.nextInt();
10 | int sum=a,x;
11 | for(int i=0;i list=new LinkedList();
5 | for(int i=1;i<10;i++){
6 | list.add(i);
7 | }
8 | System.out.println(Collections.reverse(list));
9 | }
10 | }
11 |
12 |
--------------------------------------------------------------------------------
/practice/algorithms/merge.java:
--------------------------------------------------------------------------------
1 | import java.util.io;
2 | public class merge{
3 | public static void main(String[] args){
4 | int[] arr=[1,4,5,8,10];
5 | int[] arr2=[0,2,3,6,7,9];
6 | merge(arr,arr2);
7 | }
8 | public static merge(int[] arr,int[] arr2){
9 | int[] newArray=new int[arr.length+arr2.length];
10 | int i=0;
11 | int n=newArray.length;
12 | while(i list=new ArrayList<>();
10 | for(int i=0;i list=new ArrayList<>();
10 | for(int i=0;i list,int low,int high){
25 | //System.out.println(low+" "+high);
26 | while(low list = new ArrayList<>();
6 | for (int i = 0; i < 10; i++) {
7 | list.add(i);
8 | }
9 | list.remove(5);
10 | for (int i : list) {
11 | System.out.println(i);
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/practice/arrays/ClassicalArray/BinarySearch.java:
--------------------------------------------------------------------------------
1 | public class BinarySearch {
2 | public static void main(String[] args) {
3 | int[] arr = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
4 | System.out.println(Search(arr, 8));
5 | }
6 |
7 | public static int Search(int[] arr, int key) {
8 | int low = 0, high = arr.length - 1, mid;
9 | while (low < high) {
10 | mid = (low + high) / 2;
11 | if (arr[mid] == key) {
12 | return arr[mid];
13 | } else if (arr[mid] > key) {
14 | high = mid - 1;
15 | } else {
16 | low = mid + 1;
17 | }
18 | }
19 | return -1;
20 | }
21 | }
--------------------------------------------------------------------------------
/practice/arrays/ClassicalArray/ElementDeletion.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | public class ElementDeletion{
3 | public static void main(String[] args){
4 | int[] array={1,2,3,4,5,6,7};
5 | //System.out.println(array.length);
6 | array=removeArray(array,4);
7 | //System.out.println(array.length);
8 | for(int i:array){
9 | System.out.print(i+" ");
10 | }
11 | }
12 | /*
13 | * This function removes the element from the list
14 | * @param takes the array and the element that has to be removed
15 | */
16 | public static int[] removeArray(int[] array,int key){
17 | int[] arr=new int[array.length-1];
18 | int j=0;
19 | for(int i=0;i"+arr[j]+"->"+i+"->"+j);
25 | j++;
26 | }
27 | return arr;
28 |
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/practice/arrays/RightArrayRotation.java:
--------------------------------------------------------------------------------
1 | import java.util.Scanner;
2 | import java.util.Collections;
3 | import java.util.ArrayList;
4 | public class RightArrayRotation{
5 | public static void main(String[] args){
6 | Scanner cin=new Scanner(System.in);
7 | int n=cin.nextInt();
8 | ArrayList list=new ArrayList();
9 | for(int i=0;i list, int low,int high){
22 | while(low
2 |
3 | using namespace std;
4 |
5 | int main()
6 | {
7 | int n,rev,num;
8 | cout<<"enter the number"<>num; //5
10 | n=num*num; //25
11 | cout<<"Square of "<=10)&&(num<100))
25 | {
26 | rev=n%100;
27 | if(rev==num)
28 | {
29 | flag=1;
30 | break;
31 | }
32 | }
33 | else
34 | {
35 | rev=n%1000;
36 | if(rev==num)
37 | {
38 | flag=1;
39 | break;
40 | }
41 | }
42 | n=n/10;
43 | }
44 | if(flag==1)
45 | {
46 | cout<<"automorphic no is "<
2 |
3 | int main(){
4 | int n;
5 | std::cin>>n;
6 | int temp=n;
7 | do{
8 | std::cout<0){
10 | n=n-5;
11 | std::cout<
2 | int gcd(int a,int b){
3 | if(b==0){
4 | return a;
5 | }
6 | int p=a%b;
7 | return gcd(b,p);
8 | }
9 | int main(void){
10 | int a,b;
11 | std::cin>>a>>b;
12 | std::cout<
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/practice/recursion/.addArray.cpp.swp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sauravjaiswalsj/Competitive-Programming/81aae2e43c484b21d2c495cd15d510a49771b92f/practice/recursion/.addArray.cpp.swp
--------------------------------------------------------------------------------
/practice/recursion/addArray.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | static int summ=0;
3 | static int id=0;
4 | int sum(int array[],int n){
5 | if(id>n){
6 | return 0;
7 | }
8 | id++;
9 | std::cout<>n;
17 | int *arr= new int[n];
18 | for(int i=0;i>arr[i];
20 | }
21 | std::cout<arr.length){
12 | return 0;
13 | }
14 | if(id
2 | int counter=0;
3 | int count(int n)
4 | {
5 | if(n==0)
6 | return 1;
7 | count(n/10);
8 | std::cout<>n;
16 | std::cout<
2 | bool check(int arr[],int n,int x){
3 | if(n==0)
4 | return 1;
5 | std::cout<
2 | int id=1;
3 | bool is_sorted(int *arr ,int size){
4 | if(id>size){
5 | return false;
6 | }
7 | if(arr[id-1]>arr[id]){return false;}
8 | id++;
9 | is_sorted(arr,size);
10 | return true;
11 | }
12 | int main(){
13 | int n;
14 | std::cin>>n;
15 | int *arr=new int[n];
16 | for(int i=0;i>arr[i];
18 | }
19 | std::cout<0){
29 | return n;
30 | }else if(n.compareTo(s)<0){
31 | return Lexicographically(n);
32 | }else{
33 | return "-1";
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/practice/strings/MembershipString.java:
--------------------------------------------------------------------------------
1 | import java.util.Scanner;
2 | class MembershipString{
3 | public static void main(String[] args){
4 | Scanner cin=new Scanner(System.in);
5 | String s1=cin.nextLine();
6 | char c=cin.next().charAt(0);
7 | int i=0;
8 | boolean check=false;
9 | while(i0;i--){
8 | System.out.println(kPanagram(br.readLine(),Integer.parseInt(br.readLine())));
9 | }
10 | }
11 | private static int kPanagram(String string, int k){
12 | if(string.length()<26){return 0;}
13 | Set set=new HashSet<>();
14 | for(int i=0;i set=new TreeSet<>();
10 | for(int i=0;i0;t--){
9 | cin.nextLine();
10 | String s=cin.nextLine();
11 | System.out.println(s.trim());
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/practice/strings/stringBuilder/reverse.java:
--------------------------------------------------------------------------------
1 | import java.util.Scanner;
2 | public class reverse{
3 | public static void main(String[] args){
4 | final Scanner cin=new Scanner(System.in);
5 | String s=cin.nextLine();
6 | StringBuilder sb=new StringBuilder(s);
7 | System.out.println(sb.reverse());
8 | sb.deleteCharAt(2);
9 | System.out.println(sb);
10 | sb.setCharAt(1,'d');
11 | System.out.println(sb);
12 | String x="123";
13 | x.replaceAll("1","0");
14 | System.out.println(x);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/practice/strings/upper.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | class Upper{
3 | public static void main(String[] args){
4 | Scanner cin=new Scanner(System.in);
5 | String s1=cin.nextLine();
6 | System.out.print(s1.toUpperCase());
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/projectEuler/README.md:
--------------------------------------------------------------------------------
1 | ### Solved
2 | * Multiples of 3 and 5
3 | * Even Fibonacci numbers
4 | * Largest prime factor
5 |
--------------------------------------------------------------------------------
/projectEuler/cpp/fibonaci.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | int main()
4 | {
5 | int a=0;
6 | int b=1;
7 | int sum,add=0;
8 |
9 | for(int i=1;i<=32;i++)
10 | {
11 | sum=a+b;
12 | cout<
2 | using namespace std;
3 |
4 | int main()
5 | {
6 | long int n;
7 | cin>>n;
8 | cin.ignore();
9 | for(int i=2;i
2 | using namespace std;
3 |
4 | int main()
5 | {
6 | int n,sum=0;
7 | for(int i=1;i<1000;i++)
8 | {
9 | if((i%3==0)||(i%5==0))
10 | {
11 | sum=sum+i;
12 | }
13 | }
14 | cout<
2 | #include
3 | void primeFact(long);
4 | int main(void){
5 | long n;
6 | printf("Enter the Number to find the primeFactors: ");
7 | scanf("%ld",&n);
8 | primeFact(n);
9 |
10 | }
11 | void primeFact(long n){
12 | int count;
13 | for(long i=2;i<=sqrt(n);i++){
14 | if(n%i==0){
15 | count=0;
16 | while(n%i==0){
17 | n/=i;
18 | count++;
19 | printf("%ld\n",i);
20 |
21 | }
22 | }
23 | }
24 | if(n!=1){
25 | printf("%ld",n);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/projectEuler/projectEuler.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/spoj/CPTTRN1.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | import java.lang.*;
3 | public class CPTTRN1{
4 | public static final Scanner cin=new Scanner(System.in);
5 | public static void main(String[] args) throws java.lang.Exception{
6 | int testCase=cin.nextInt();
7 | while(testCase!=0){
8 | PatternPrinting();
9 | testCase--;
10 | }
11 | }
12 | public static void PatternPrinting(){
13 | int n=cin.nextInt();
14 | int m=cin.nextInt();
15 | //Rows Print
16 | //Column
17 | int row=1;
18 | int nst=m;
19 | while(row<=n){
20 | //work
21 | //star
22 | int cst=1;
23 | while(cst<=nst){
24 | if(row%2==0){
25 | if(cst%2!=0){
26 | System.out.print(".");
27 | }else{
28 | System.out.print("*");
29 | }
30 | }
31 | else{
32 | if(cst%2!=0){
33 | System.out.print("*");
34 | }else{
35 | System.out.print(".");
36 | }
37 | }
38 | cst++;
39 | }
40 | System.out.println("");
41 | row++;
42 | }
43 | }
44 | }
45 |
46 |
--------------------------------------------------------------------------------
/spoj/CPTTRN2.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | import java.lang.*;
3 | class Main{
4 | public static final Scanner cin=new Scanner(System.in);
5 | public static void main(String[] args) throws java.lang.Exception{
6 | int testCase=cin.nextInt();
7 | while(testCase!=0){
8 | PatternPrinting();
9 | testCase--;
10 | }
11 | }
12 | public static void PatternPrinting(){
13 | int n=cin.nextInt();
14 | int m=cin.nextInt();
15 | //Rows Print
16 | //Column
17 | int row=1;
18 | int nst=m;
19 | while(row<=n){
20 | //work
21 | //star
22 | int cst=1;
23 | while(cst<=nst){
24 | if(row==1|| row==n){
25 | System.out.print("*");
26 | }
27 | else{
28 | if(cst==1|| cst==n){
29 | System.out.print("*");
30 | }else{
31 | System.out.print(".");
32 | }
33 | }
34 | cst++;
35 | }
36 | System.out.println("");
37 | row++;
38 | }
39 | }
40 | }
41 |
42 |
--------------------------------------------------------------------------------
/spoj/HS12MBR.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | import java.lang.*;
3 | public class HS12MBR{
4 | public static void main(String[] args)throws java.lang.Exception{
5 |
6 |
--------------------------------------------------------------------------------
/spoj/Pattern/CPTTRN1.java:
--------------------------------------------------------------------------------
1 | package Pattern;
2 |
3 | public class CPTTRN1 {
4 | public CPTTRN1(int n,int m){
5 | int row=1,nst=m;
6 | while(row<=n){
7 | for(int cst=1;cst<=nst;cst++) {
8 | if(((row & 1)==1)){
9 | if(((cst & 1)==1)){
10 | System.out.print("*");
11 | }else{
12 | System.out.print(".");
13 | }
14 | }else{
15 | if((cst&1)==1){
16 | System.out.print(".");
17 | }else{
18 | System.out.print("*");
19 | }
20 | }
21 | }
22 | System.out.println();
23 | row++;
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/spoj/Pattern/CPTTRN2.java:
--------------------------------------------------------------------------------
1 | package Pattern;
2 |
3 | public class CPTTRN2 {
4 | CPTTRN2(int n,int m){
5 | int row=1;
6 | while(row<=n){
7 | for(int cst=1;cst<=m;cst++){
8 | if((row==1) || (row ==n ) || (cst ==1) || (cst==m)){
9 | System.out.print("*");
10 | }else{
11 | System.out.print(".");
12 | }
13 | }
14 | System.out.println();
15 | row++;
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/spoj/Pattern/Main.java:
--------------------------------------------------------------------------------
1 | package Pattern;
2 | import java.util.Scanner;
3 | import Pattern.CPTTRN2;
4 | public class Main {
5 | public static void main(String[] args) {
6 | final Scanner cin = new Scanner(System.in);
7 | int test=cin.nextInt();
8 | int n=0,m=0;
9 | while(test-- >0) {
10 | n = cin.nextInt();
11 | m = cin.nextInt();
12 | CPTTRN2 pattern = new CPTTRN2(n,m);
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/spoj/PrimeGen.py:
--------------------------------------------------------------------------------
1 | import math
2 | def checkPrime(num):
3 | if(num<=1):
4 | return False
5 | if(num == 2 or num == 3):
6 | return True
7 | if(num%2==0 or num%3==0):
8 | return False
9 | for i in range(3,int(math.sqrt(num))):
10 | if(num%i==0):
11 | return False
12 | return True
13 |
14 | if __name__ == "__main__":
15 | loop=int(input())
16 | while(loop!=0):
17 | firstInput, secondInput = map(int, input().split())
18 | for i in range(firstInput, secondInput+1):
19 | if(checkPrime(i)==True):
20 | print(i)
21 | if(loop!=1):
22 | print()
23 | loop-=1
24 |
25 |
--------------------------------------------------------------------------------
/spoj/PrimeGenerator.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | class PrimeGenerator{
3 | public static void main(String[] args){
4 | Scanner cin=new Scanner(System.in);
5 | int test=cin.nextInt();
6 | while(test!=0){
7 | long a=cin.nextLong();
8 | long b=cin.nextLong();
9 | for(long i=a;i<=b;i++){
10 | if(Prime(i)){
11 | System.out.println(i);
12 | }
13 | }
14 | test--;
15 | }
16 | }
17 | public static boolean Prime(long n){
18 | if(n<=1)return false;
19 | if(n==2 || n==3) return true;
20 | if(n%2==0 || n%3==0) return false;
21 | for(long i=3;i name=new ArrayList<>();
7 | for(int i=0;i<=n;i++){
8 | String val=cin.nextLine();
9 | name.add(val);
10 | }
11 | for(String word:name){
12 | int k=word.length();
13 | //System.out.println(k);
14 | for(int i=0;i0;i=i*5){
26 | count+=A/i;
27 | }
28 | return count;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/techgig/Array/ThirdLargest.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | public class ThirdLargest{
3 | public static void main(String[] args){
4 | Scanner cin=new Scanner(System.in);
5 | int n=cin.nextInt();
6 | ArrayList list=new ArrayList<>();
7 | for(int i=0;i list){
13 | Collections.sort(list,Collections.reverseOrder());
14 | return list.get(2);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/techgig/CodeGladiator2019a.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | class CandidateCode{
3 | public static final Scanner cin=new Scanner(System.in);
4 | public static void main(String[] args){
5 | int t=cin.nextInt();
6 | while(t!=0){
7 | int n=cin.nextInt();
8 | gameBlock(n);
9 | t--;
10 | }
11 | }
12 | public static void gameBlock(int n){
13 | int[] st=new int[n];
14 | int[] en=new int[n];
15 | for(int i=0;i=st[i]){
30 | count++;
31 | }
32 | }
33 | if(count==n){
34 | System.out.println("WIN");
35 | }
36 | else{
37 | System.out.println("LOSE");
38 | }
39 | }
40 |
41 | }
42 |
43 |
--------------------------------------------------------------------------------
/timusJudge/reverseRoot.java:
--------------------------------------------------------------------------------
1 | import java.util.Scanner;
2 | import java.util.ArrayList;
3 | import java.text.DecimalFormat;
4 | public class reverseRoot{
5 | public static void main(String[] args){
6 | Scanner cin=new Scanner(System.in);
7 | DecimalFormat df=new DecimalFormat("0.0000");
8 | ArrayList arr=new ArrayList();
9 | while(cin.hasNextLong()){
10 | arr.add(cin.nextLong());
11 | }
12 | for(int i=arr.size()-1;i>=0;i--){
13 | System.out.println(df.format(Math.sqrt(arr.get(i))));
14 | }
15 | }
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/topcoder/784/250:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sauravjaiswalsj/Competitive-Programming/81aae2e43c484b21d2c495cd15d510a49771b92f/topcoder/784/250
--------------------------------------------------------------------------------
/topcoder/784/250.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | class Scissors{
4 | public:
5 | int openingTime(int N){
6 | int pair=1;
7 | int time=10;
8 | N=N-pair;
9 | pair=pair+1;
10 | for(int i=0;;i++){
11 | N=N-pair;
12 | pair+=2;
13 | time+=10;
14 | if(N<=pair && N!=0){
15 | time+=10;
16 | break;
17 | }
18 | if(N==0){
19 | break;
20 | }
21 | }
22 | return time;
23 | }
24 | };
25 |
26 | int main(void){
27 | int n;
28 | Scissors *p = new Scissors();
29 | std::cin>>n;
30 | int t=p->openingTime(n);
31 | std::cout<
2 | #include
3 | class LCMRange{
4 | public:
5 | int lcm(int f, int l){
6 | int lcm=1;
7 | for(int i=f;i<=l;i++){
8 | lcm=lcm*(i/gcd(lcm,i));
9 | }
10 | return lcm;
11 | }
12 | int gcd(int a,int b){
13 | while(b>0){
14 | int t=b;
15 | b=a%b;
16 | a=t;
17 | }
18 | return a;
19 | }
20 | };
21 | int main(){
22 | int f,l;
23 | std::cin>>f>>l;
24 | LCMRange *get =new LCMRange();
25 | std::cout<lcm(f,l);
26 | return 0;
27 | }
28 |
--------------------------------------------------------------------------------
/topcoder/chess.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | using namespace std;
4 |
5 | class BrokenChessboard{
6 | public:
7 | int minimumFixes(char* p){
8 | int count,sum;
9 | char *ptr=p;
10 | while(*ptr!='\0'){
11 | count=0;
12 | if(*ptr=='B'){
13 | if(*ptr++=='W'){
14 | *ptr++;
15 | }
16 | else
17 | {
18 | count++;
19 | *ptr++;
20 | }
21 | sum=count;
22 | }
23 | }
24 | return sum;
25 | }
26 | };
27 | int main(){
28 | char str[50];
29 | cin>>str;
30 | BrokenChessboard b;
31 | int k=b.minimumFixes(str);
32 | cout<
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/uva/900.java:
--------------------------------------------------------------------------------
1 | // Fibnocci Secquence
2 | import java.util.Scanner;
3 |
4 | class BrickWallPatterns{
5 | public static void main(String[] args){
6 | Scanner cin =new Scanner(System.in);
7 | int n;
8 | while((n=cin.nextInt())!=0){
9 | System.out.println(getWallLength(n));
10 | }
11 | }
12 | private static long getWallLength(int n){
13 | if(n==1) return 1;
14 | if(n==2) return 2;
15 | long a=1;
16 | long b=2;
17 | long sum=0;
18 | for(int i=3;i<=n;i++){
19 | sum=a+b;
20 | a=b;
21 | b=sum;
22 | }
23 | return sum;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------