n, p = input().split() n = int(n) p = float(p) PED_RADIUS = 0.007 SCALE_SIZE = 2.0 DT = 500 stddraw.setPenRadius(PED_RADIUS) # print(stddraw._DEFAULT_PEN_RADIUS) stddraw.setXscale(-SCALE_SIZE, SCALE_SIZE) stddraw.setYscale(-SCALE_SIZE, SCALE_SIZE) angle = 2 * math.pi / n while True: stddraw.clear(stddraw.WHITE) stddraw.setPenColor(stddraw.LIGHT_GRAY) for i in range(n): for j in range(i, n): if random.random() > p: continue x0 = math.cos(angle * i) y0 = math.sin(angle * i) x1 = math.cos(angle * j)
import math from pystdlib import stddraw as sd print("spiral") DIM = 30 IMAGE_SIZE = 1024 sd.setCanvasSize(IMAGE_SIZE, IMAGE_SIZE) sd.setXscale(-DIM, DIM) sd.setYscale(-DIM, DIM) sd.clear(sd.PINK) x = [0] y = [0] POINTS = 1000 delta_alpha = 6 * math.pi / POINTS for i in range(1, POINTS + 1): angle = i * delta_alpha x.append(angle * math.cos(angle)) y.append(angle * math.sin(angle)) sd.line(x[i - 1], y[i - 1], x[i], y[i]) sd.show()
from pystdlib import stddraw # Draw a bouncing ball to standard draw. RADIUS = .05 DT = 20.0 stddraw.setXscale(-1.0, 1.0) stddraw.setYscale(-1.0, 1.0) rx = .480 ry = .860 vx = .015 vy = .023 stddraw.clear(stddraw.WHITE) while True: stddraw.setPenColor(stddraw.WHITE) stddraw.filledCircle(rx, ry, RADIUS) stddraw.setPenColor(stddraw.BLACK) stddraw.circle(rx, ry, RADIUS) # Update ball position and draw it there. if abs(rx + vx) + RADIUS > 1.0: vx = -vx if abs(ry + vy) + RADIUS > 1.0: vy = -vy rx = rx + vx ry = ry + vy
nargs="?", default=10000, help="number of simulation moves. default: 10000", ) args = parser.parse_args() moves = args.moves # Ignore a string line. stdio.readLine() # Read size of the transition matrix. n = stdio.readInt() stddraw.setXscale(-0.5, n - 0.5) stddraw.setYscale(0, moves // 3) # p = [stdio.readFloat() for i in range(n) for j in range(n)] p = stdarray.create2D(n, n, 0) for i in range(n): for j in range(n): p[i][j] = stdio.readFloat() hits = stdarray.create1D(n, 0) # Start at page 0. page = 0 for i in range(moves): r = random.random() total = 0.0