Skip to content

Instantly share code, notes, and snippets.

View Alexandre-cibot's full-sized avatar

Alexandre Cibot Alexandre-cibot

View GitHub Profile
@Alexandre-cibot
Alexandre-cibot / islands.js
Created August 31, 2022 10:16
Challenge to get nb of islands present on a map.
// Land is represented as #
// water is -
// Land that connected on at least one side with another land belongs to the same island.
// Get the count of islands.
const map1 = `
------
--###-
---##-
// Crack caesard encoded sentences.
// By find which letter is E.
// E is letter the most used in french.
function crack(caesarCode) {
const matrix = {};
const caesarCodeArray = caesarCode.toUpperCase().split('')
caesarCodeArray.filter(e => e !== " ").forEach(e => {
if(matrix[e]) {
matrix[e] += 1
} else {
@Alexandre-cibot
Alexandre-cibot / cipher.js
Created February 19, 2021 14:09
Vigenère cipher - Clash of Code
// Vigenère cipher
// https://en.wikipedia.org/wiki/Vigen%C3%A8re_cipher
// Created for a Clash Of Code
// doesnt respect case. screw it.
function encrypt(text, code) {
text = text.toLowerCase();
code = code.toLowerCase();
const alpha = [..."abcdefghijklmnopqrstuvwxyz".repeat(2)];
let output = "";
let key = code;
@Alexandre-cibot
Alexandre-cibot / app.js
Created January 11, 2021 22:56
Tic Tac Toe
// Initialize variables
const FIRST_PLAYER = 'x'
const SECOND_PLAYER = 'o'
let currentPlayer = FIRST_PLAYER
let running = true
let grid = []
startGame()
function startGame() {
running = true
@Alexandre-cibot
Alexandre-cibot / settings.json
Last active August 30, 2022 20:53
VsCode preferences (06/2020)
{
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/*/**": true
},
"editor.formatOnSave": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
class ArrayNb extends Array {
constructor(props) {
!!props ? super(props) : super();
}
push(...elements) {
if ( [...elements].every(e => typeof e === "number") ){
return super.push(...elements);
} else {
throw new Error("ArrayNb can only store numbers");
}
@Alexandre-cibot
Alexandre-cibot / bubbleSort.js
Last active January 18, 2019 10:21
Bubble sort
function bubbleSort(array) {
let res = [...array];
let status = new Array(res.length - 2).fill(false);
while (!status.every(e => e === true)) {
for (let i = 0; i < res.length - 1; i++) {
if (res[i] > res[i + 1]) {
// swap values
let temp = res[i];
res[i] = res[i + 1];
res[i + 1] = temp;
// Placez vos paramètres dans ce fichier pour remplacer les paramètres par défaut
{
// Use ZSH as the integrated terminal shell
"terminal.integrated.shell.osx": "zsh",
"workbench.colorTheme": "Atom One Dark",
"editor.tabSize": 2,
"window.zoomLevel": 1,
// "sublimeTextKeymap.promptV3Features": true,
"gitlens.advanced.messages": {
"suppressCommitHasNoPreviousCommitWarning": false,