Skip to content

Instantly share code, notes, and snippets.

@byyam
byyam / collatz_conjecture.cpp
Created October 24, 2019 14:38
collatz conjecture
#include <stdio.h>
#include <limits.h>
const int s = 30;
bool f(long i)
{
int r = 0;
for(;;)
if (i < 0 || r > s) return false;
else if (i == 1) break;

Keybase proof

I hereby claim:

  • I am byyam on github.
  • I am yamzzz (https://keybase.io/yamzzz) on keybase.
  • I have a public key ASASe_RhGfvyDxjLcBTJF_B0nKpx1vEwZ8ToJq9N5pKIlAo

To claim this, I am signing this object:

@byyam
byyam / memory-cache.go
Last active October 24, 2019 15:01
cache in memory
package main
import (
"fmt"
"sync"
"time"
"runtime"
)
type keyAndValue struct {
@byyam
byyam / interface-reflect.go
Created August 12, 2019 10:25
interface compare nil
package main
import (
"fmt"
"reflect"
)
type State struct{}
func testnil1(a, b interface{}) bool {
@byyam
byyam / gin-json-schema.go
Last active September 6, 2021 11:28
gin json schema
package main
import (
"fmt"
"bytes"
"strings"
"io/ioutil"
"net/http"
"github.com/gin-gonic/gin"
"github.com/xeipuuv/gojsonschema"
)
@byyam
byyam / printer.cpp
Created May 26, 2015 11:57
print a graph
// NOTE: compile with g++ filename.cpp -std=c++11
#include <stdio.h>
#include <cmath>
#include <cstdlib>
#include <time.h>
#define DIM 1024
#define DM1 (DIM-1)
#define _sq(x) ((x)*(x)) // square
#define _cb(x) abs((x)*(x)*(x)) // absolute value of cube