Sunday, April 9, 2017
Saturday, April 8, 2017
Random Turtle Movement.
I use turtle module, the standard module, in Python.
The turtle movement has random direction (angle), and random distance (forward/backward).
import turtle
from random import uniform
turtle.shape("turtle")
turtle.speed(1)
for i in range (1,100):
#random angle
a = uniform (-90,90)
turtle.left(a)
#random move
d = uniform (-100,100)
turtle.forward(d)
turtle.exitonclick()
The Power of 10
Rules for Developing Safety-Critical Code:
Avoid complex flow constructs, such as goto and recursion.
All loops must have fixed bounds. This prevents runaway code.
Avoid heap memory allocation.
Restrict functions to a single printed page.
Use a minimum of two runtime assertions per function.
Restrict the scope of data to the smallest possible.
Check the return value of all non-void functions, or cast to void to indicate the return value is useless.
Use the preprocessor sparingly.
Limit pointer use to a single dereference, and do not use function pointers.
Compile with all possible warnings active; all warnings should then be addressed before release of the software.
Friday, April 7, 2017
Prime Number on Python
for i in range (2,200):
prime = True
for j in range (2,i):
if i%j==0:
prime=False
if prime==True:
print i
Prime Number on Delphi
if (i mod 2 <>0) and (i mod 3 <>0) and (i mod 5 <>0) and (i mod 7 <>0) then i is prime.
Don't use that.
That's just for prime number below 100.
Use this instead.
var i,j:integer;
prime:boolean;
begin
for i:=2 to 200 do begin
prime:=true;
for j:=2 to i-1 do begin
if i mod j=0 then prime:=false;
end;
if prime=true then memo1.Lines.Append(intToStr(i));
end;
end;
Wednesday, March 29, 2017
Rutinitas Sore.
Tuesday, March 21, 2017
Adonan.
Tak terbayangkan jika melakukan itu secara sengaja.
My sky is high, blue, bright and silent.
Nugroho's (almost like junk) blog
By: Nugroho Adi Pramono