IF statement

Sample Code 1

a(T):rsrrsr
b(T):a(2-T)b(T-5)
c(T):b(T)sc(T-1)
c(20)

In this code, b(T) equals "rsrrsr" if T≡1 mod 5, and no moves otherwise.

Examples

Rational Growth

Sample Code

Examples

12B method

Sample Code

f(T):sf(T-4)rf(T+7)
f(8)

This code realizes the loop

a:ssrsssrsssrsssr
a

In this loop, the number of "s" equals 4 + 7, and the number of "r" equals 7.
In generally, the code

f(T):[1]f(T-A)[2]f(T+B)

implies a loop with (A+B) times of "[1]" and B times of "[2]".

Sample Code 2

a(T):sa(T-37)ra(T+83)
a(1)

Since 83/37 approximately equals 9/4, this code is similar to

a(T):sa(T-4)ra(T+9)
a(1)

but the small difference changes the direction of the movement.
Therefore, "square minus square" shape can be drawn by a 12B code.

Sample Code 3

係数が1じゃないやつ

Examples

Random walk by a numerical function

Sample Code

f(T):sf(T-4)rf(T-7)
f(255)

Examples

Probably, no problems in HOJ requires this method (even for "best solution") at this moment.


トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS