graph TB
A((1, 2))-->B((2))
A-->C((3))
A-->D((4))
B-->E((5))
B-->F((6))
B-->G((7))
C-->H((8))
D-->I((9))
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
// Image of a telephone's keypad: https://upload.wikimedia.org/wikipedia/commons/thumb/7/73/Telephone-keypad2.svg/2880px-Telephone-keypad2.svg.png | |
// Problem: Given phone number, output all possible letter values or "words". | |
// Example: | |
// Input: 123-000 | |
// Output: 1ad-000 1ae-000 1af-000 1bd-000 1be-000 1bf-000 1cd-000 1ce-000 1cf-000 | |
// | |
// Example: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ## Dumb-dumb initial solution | |
using System; | |
using System.Threading.Tasks; | |
using System.Collections.Generic; | |
public class Program | |
{ | |
public static async Task Main() | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.fasterxml.jackson.databind.JsonNode; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
public class JsonParserIterator { | |
public static void main(String[] args) throws IOException { | |
String json = "{ \"fx\": [{ \"pk\": \"ALL=\" }, { \"pk\": \"EUR=\" }] }"; | |
ObjectMapper mapper = new ObjectMapper(); | |
JsonNode root = mapper.readTree(json); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Reflection.Emit; | |
using System.Diagnostics; | |
public class Program | |
{ | |
public static void Main() | |
{ | |
var con = typeof(B<int>).GetConstructors()[0]; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![allow(unused)] | |
fn main() { | |
use std::mem::{self, MaybeUninit}; | |
let data = { | |
// Create an uninitialized array of `MaybeUninit`. The `assume_init` is | |
// safe because the type we are claiming to have initialized here is a | |
// bunch of `MaybeUninit`s, which do not require initialization. | |
let mut data: [MaybeUninit<Vec<u32>>; 1000] = unsafe { | |
MaybeUninit::uninit().assume_init() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object obj; | |
var r = 0; | |
const int cnt = 1000000; | |
var constructorInfo = typeof(Class).GetConstructor(new[] { typeof(int) })!; | |
var hCtor = constructorInfo.MethodHandle; | |
RuntimeHelpers.PrepareMethod(RuntimeMethodHandle.FromIntPtr(hCtor.Value)); | |
var pCtor = (delegate* managed<object, int, void>)hCtor.GetFunctionPointer(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.IO.Pipelines; | |
using System.Net; | |
using System.Net.Security; | |
using Microsoft.AspNetCore.Connections; | |
using Microsoft.AspNetCore.Connections.Features; | |
using Microsoft.AspNetCore.Http.Features; | |
using Microsoft.AspNetCore.Server.Kestrel.Core; | |
var builder = WebApplication.CreateBuilder(args); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//live: https://scastie.scala-lang.org/dadhi/G2uzgCqXSbiav34bM602iw/68 | |
trait EntryFactory[K] { | |
def create(key: K): Entry[K] | |
} | |
object EntryFactory { | |
implicit def anyFactory[K]: EntryFactory[K] = | |
new EntryFactory[K] { | |
override def create(key: K) = KEntry(key, key.hashCode) |