Skip to content

Instantly share code, notes, and snippets.

<program> ::= <clause list> <query> | <query>
<clause list> ::= <clause> | <clause list> <clause>
<clause> ::= <predicate> . | <predicate> :- <predicate list>.
<predicate list> ::= <predicate> | <predicate list> , <predicate>
<predicate> ::= <atom> | <atom> ( <term list> )
<term list> ::= <term> | <term list> , <term>
<term> ::= <numeral> | <atom> | <variable> | <structure>
<structure> ::= <atom> ( <term list> )
<query> ::= ?- <predicate list>.
<atom> ::= <small atom> | ' <string> '
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <queue>
#include <cstring>
using namespace std;
#define MAXN 610
@kuoe0
kuoe0 / sudoku_solver.pl
Last active December 20, 2015 01:29
sudoku solver with Prolog
%=============================================================================
% FileName: sudoku_solver.pl
% Desc: sudoku solver
% Environment: Mac OS X 10.8.2, SWI-Prolog 6.2.6
% Usage: swipl -q -s sudoku_solver.pl
% Input: Enter all number in one line and seperate by one space. 0 denote the empty element.
% Output: Show all number in one line and seperate by one space.
% Author: KuoE0
% Email: kuoe0.tw@gmail.com
% HomePage: http://kuoe0.ch/
@kuoe0
kuoe0 / expr.lsp
Last active December 17, 2015 20:08
Common Lisp - Convert infix expression to postfix expression
#! /usr/bin/env sbcl --script
;;; Filename: expr.lsp
;;; Author: KuoE0 <kuoe0.tw@gmail.com>
;;; Description: Convert infix expression to postfix expression
;;;
;;; Distruted under terms of the BSD license.
; split string by one space
(defun split-by-space (str)
(let ((len (length str))
@kuoe0
kuoe0 / brew_version.sh
Last active December 16, 2015 10:38
install specific version formula with homebrew
#=============================================================================
# FileName: brew_version
# Desc: install specific version formula with homebrew
# Usage: brew_version <formula> <version> [param1 param2 ...]
# Author: KuoE0
# Email: kuoe0.tw@gmail.com
# HomePage: http://kuoe0.ch/
#=============================================================================
# /usr/bin/env bash
@kuoe0
kuoe0 / qround - c - Fair and Square.py
Created April 14, 2013 08:55
Google Code 2013 - Qualification Round - C - Fair and Square
#! /usr/local/bin/python
# -*- coding: utf-8 -*-
import math
palin = []
max_digit = 0
def isPalindrome( number ):
@kuoe0
kuoe0 / qround - b - Lawnmower.cpp
Created April 14, 2013 08:19
Google Code Jam 2013 - Qualification Round - B - Lawnmower
/*=============================================================================
# FileName: qround - b - Lawnmower.cpp
# Desc: Google Code Jam 2013 - Qualification Round - B - Lawnmower
# Author: KuoE0
# Email: kuoe0.tw@gmail.com
# HomePage: http://kuoe0.ch/
# Version: 0.0.1
# LastChange: 2013-04-14 16:17:59
# History:
=============================================================================*/
@kuoe0
kuoe0 / qround - a - Tic-Tac-Toe-Tomek.cpp
Last active December 16, 2015 05:08
Google Code Jam - Qualification Round - A - Tic-Tac-Toe-Tomek
/*=============================================================================
# FileName: qround - a - Tic-Tac-Toe-Tomek.cpp
# Desc: Google Code Jam - Qualification Round - A - Tic-Tac-Toe-Tomek
# Author: KuoE0
# Email: kuoe0.tw@gmail.com
# HomePage: http://kuoe0.ch/
# Version: 0.0.1
# LastChange: 2013-04-14 16:19:38
# History:
=============================================================================*/
/*=============================================================================
# FileName: quickSort.cpp
# Desc: Quick Sort
# Author: KuoE0
# Email: kuoe0.tw@gmail.com
# HomePage: http://kuoe0.ch/
# Version: 0.0.1
# LastChange: 2013-03-05 03:17:47
# History:
=============================================================================*/
/*=============================================================================
# FileName: mergeSort.cpp
# Desc: Natural Merge Sort
# Author: KuoE0
# Email: kuoe0.tw@gmail.com
# HomePage: http://kuoe0.ch/
# Version: 0.0.1
# LastChange: 2013-03-05 02:55:56
# History:
=============================================================================*/