Skip to content

Instantly share code, notes, and snippets.

SELECT language, COUNT(*) AS lang_count FROM submissions GROUP BY language;
SELECT nickname FROM players WHERE TIMESTAMPDIFF(YEAR, birth, NOW()) = 25;
WITH distinct_submissions AS (
SELECT DISTINCT user_id, problem_id FROM submissions
)
SELECT players.nickname, COUNT(distinct_submissions.problem_id) AS problems_attempted
FROM distinct_submissions
INNER JOIN players ON players.user_id = distinct_submissions.user_id
#pragma GCC optimize ("Ofast")
#include <algorithm>
#include <chrono>
#include <fstream>
#include <iostream>
#include <iterator>
#include <ostream>
#include <string>
#include <vector>
function stringMultiply(x, y) {
if (x === '0' || y === '0') {
return '0';
}
if (x === '1') {
return y;
}
if (y === '1') {
@mjeanroy
mjeanroy / arrayDiff.js
Last active December 3, 2020 13:58
Cassidoo #172
function arrayDiff(array, diff) {
const size = array.length;
if (size === 0) {
return 0;
}
const map = new Map();
for (let i = 0; i < size; ++i) {
const value = array[i];
if (!map.has(value)) {
@mjeanroy
mjeanroy / levenshtein.js
Created June 14, 2019 10:25 — forked from andrei-m/levenshtein.js
Levenshtein distance between two given strings implemented in JavaScript and usable as a Node.js module
/*
Copyright (c) 2011 Andrei Mackenzie
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE