English Page
Elementary Techniques | Techniques of Function | Techniques of Recursion |Techniques of Number

## Recycle numerical functions

### Sample Code 1

```a(X,T):XXa(sX,T-1)XX
a(a(,3)a(r,9)r,1)```

### Sample Code 2

```a(X,T):a(sX,T-1)XX
a(ra(r,6),100)```

## 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.

## Rational Growth

### Sample Code

```a(T):sa(T-5)
b(T):a(T)rb(T+7)
b(1)```

The speed of growth is "7/5".

## 12B method

### Sample Code

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

This code realizes the loop

```a:ssrsssrsssrsssra
a```

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

`f(T):f(T-A)f(T+B)`

implies a loop with (A+B) times of "" and B times of "".

### 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

```f(T):sf(T-15)rf(T+T+63)
f(1)```

Some new sequence can be obtained by changing the coefficient of degree = 1.
In this case, the periodic sequence

1,[5,5,6,7],[5,5,6,7],[5,5,6,7],...

appears.

## 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.

## Compress long statement by numbers

### Sample Code 1

```a(T,A):ra(T-A,A)
f(T):a(T,64)sa(T,16)sa(T,4)sa(T,1)s```

By f(1 to 255), you can make all patterns of four step move, except "ssss".

### Sample Code 2

```a(T,X):X
b(A,B,X):b(A-127,B,s)a(128-A,Xb(A+A,B-1,r))
f(T):b(T,8,r)```

All strings of length=8, made of "s" and "r" can be made by f(1 to 255), but for "srrrrrrr" ans "rrrrrrrr".

### Sample Code 3

```a(T,X):X
b(A,B):lb(A-81,B)a(82-A,llsb(A+A+A,B-1))
f(T):b(T,5)```

## Truncate a multiple recusion

### Sample Code 1

```f(X,T):rXf(f(sX,T-1),10)
f(,1)```

### Sample Code 2

```f(X,T):Xf(rf(sX,T-1),10)
f(,1)```

Last-modified: 2013-02-13 (水) 23:43:58 (2658d)