Skip to content

Instantly share code, notes, and snippets.

// might work with compiler optimilization turned on, but better when disabled
#include <thread>
#include <iostream>
#include <string>
#include <Windows.h> // for Sleep()
typedef unsigned long long uint64;
constexpr int CPU_N = 4; // the more the longer it will wait (reduce n), 99+ will break the array
@lethern
lethern / day5.js
Last active December 5, 2018 05:42
var diff = 'a'.codePointAt(0) - 'A'.codePointAt(0);
var N = 'z'.codePointAt(0) - 'a'.codePointAt(0);
fs.readFile('05_input', 'utf8', function (err, _contents)
{
max = 1111111;
for (aa = 0; aa < N; ++aa) {
l = String.fromCodePoint(aa + 'a'.codePointAt(0));
l2 = String.fromCodePoint(aa + 'A'.codePointAt(0));
contents = _contents.replace(new RegExp(l, 'g'), '');
fs.readFile('07_input', 'utf8', function (err, _contents) {
let contents = _contents.split`\n`;
contents.splice(-1, 1);
let nodes = new Map();
for (row of contents) {
let from = row[5];
let to = row[36];
if (!nodes.get(from)) nodes.set(from, { edges: new Map() } );
#include <iostream>
const int ArrSize = 44;
struct ArrNode{
int size;
ArrNode* prev;
ArrNode* next;
int arr[ArrSize] = { 0 };
var fs = require('fs');
var diff = 'a'.codePointAt(0) - 'A'.codePointAt(0);
var N = 'z'.codePointAt(0) - 'a'.codePointAt(0);
fs.readFile('E:\\javascript\\AdventOfCode\\13_input', 'utf8', function (err, _contents)
{
let contents = _contents.split`\n`.map(c=>c.split``);
#include <list>
using namespace std;
list<int> A ={ 3,7 };
list<int>::iterator elf1 = A.begin();
list<int>::iterator elf2 = ++A.begin();
void move_A_iterator( list<int>::iterator & it, int steps ) {
while( steps-- ) {
@lethern
lethern / sql.sql
Created January 29, 2019 18:50
sqlsql
create table #CHANNEL(
pk [int] IDENTITY(1,1) NOT NULL,
ChannelNumber nvarchar(10) NULL,
DisplayName nvarchar(10) NULL,
ChannelID int NOT NULL,
PRIMARY KEY CLUSTERED (pk ASC)
)
endsWith = function (str, suffix) {
if (str.length < suffix.length)
return false;
var suff_i = suffix.length - 1;
var str_i = str.length - 1;
for (; suff_i >= 0;) {
if (str.charAt(str_i) != suffix.charAt(suff_i))
return false;
--suff_i;
--str_i;
/* To prevent any potential data loss issues, you should review this script in detail before running it outside the context of the database designer.*/
BEGIN TRANSACTION
SET QUOTED_IDENTIFIER ON
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
COMMIT
CLASSES.FIELD_BASIC_INPUT = function () { };
copy( CLASSES.FIELD_BASIC_INPUT,
[FIELD_BASIC_proto, FIELD_VALUE_proto, FIELD_DOM_proto, FIELD_BASIC_INPUT_proto]);
CLASSES.FIELD_BASIC_TEXTAREA = function () { };
copy( CLASSES.FIELD_BASIC_TEXTAREA,
[FIELD_BASIC_proto, FIELD_VALUE_proto, FIELD_DOM_proto, FIELD_BASIC_TEXTAREA_proto]);
CLASSES.FIELD_BASIC_LABEL = function () { };
copy( CLASSES.FIELD_BASIC_LABEL,