Skip to content

Instantly share code, notes, and snippets.

//solution2("...xxx..x....xxx.", 7);
//solution("aaAbcCABBc");
static int solution2(string S, int B)
{
if (B < 2 || S.Length == 0)
return 0;
var potholes = new List<int>();
var count = 1;
@Ilchert
Ilchert / U8File.cs
Last active January 11, 2024 01:39
using System.Buffers;
using System.IO.Pipelines;
using System.Runtime.CompilerServices;
using U8;
using U8.InteropServices;
namespace _1brc
{
internal class U8File
{
// See https://aka.ms/new-console-template for more information
using System.Buffers;
using System.Buffers.Binary;
using System.Buffers.Text;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Text;
using System.Threading.Channels;
var filePath = @"C:\projects\local\1brc-main\measurements.txt";
// See https://aka.ms/new-console-template for more information
using System.Buffers.Binary;
using System.Buffers.Text;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Text;
var filePath = @"C:\projects\local\1brc-main\measurements.txt";
// See https://aka.ms/new-console-template for more information
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddSingleton<Service>();
@Ilchert
Ilchert / read14.cs
Last active October 10, 2023 21:05
// See https://aka.ms/new-console-template for more information
using System.Buffers.Binary;
var data = new byte[] {
100,
100,100,10,10,
11,11,11,11,
12,00,
4,
4,
@Ilchert
Ilchert / LayoutConHost.cs
Last active August 12, 2023 18:36
Conhost console search
// See https://aka.ms/new-console-template for more information
using System.Diagnostics;
using System.Runtime.InteropServices;
while (true)
{
var process = Process.GetCurrentProcess();
ulong cohost = 0;
int status;
status = NtQueryInformationProcess(process.Handle, 0x31, ref cohost, Marshal.SizeOf(typeof(ulong)), out _); // cohost
@Ilchert
Ilchert / FindLayout.cs
Created August 12, 2023 18:14
Find layout from console
using System.Diagnostics;
using System.Runtime.InteropServices;
while (true)
{
var pbi = new ParentProcessUtilities();
var process = Process.GetCurrentProcess();
int status;
while (true)
{
@Ilchert
Ilchert / TypeMagic.cs
Created July 16, 2023 09:16
TypeMagic.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
var data = new Bar(1, new Foo(2));
var d = new Derive_SumEverything<Bar>();
using System.Security.Cryptography;
using System;
using System.Text.Json;
using System.Text.Json.Serialization.Metadata;
var a = new A { ModeA = "A", ModeB = "B" };
JsonSerializerOptions optionsA = new()
{
TypeInfoResolver = new DefaultJsonTypeInfoResolver