Skip to content

Instantly share code, notes, and snippets.

@realsba
realsba / BinaryStream.js
Last active July 28, 2023 14:43
JS implementation of BinaryStream
export default class BinaryStream {
_offset = 0;
_dataview = null;
_uint8Array = null;
constructor(buffer) {
this._dataview = new DataView(buffer);
this._uint8Array = new Uint8Array(buffer);
}
@realsba
realsba / palindrom3.cpp
Created May 18, 2018 11:06
Find all palindromes made from the product of two 4-digit numbers
#include <fstream>
using Type = uint64_t;
bool isPalindrom(Type x)
{
Type tmp {x}, y {0};
while (tmp) {
y *= 10;
@realsba
realsba / palindrom2.cpp
Created May 17, 2018 12:43
Find all palindromes made from the product of two 4-digit numbers
#include <iostream>
#include <iomanip>
#include <unordered_set>
#include <vector>
#include <fstream>
using Type = uint32_t;
using Magic = std::vector<Type>;
using Numbers = std::unordered_set<Type>;
@realsba
realsba / palindrom1.cpp
Last active May 17, 2018 12:45
Find all palindromes made from the product of two 4-digit numbers
#include <iostream>
#include <iomanip>
#include <unordered_set>
#include <vector>
#include <fstream>
using Type = uint32_t;
using Magic = std::vector<Type>;
using Numbers = std::unordered_set<Type>;