This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A function that copies a 2D array in a spiral order | |
function spiralCopy(inputMatrix) { | |
// Initialize an empty array to store the result | |
let result = []; | |
// Define the boundaries of the matrix | |
let topRow = 0; | |
let bottomRow = inputMatrix.length - 1; | |
let leftCol = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ***************************************************************************** | |
* Name: Amr Musharrafa | |
* Last modified: December 19, 2023 | |
**************************************************************************** */ | |
public class Random { | |
public static void main(String[] args) { | |
int[] dataArray = new int[6]; | |
fillArraySequentially(dataArray); // Call the method to fill the array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Dice Simulation | |
* | |
* Overview: | |
* This Java program simulates the throwing of two six-sided dice, calculates the exact | |
* probabilities for each sum, and compares them with empirical results obtained through simulation. | |
* | |
* Calculation of Exact Probabilities: | |
* The code calculates the exact probabilities for the sum of two dice using a nested loop | |
* that considers all possible combinations of two dice rolls. The results are stored in the 'dist' array. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
import java.io.FileNotFoundException; | |
import java.util.Arrays; | |
import java.util.Scanner; | |
public class BruteForceSearch { | |
public static void main(String[] args) { | |
// Load data from files | |
int[] whitelist = loadData("largeW.txt"); |