Skip to content

Instantly share code, notes, and snippets.

View machkouroke's full-sized avatar
🏠
Working from home

OKE Machkour machkouroke

🏠
Working from home
View GitHub Profile
@machkouroke
machkouroke / .scala
Created November 18, 2022 00:38
Test for Smart Calculator
import org.scalatest.funsuite.AnyFunSuite
class MainTest extends AnyFunSuite :
private val UNKNOWN_VARIABLE = "Unknown variable"
private val INVALID_IDENTIFIER = "Invalid identifier"
private val INVALID_ASSIGNMENT = "Invalid assignment"
test("Simple Operation") {
assert(Main.evaluator("4 + 4") == "8")
assert(Main.evaluator("+4") == "4")
@machkouroke
machkouroke / .scala
Created November 19, 2022 00:57
Test For scala Calculator
import org.scalatest.funsuite.AnyFunSuite
class MainTest extends AnyFunSuite :
private val UNKNOWN_VARIABLE = "Unknown variable"
private val INVALID_IDENTIFIER = "Invalid identifier"
private val INVALID_ASSIGNMENT = "Invalid assignment"
test("Simple Operation") {
assert(Main.evaluator("4 + 4") == "8")
assert(Main.evaluator("+4") == "4")
@machkouroke
machkouroke / build.gradle
Created January 27, 2023 22:04
Build config for web app in spring boot
plugins {
id 'java'
id 'org.springframework.boot' version '3.0.2'
id 'io.spring.dependency-management' version '1.1.0'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '19'
@machkouroke
machkouroke / index.jsp
Created March 21, 2023 11:13
Formulaire d'enrégistrement
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<head>
<title>Title</title>
<meta charset="UTF-8">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss.SSS").withZone(ZoneId.systemDefault());
String formatted date = formatter.format(this.date);
@machkouroke
machkouroke / Queen.jl
Last active April 14, 2023 15:44
N_queen problem in julia
struct Queen
x::Int
y::Int
end
function Base.show(io::IO, q::Queen)::Nothing
print(io, "Queen($(q.x), $(q.y))")
end
function same_line(q1::Queen, queens::Vector{Queen})::Int
include("./Queen.jl")
struct Chromosone
queens::Vector{Queen}
end
using Plots
include("Chromosone.jl")
function plot_chromosome(solution::Chromosone, n::Int64=8)::Plots.Plot
board = zeros(n, n)
for i in 1:n
for j in 1:n
if (i + j) % 2 == 0
board[i, j] = 1
end
end
function pop(vector::Vector{T}, element::T) where {T<:Any}
copy_vector = deepcopy(vector)
index = findfirst(==(element), vector)
if index !== nothing
deleteat!(copy_vector, index)
end
return copy_vector
end
function fitness(x::Chromosome)::Float64
function generate_solution(n::Int)::Chromosome
return [Queen(i, j) for (i, j) in enumerate(randperm(n))] |> Chromosome
end
function randpop(popsize::Int64, n::Int64)::Vector{Chromosome}
return [generate_solution(n) for _ in 1:popsize]
end