Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
sid-am-ahd935 authored Oct 26, 2022
2 parents 382fecf + 45aad00 commit 26fb8a7
Show file tree
Hide file tree
Showing 27 changed files with 1,589 additions and 1 deletion.
25 changes: 25 additions & 0 deletions C++/Pascal Triangle Pattern/Pascal Triangle Pattern.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <iostream>

using namespace std;

int main()
{
int n;
cout<<"Enter the no. of Rows: ";
cin>>n;
for(int i=0;i<n;i++)
{
int num=1;
for(int j=0;j<n-i;j++)
{
cout<<" ";
}
for(int k=0;k<=i;k++)
{
cout<<num<<" ";
num=num*(i-k)/(k+1);
}
cout<<endl;
}
return 0;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added C++/Pascal Triangle Pattern/temp.exe
Binary file not shown.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletions Java/Multiple Swapping Methods/swap.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import java.util.*;

class Swap {

public static void main(String args[]) {
Scanner sc = new Scanner (System.in);

System.out.println("Select the method of swapping two numbers.");
System.out.println("\t 1. Press 1 for + & - method.");
System.out.println("\t 2. Press 2 for * & / method.");
System.out.println("\t 3. Press 3 for XOR method.");
System.out.println("\t 4. Press 4 for single statement method.");
System.out.println("Enter your choice: ");
int choice = sc.nextInt();

int a,b;
System.out.println("Enter 1st no. A:");
a = sc.nextInt();
System.out.println("Enter 2nd no. B:");
b = sc.nextInt();

switch(choice) {
// + & - method
case 1: a=a+b;
b=a-b;
a=a-b;
System.out.println("result: "+a+" "+b);
break;
// * & / method
case 2: a=a*b;
b=a/b;
a=a/b;
System.out.println("result: "+a+" "+b);
break;
// XOR method
case 3: a=a^b;
b=a^b;
a=a^b;
System.out.println("result: "+a+" "+b);
break;

// single statement method
case 4: b=a+b-(a=b);
System.out.println("result: "+a+" "+b);
break;

default:System.out.println("Invalid choice");
break;

}

}


}
4 changes: 4 additions & 0 deletions Java/Sec min & min array/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This solution is done using best-case time complexity - O(logn) and the worst case time complixity is O(n) which is
# done by linear search

-- THE SOLUTION IS DONE USING DIVIDE AND CONQUER TECHNIQUE
76 changes: 76 additions & 0 deletions Java/Sec min & min array/sec_min.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/* This solution is done using best-case time complexity - O(logn) and the worst case time complixity is O(n) which is
done by linear search
THE SOLUTION IS DONE USING DIVIDE AND CONQUER TECHNIQUE
*/

import java.util.Scanner;

public class Sec_Min {

public static int[] secmin(int [] arr,int left, int right) {

int min;
int sec;
if(left == right)
{
sec = arr[left];
min = arr[left];
}

else if(left+1 == right)
{
if (arr[left] < arr[right])
{
sec = arr[right];
min = arr[left];
}
else
{
sec = arr[left];
min = arr[right];
}
}
else
{
// Divide the array in two same segments, afterthat conquer the segments to get the solution
int mid = (right+left)/2;
int [] leftarr = secmin(arr, left, mid);
int [] rightarr = secmin(arr, mid+1, right);


if (leftarr[1] > rightarr[1])
{
min = rightarr[1];
sec = Math.min(leftarr[1], rightarr[0]);
}
else
{
min = leftarr[1];
sec = Math.min(rightarr[1], leftarr[0]);
}

}
int [] maxmin = {sec, min}; // the sec and min are stored in an array with index 0, 1
return maxmin;

}
public static void main(String[] args) {

Scanner sc = new Scanner(System.in);
System.out.print("Enter the size of array: ");
int n = sc.nextInt();
int [] array = new int[n];
for(int i=0; i<n; i++)
{
System.out.print("Enter the element - " + (i+1) + ": ");
array[i] = sc.nextInt();
}

int [] res = secmin(array, 0, n-1);
System.out.println("Minimum in array is: " + res[1] + "\n" + "Second Minimum in array is: " + res[0]);


}
}
// thank you for visiting the problem
88 changes: 88 additions & 0 deletions Java/Simple Calculator/Calculator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@


import java.util.*;

class Calculator{

public static void main(String args[]){
Scanner sc = new Scanner(System.in);

System.out.println("Simple calculator.");
System.out.println("\t 1. Press 1 for Addition.");
System.out.println("\t 2. Press 2 for Subtraction.");
System.out.println("\t 3. Press 3 for Multiplication.");
System.out.println("\t 4. Press 4 for Division.");
System.out.println("\t 5. Press 5 for Remainder.");
System.out.println("Enter your choice: ");
int choice = sc.nextInt();

int a=0,b=0,r=0;
if(choice <6 && choice >0){
System.out.println("Enter 1st no. A:");
a=sc.nextInt();
System.out.println("Enter 2nd no. B:");
b=sc.nextInt();
}

if(choice==1) //For Addition
{
r=a+b;
System.out.println("Addition Result : "+r);
}
else if(choice==2) //For Subtraction
{
r=a-b;
System.out.println("Subtraction Result : "+r);
}
else if(choice==3) // For Multiplication
{
r=a*b;
System.out.println("Multiplication Result : "+r);
}
else if(choice==4) // For Division
{
if(b==0){

if(a==0){

System.out.println("invalid");

}
else{

System.out.println("infinite");
}
}
else
{
r=a/b;
System.out.println("Division Result : "+r);
}
}
else if(choice==5) // For Rmainder
{
if(b==0){

if(a==0){

System.out.println("invalid");

}
else{

System.out.println("infinite");
}
}
else
{
r=a%b;
System.out.println("Remainder: "+r);
}

}
else{
System.out.println("invalid choice");
}
}

}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 62 additions & 0 deletions JavaScript/SnakeGame/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
@import url('https://fonts.googleapis.com/css2?family=New+Tegomin&display=swap');
*{
padding: 0;
margin: 0;
}

.body{
background: url("../img/bg.jpg");
min-height: 100vh;
background-size: 100vw 100vh;
background-repeat: no-repeat;
display: flex;
justify-content: center;
align-items: center;
}

#scoreBox{
position: absolute;
top: 9px;
right: 200px;
font-size: 39px;
font-weight: bold;
font-family: 'New Tegomin', serif;
}

#hiscoreBox{
position: absolute;
top: 59px;
right: 140px;
font-size: 39px;
font-weight: bold;
font-family: 'New Tegomin', serif;
}

#board{
background: linear-gradient(rgb(170, 236, 170), rgb(236, 236, 167));
width: 90vmin;
height: 92vmin;
border: 2px solid black;
display: grid;
grid-template-rows: repeat(18, 1fr);
grid-template-columns: repeat(18, 1fr);
}

.head{
background: linear-gradient(rgb(240, 124, 124), rgb(228, 228, 129));
border: 2px solid rgb(34, 4, 34);
transform: scale(1.02);
border-radius: 9px;
}

.snake{
background-color: purple;
border: .25vmin solid white;
border-radius: 12px;
}

.food{
background: linear-gradient(red, purple);
border: .25vmin solid black;
border-radius: 50%;
}
Binary file added JavaScript/SnakeGame/img/bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions JavaScript/SnakeGame/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SnakeGame by Hamid </title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="body">
<div id="scoreBox">Score: 0</div>
<div id="hiscoreBox">High Score: 0</div>
<div id="board"></div>
</div>
</body>
<script src="js/index.js"></script>
</html>
Loading

0 comments on commit 26fb8a7

Please sign in to comment.