Skip to content

Instantly share code, notes, and snippets.

View andot's full-sized avatar
🏠
Working from home

不帅任你踹 andot

🏠
Working from home
View GitHub Profile
@andot
andot / maxlen.go
Created September 30, 2014 06:52
给定一个query和一个text,均由小写字母组成。要求在text中找出以同样的顺序连续出现在query中的最长连续字母序列的长度。例如,query为"acbac",text为"acaccbabb",那么text中的"cba"为最长的连续出现在query中的字母序列,因此,返回结果应该为其长度3。
package main
import (
"fmt"
"strings"
)
func maxlen(query string, text string) (max int) {
max = 0
p := 0
@andot
andot / all_number.prolog
Last active August 29, 2015 14:05
计算123456789,所有3位数加法的组合。
all_number(Result) :-
Digit = [1, 2, 3, 4, 5, 6, 7, 8, 9],
member(A1, Digit),
member(A2, Digit),
member(A3, Digit),
member(B1, Digit),
member(B2, Digit),
member(B3, Digit),
member(C1, Digit),
member(C2, Digit),