Skip to content

Instantly share code, notes, and snippets.

Let's classify all the possible equilateral triangles of interest. As there are more equilateral triangles in the proof, let's call those we want to count the counting triangles.

For each of the counting triangle asked, define its enclosing triangle be the minimal upright equilateral triangle that goes alone the network. Here, upright means the triangle has one side being horizontal, and the third vertex is above the horizontal side. Later in the text, the term upside-down will appear, meaning the opposite of upright, ie. one side being horizontal but the third vertex is below the horizontal side.

For example, here are some counting triangles (red) and their enclosing triangle (blue). The second counting triangle is upside-down.

Image1

We classify counting triangles by the side length of its enclosing triangle, as this directly related to how many these triangles are there in the original network. If the network has side N, we can find the number of ways

@progheal
progheal / KingChicken.md
Last active June 18, 2016 13:14
Proper solution of the challenge `KingChicken`: https://codefights.com/challenge/3vZaAk4SrnfoHgr9C

For odd number of students, it's easy to construct a situation that all of them are king chicken:
Label them from 1 to n, every one pecks the (n-1)/2 students numbered after him (labels wrap around from n to 1).
In this case, for every people, those (n-1)/2 students pecked him is pecked by the last people he pecked.
For example, for 7 students (Test 4),
Student 1 pecks Student 2,3,4, and Student 4 pecks Student 5,6,7, make Student 1 king chicken;
Student 2 pecks Student 3,4,5, and Student 5 pecks Student 6,7,1, make Student 2 king chicken;
etc.

For even number of students, things get interesting:
n=2 is impossible for both of them to be king; one must peck the other.

@progheal
progheal / colouringThePlane.md
Last active June 15, 2016 16:58
Proof of the challenge `colouringThePlane`

We'll prove that the number of color needed for input n is ceiling((n-1)^2/2), ie. this OEIS sequence with offset 1.

First we prove that this number is needed. To satisfy the condition, a square color should be different from all other squares in a specific range related to n. This range is the union of all retangles containing the initial square, and is a diamond shape centered at this square. For example, n=5 corresponding to this diamond shape:

@progheal
progheal / MCIMEpatch.py
Last active October 21, 2015 16:47
Minecraft CJK-IME patchfile generator
#!/usr/bin/env python3
# encoding=UTF-8
# Minecraft CJK-IME patchfile generator (Minecraft 中文輸入更新檔產生程式) by LPH66 @ PTT (Minecraft IGN: proghealer)
#
# Version 0.6 probably final (2015/10/22)
#
# 適用範圍:Minecraft 1.6.4 ~ 1.8.8;但 snapshot/prerelease 版本不一定適用。
#
# 系統需求: python 3.x 執行環境。(關於 python 環境安裝等事項可至 python 官方網站查詢:https://www.python.org/ )