Skip to content

Instantly share code, notes, and snippets.

View tuankiet65's full-sized avatar

Kiet Ho tuankiet65

View GitHub Profile
@tuankiet65
tuankiet65 / chess-player.pas
Last active December 10, 2015 16:28
A chess player for Pascal.
{This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
@tuankiet65
tuankiet65 / ron.pas
Created January 8, 2013 07:14
Giải bài toán sau: Rôn rất thích khảo sát tìm hiểu các dãy số. Có một hôm Rôn ngồi viết một cách ngẫu nhiên bốn số nguyên dương w, x, y, z và sau đó dành mọi thời gian rãnh của mình để xây dựng dãy số A = (a1, a2, . . ., an, . . .), trong đó: • a1 = w, • ai = (xai-1+y) mod z với i > 1. Rôn rất tự hào là đã viết được n số của dãy do mình tạo ra v…
{Copyright Ho Tuan Kiet@tuankiet65@gmail.com; GNU GPL 3.0}
program ron;
uses crt;
var a: array[1..4000000] of int64;
w, x, y, z, k, i, i2, tg: longint;
begin
clrscr;
write('Nhap w: ');
readln(a[1]);
write('Nhat x: ');
@tuankiet65
tuankiet65 / mod10.pas
Created January 8, 2013 11:37
Check if a credit card number is valid using Luhn algorithm
{This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
@tuankiet65
tuankiet65 / 99bottlesofbeer.pas
Last active December 10, 2015 19:48
99 bottles of beer program
{This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
@tuankiet65
tuankiet65 / beautifulstrings-sampleinput.txt
Last active December 11, 2015 19:28
Facebook Hacker Cup 2013 - Beautiful Strings
5
ABbCcc
Good luck in the Facebook Hacker Cup this year!
Ignore punctuation, please :)
Sometimes test cases are hard to make up.
So I just go consult Professor Dalves
program music;
uses crt;
var n, author, tone, path, tmp: string;
t: text;
hz, time, i: longint;
begin
clrscr;
write('Enter input path: ');
readln(path);
assign(t, path);
@tuankiet65
tuankiet65 / vi.wiki_dumps_download.sh
Created February 16, 2013 15:36
vi.wiki dumps download
mkdir viwikipedia
cd viwikipedia
echo "========================================================================"
echo "======================== viwiki dumps download ========================="
echo "========================================================================"
wget -r -np -nH -R "viwiki-latest-pages-meta-history.xml.bz2" http://dataset2.wikimedia.org/viwiki/latest/
@tuankiet65
tuankiet65 / ttt_1.pas
Last active December 14, 2015 19:08
Nhập vào 1 số nguyên dương n. xuất ra tất cả các số có n chữ số
program bt1;
uses crt;
var n: longint;
i, b, e: int64;
begin
clrscr;
write('Nhap n: ');
readln(n);
b:=1;
e:=b*10-1;
@tuankiet65
tuankiet65 / bt2.pas
Last active December 14, 2015 21:19
Nhập vào một số nguyên dương n. tính tổng của các chữ số là số nguyên tố của n.
program bt2;
uses crt;
var n: int64;
tong, nchr: longint;
begin
clrscr;
write('Nhap n: ');
readln(n);
while n<>0 do begin
nchr:=n mod 10;
@tuankiet65
tuankiet65 / bt3.pas
Created March 18, 2013 12:47
Cho dữ liệu trong file input.txt gồm số dòng không rõ, đảo ngược các dòng và xuất ra file ketqua.txt
program string_reverse;
uses crt;
var t, tout: text;
s, s2: widestring;
i: longint;
begin
clrscr;
assign(t, './input.txt');
reset(t);
assign(tout, './ketqua.txt');