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 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") |
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 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") |
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
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' |
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
<%@ 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; | |
} |
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
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss.SSS").withZone(ZoneId.systemDefault()); | |
String formatted date = formatter.format(this.date); |
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
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 |
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
include("./Queen.jl") | |
struct Chromosone | |
queens::Vector{Queen} | |
end |
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
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 |
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
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 |
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
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 |
OlderNewer