fork download
  1. import math
  2.  
  3. # Parameters
  4. center_x = 0
  5. center_y = 20 # Simplified for terminal display
  6. radius = 10 # Simplified for terminal display
  7.  
  8. # Terminal size (width x height)
  9. width, height = 80, 40
  10.  
  11. # Initialize a grid
  12. grid = [[' ' for _ in range(width)] for _ in range(height)]
  13.  
  14. # Draw the circle
  15. for y in range(height):
  16. for x in range(width):
  17. # Translate grid coordinates to center coordinates
  18. dx = x - width // 2 + center_x
  19. dy = y - height // 2 - center_y
  20.  
  21. # Check if the point is on the circle
  22. distance = math.sqrt(dx**2 + dy**2)
  23. if abs(distance - radius) < 1:
  24. grid[y][x] = '*'
  25.  
  26. # Print the grid
  27. for row in grid:
  28. print(''.join(row))
  29.  
Success #stdin #stdout 0.02s 25732KB
stdin
Standard input is empty
stdout
import math

# Parameters
center_x = 0
center_y = 20  # Simplified for terminal display
radius = 10   # Simplified for terminal display

# Terminal size (width x height)
width, height = 80, 40

# Initialize a grid
grid = [[' ' for _ in range(width)] for _ in range(height)]

# Draw the circle
for y in range(height):
    for x in range(width):
        # Translate grid coordinates to center coordinates
        dx = x - width // 2 + center_x
        dy = y - height // 2 - center_y
        
        # Check if the point is on the circle
        distance = math.sqrt(dx**2 + dy**2)
        if abs(distance - radius) < 1:
            grid[y][x] = '*'

# Print the grid
for row in grid:
    print(''.join(row))