Skip to content

Instantly share code, notes, and snippets.

View mertcanekiz's full-sized avatar

Mertcan Ekiz mertcanekiz

View GitHub Profile
a=input
i=int
s=i(a())
d=i(a())
print(f'{i((s+d+1)/2)}\n{i((s-d)/2)}')
/*
* linux/kernel/fork.c
*
* Copyright (C) 1991, 1992 Linus Torvalds
*/
/*
* 'fork.c' contains the help-routines for the 'fork' system call
* (see also entry.S and others).
* Fork is rather simple, once you get the hang of it, but the memory
using System;
using System.Collections;
public abstract class IntSeq : IEnumerable
{
public abstract int Size { get; set; }
public abstract void clear();
public abstract void unshift(int item);
public abstract int shift();
function map(n, start1, stop1, start2, stop2) {
return ((n-start1)/(stop1-start1))*(stop2-start2)+start2;
}
function scovilleToLevel(scoville) {
let log = Math.log10(scoville);
return map(log, 0, 6, 1, 11); // 6 because Math.log10(1000000)=6
}
def pentagonal(n):
return n * (3 * n - 1) // 2
@lru_cache(maxsize=None)
def generalized_pentagonal(n):
if n == 0:
return pentagonal(0)
if n % 2 == 0:
return pentagonal(-n // 2)
@mertcanekiz
mertcanekiz / triple.py
Created January 15, 2018 02:06
Python code for generating Pythagorean triples with given perimeter
def gen_pythagorean_triple(p, primitive=True):
mlimit = int((p/2)**0.5)+1
for m in range(2, mlimit):
if (p//2) % m == 0:
if m % 2 == 0:
k = m + 1
else:
k = m + 2
while k < 2*m and k <= p // (2*m):
if p // (2*m) % k == 0 and gcd(k, m) == 1:
@mertcanekiz
mertcanekiz / fonts.conf
Created October 4, 2015 07:31
Mac-like font rendering for Linux
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<match target="font">
<edit mode="assign" name="rgba">
<const>rgb</const>
</edit>
</match>
<match target="font">
<edit mode="assign" name="hinting">
@mertcanekiz
mertcanekiz / touchpad.sh
Created October 2, 2015 22:20
Script for enabling/disabling Synaptics Touchpad
#!/bin/bash
tpid=`xinput list | grep SynPS | sed 's/.*id\=\([0-9]\+\).*/\1/g'`
declare -i status
status=`xinput list-props ${tpid} | grep Device\ Enabled | sed -e 's/.*\:[ \t ]\+//g'`
if [ 0 -eq ${status} ] ; then
xinput enable ${tpid}
else
package com.teddygaming.engine;
import java.util.ArrayList;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import com.teddygaming.engine.math.vec2;
public class Input
{