Skip to content

Instantly share code, notes, and snippets.

View nsmaciej's full-sized avatar
🙂
o awen pona

Maciej Goszczycki nsmaciej

🙂
o awen pona
View GitHub Profile
@nsmaciej
nsmaciej / settings.jsonc
Last active June 13, 2022 15:47
VSCode Settings
{
// Python.
"jupyter.askForKernelRestart": false,
"python.formatting.provider": "black",
"[python]": {
"editor.rulers": [88]
},
// C/C++.
"C_Cpp.clang_format_fallbackStyle": "LLVM",
@nsmaciej
nsmaciej / tic_tac_toe.py
Last active January 1, 2020 15:58
Tic-tac-toe game
# Maciej Goszczycki 2019
# Human is always True. We invert the board when drawing to show the right symbol.
from functools import lru_cache
import random
import re
def colour(colour, text):
return f"\033[{30 + colour}m{text}\033[0m"
@nsmaciej
nsmaciej / solution.py
Created December 30, 2019 13:37
Best Tic-tac-toe starting position
from functools import lru_cache
def straight(board, i):
return (
board[i][0] == board[i][1] == board[i][2] is not None
or board[0][i] == board[1][i] == board[2][i] is not None
)
from collections import defaultdict, Counter
import pprint
def encode(x, known):
seen_vowels = {}
seen_other = {}
def check(seen, x, m):
if x in known:
#include <cstdio>
#include <vector>
#define inline __attribute__((always_inline))
namespace {
template <typename Iterator, typename Value, typename Checker>
class EasyIterator {
public:
@nsmaciej
nsmaciej / vimrc.vim
Last active August 19, 2020 11:51
Configs
function! SetIndention(width) abort
let &l:tabstop=a:width
let &l:shiftwidth=a:width
let &l:softtabstop=a:width
endfunction
filetype plugin indent on
set nowrap
set hidden
set showcmd
@nsmaciej
nsmaciej / index.html
Created February 26, 2018 16:56
Assignment 1
<!doctype html>
<html>
<head>
<title>Student Assigments</title>
<style>
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
/* ____ _ ____
* / __ )_________ _(_)___ _________ _/ / /
* / __ / ___/ __ `/ / __ \/ ___/ __ `/ / /
* / /_/ / / / /_/ / / / / / /__/ /_/ / / /
* /_____/_/ \__,_/_/_/ /_/\___/\__,_/_/_/
*
* Copyright 2017 Maciej Goszczycki
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@nsmaciej
nsmaciej / dns.rs
Last active March 6, 2017 21:19
Simple DNS Server
extern crate futures;
extern crate tokio_core;
extern crate byteorder;
extern crate itertools;
use std::io::prelude::*;
use std::net::{SocketAddr, IpAddr};
use std::io::{self, Cursor, Error, ErrorKind};
use byteorder::{ReadBytesExt, WriteBytesExt};
@nsmaciej
nsmaciej / scrabble.rs
Created March 2, 2017 14:08
Scrabble solver in Rust
use std::io::{self, BufReader};
use std::fs::File;
use std::cmp::Ord;
use std::io::prelude::*;
fn main() {
// Read the input
let mut word = String::new();
print!("Enter your letters: ");
io::stdout().flush().unwrap();