Skip to content

Instantly share code, notes, and snippets.

View komori-n's full-sized avatar

Toshinori Tsuboi komori-n

View GitHub Profile
import itertools
from ortools.sat.python import cp_model
BOARD_SIZE = 9
WIDTH = HEIGHT = BOARD_SIZE
PIECETYPES = ['p', 'n', 's', 'g', 'k', 'l', 'r', 'b', 'q', '_']
# 0:up, 1:down, 2:left, 3:right, 4:upleft, 5:upright, 6:downleft, 7:downright,
# 8:knightleft, 9:knightright
DI = [-1, 1, 0, 0, -1, -1, 1, 1, -2, -2]
DJ = [0, 0, -1, 1, -1, 1, -1, 1, -1, 1]
@komori-n
komori-n / molek-solitaire-solver.py
Created June 22, 2020 12:29
A MOLEK-SYNTEZ solitaire solver written in python
from copy import deepcopy
from random import shuffle
from queue import PriorityQueue
import time
import _pickle as cPickle
class Card():
TEXT2NUM = {
"6": 6, "7": 7, "8": 8, "9": 9, "0": 10,
from copy import copy, deepcopy
import pickle
import timeit
pickle_copy = lambda l: pickle.loads(pickle.dumps(l, -1))
case = 5
if case == 1:
## case 1: integer list
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
uint8_t event1(int32_t* param) {
uint8_t data = (uint8_t)*param;
printf("%"PRId8"\n", data);
}
#define A 0
#define B 1
#define CFG_1_MODE A
#define CFG_2_MODE B
#define CFG_3_MODE A
#define EXPAND(i) IMPL_TMP(CFG_##i##_MODE)(i)
#define IMPL_TMP(mode) IMPL_CAT(mode)
#define IMPL_CAT(mode) IMPL_##mode
#define A (1)
#define B ((uint8_t)2)
#define STRIP_PRN(x) IDENTITY x
#define IDENTITY(x) x
#define DELETE_BLOCK(x) DELETE_ARG x
#define DELETE_ARG(x)
STRIP_PRN(A)
DELETE_BLOCK(STRIP_PRN(B))
#include "komori/unique_function.hpp"
#include "gtest/gtest.h"
namespace {
constexpr const int kMagicNumber1 = 0x334;
constexpr const int kMagicNumber2 = 0x668;
int func1(void) {
return kMagicNumber1;
use std::env;
use serde_derive::Deserialize;
use anyhow::Result;
const EMAIL: &'static str = "ikamat.kmr@gmail.com";
const SUMMARY_URL:&'static str = "https://api.track.toggl.com/reports/api/v2/summary";
#[tokio::main]
async fn main() -> Result<()> {
let toggl_token = env::var("TOGGL_TOKEN")?;
// serde = "1.0"
// serde_derive = "1.0"
// serde_json = "1.0"
use serde::{Deserialize, Deserializer};
use serde_derive::Deserialize;
#[derive(Debug, Deserialize)]
struct Hoge {
#[serde(deserialize_with="deserialize_option")]
val: Option<u64>,
@komori-n
komori-n / main.rs
Last active July 25, 2021 13:29
nananiji-bot
use anyhow::Context as _;
use anyhow::Result;
use chrono::{FixedOffset, TimeZone, Utc};
use lambda_runtime::{error::HandlerError, lambda, Context};
use log::info;
use reqwest::{blocking::Client, header::CONTENT_TYPE};
use serde::{Deserialize, Serialize};
const NANANIJI_GENERATOR_URL: &'static str =
"https://xxxxxxxx.execute-api.ap-northeast-1.amazonaws.com/beta/";