Skip to content

Instantly share code, notes, and snippets.

View youssef3wi's full-sized avatar

Aouichaoui Youssef youssef3wi

  • Kairouan, Tunisie
View GitHub Profile
@youssef3wi
youssef3wi / ascii-art.java
Created November 16, 2023 16:01
Ascii-art
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
public class CodingGame {
private static final int A = 'A';
private static final int Z = 'Z';
@youssef3wi
youssef3wi / quadratic_polynomial.java
Last active November 19, 2023 21:35
Quadratic Equation Calculator
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class CodingGame {
private static int getValueOfCoefficient(String value) {
if (value != null) {
if (value.isEmpty()) {
return 1;
} else if (value.equals("-")) {
@youssef3wi
youssef3wi / microorganisms.java
Created November 22, 2023 14:04
Several microorganisms of different families have been arranged next to each other. Knowing that a microorganism eats its neighbor if it is of a different family and smaller in size, write a program that returns the largest family and its size when the situation reaches an equilibrium.
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* Several microorganisms of different families have been arranged next to each other. Knowing that a microorganism eats its neighbor if it is of a different family and smaller in size, write a program that returns the largest family and its size when the situation reaches an equilibrium.
*
* <ul>
* Process:
* <li>Each microorganism belongs to a family, defined by a letter, and has a size, defined by an integer.</li>
@youssef3wi
youssef3wi / gist:d9cfb2679ef89beeaacb917dfa95162a
Created November 22, 2023 15:02
Sum digits of a string.
import static java.lang.Integer.parseInt;
public class CodingGame {
public static void main(String[] args) {
String number = "34267";
int result = 0;
int oddSum = 0;
for (int idx = 0; idx < number.length(); idx++) {
int digit = parseInt(number.charAt(idx) + "");
@youssef3wi
youssef3wi / README.md
Created December 11, 2023 18:06
SushiNori: Shift Scheduling

SushiNori: Shift Scheduling

SushiNori has a team of chefs to work its two chef stations. The chefs make requests to management for days they prefer to have off each week. You've been asked to determine whether it's possible to arrange the weekly schedule in such a way that all chefs will get to take their preferred days off while keeping the restaurant staffed.

SushiNori is open seven days a week. Each workday consists of two shifts of 8 hours each. There are restrictions on how many hours employees may work:

  • No employee may log more than 40 hours in a week.
  • No employee may exceed 5 days of work in a week.
  • No employee may work more than 8 hours in a day.
@youssef3wi
youssef3wi / package_sorting_system.ts
Created December 14, 2023 11:56
Pick the packages from the heaviest to the lightest one.
/**
* <p>
* Rules
* <p>
* You work in an automated factory that controls a robotic arm to move packages.
* The arm can pick packages from the conveyor belts to form a stack of packages.
* The packages are sorted from the heaviest to the lightest on each of the conveyor belts.
* Your objective is to pick the heaviest package among the 3 conveyor belts to move it on a stack.
* <p>
* Implement the function solve(weight0, weight1, weight2) that takes 3 integer arguments: weight0, weight1 and weight2.
@youssef3wi
youssef3wi / sort_the_packages.ts
Created December 14, 2023 14:39
Sort the packages using the robotic arm of the factory.
/**
* You work in an automated factory and your objective is to write the function that will dispatch the packages to the correct stack,
* according to their volume and mass.
* <p>
* - A package is <b>bulky</b> if its volume (Width x Height x Length) is greater than or equal to 1,000,000 cm³ or when one of
* its dimension is greater or equal than 150 cm.
* - A package is <b>heavy</b> when its mass is greater or equal than 20 kg.
* <p>
* You must dispatch the packages in the following stacks.
* - STANDARD: standard packages (those which are not bulky nor heavy) can be handled normally.
@youssef3wi
youssef3wi / approximate_pi.java
Created December 20, 2023 12:52
Calculate an approximate of π (Pi).
import java.util.ArrayList;
import java.util.List;
import static java.lang.Math.random;
/**
* In this exercise, we will calculate an approximate of π(Pi).
* <p>
* The technical is as follows:
* Take a random point P at coordinate (x, y) such that <code>0 <= x <= 1</code> and <code>0 <= y <= 1</code>.
@youssef3wi
youssef3wi / echanger_messages_secrets.java
Created December 20, 2023 20:41
Vous êtes enseignant et vous soupçonnez vos élèves d'échanger des messages secrets pendant vos cours.
import java.util.HashMap;
import java.util.Map;
/**
* Vous êtes enseignant et vous soupçonnez vos élèves d'échanger des messages secrets pendant vos cours.
* <p>
* Vous avez confisqué une feuille à Alice. Il semble qu'elle préparait un message pour son ami Bob.
* La première phrase de la feuille est en clair, la seconde est codée. La méthode semble être un chiffrement par substitution.
* Chaque lettre du texte en clair correspond toujours à la même lettre chiffrée. Par chaque, la phrase initiale contient toutes les lettres de l'alphabet,
* ce qui vous permet de déduire la correspondance complète des lettres.
@youssef3wi
youssef3wi / Kaido.java
Created January 21, 2024 17:00
Kaido has a precious chest with a number written on it.
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
/**
* Kaido has a precious chest with a number written on it. The chest has two keyholes.
* He also has a keychain with n keys on it. A number of labels each key.
* To unlock this chest, we need to insert two of his keys such as the labels on them sum up to the number written on the chest.
* Can you help to unlock this chest ?
* <p/>