Challenge of the Month - February 2021

Nonki Takahashi 676 Reputation points
2021-02-07T02:49:50.33+00:00

These challenges are intended for people who are learning to program for the first time or for those returning to programming who want to start using Small Basic. Some will be easy, some will be hard - but they will all make you think, and more importantly be GREAT FUN!

Please post your solutions / partial solutions / questions / feedback etc. into this thread. The only rule is that your solution must use standard Small Basic methods (no extensions).

It would be good if people could post their problems with these challenges so that a discussion can start so that everyone can learn from each other.

We may extend these challenges over into a second month if solutions and questions are still coming in.

64856-square.png

Turtle Challenge

  1. Write a program to draw a square with Turtle.
  2. Try to change the edge length of square.
  3. Try to change the angle of the shape.
Small BASIC
Small BASIC
A programming language created by Microsoft that serves a stepping stone for beginners from block-based coding languages to more complex text-based languages.
277 questions
0 comments No comments
{count} votes

Accepted answer
  1. Tryhest 221 Reputation points
    2021-02-08T19:07:37.32+00:00

    25 squares at golden angle:
    65508-image.png

    Turtle.Speed=10  
    GraphicsWindow.BackgroundColor="teal"  
    ll=140  
    For xx= 1 To 25  
      GraphicsWindow.PenColor=GraphicsWindow.GetRandomColor()  
      ll=ll-3  
      Turtle.Angle=Turtle.Angle+137.5  
      For x= 1 To 4  
        Turtle.Move(ll)  
        Turtle.Turn(90)  
      EndFor  
    EndFor  
      
    
    1 person found this answer helpful.
    0 comments No comments

8 additional answers

Sort by: Most helpful
  1. Tryhest 221 Reputation points
    2021-02-08T19:00:34.177+00:00

    10 squares by turtle at random angle, size and color:
    65496-image.png
    Turtle.Speed=9
    GraphicsWindow.BackgroundColor="tan
    For xx= 1 To 10
    GraphicsWindow.PenColor=GraphicsWindow.GetRandomColor()
    ll=Math.GetRandomNumber(50)+20
    Turtle.Angle=Math.GetRandomNumber(360)
    For x= 1 To 4
    Turtle.Move(ll)
    Turtle.Turn(90)
    EndFor
    Program.Delay(555)
    EndFor

    1 person found this answer helpful.
    0 comments No comments

  2. Nonki Takahashi 676 Reputation points
    2021-02-10T13:09:55.233+00:00

    This is my solution:

    66493-turtle-regular-polygon.png

    ' Turtle Regular Polygon  
    ' Copyright ©︎ 2021 Nonki Takahashi.  The MIT License.  
    ' Last update 2021-02-10  
      
    GraphicsWindow.BrushColor = "Black"  
    GraphicsWindow.DrawText(10, 10, "Distance")  
    tboxD = Controls.AddTextBox(100, 10)  
    GraphicsWindow.DrawText(10, 40, "Angle")  
    tboxA = Controls.AddTextBox(100, 40)  
    GraphicsWindow.DrawText(10, 70, "Corners")  
    shpC = Shapes.AddText("X")  
    Shapes.Move(shpC, 100, 70)  
    n = 4  
    distance = 100  
    Controls.SetTextBoxText(tboxD, distance)  
    angle = Math.Round(360 / n * 10) / 10  
    Controls.SetTextBoxText(tboxA, angle)  
    Shapes.SetText(tboxA, angle)  
    Controls.AddButton("Draw", 10, 100)  
    Turtle.Speed = 10  
    Controls.ButtonClicked = OnButtonClicked  
    Sub OnButtonClicked  
        distance = Controls.GetTextBoxText(tboxD)  
        angle = Controls.GetTextBoxText(tboxA)  
        GraphicsWindow.PenColor = GraphicsWindow.GetRandomColor()  
        Turtle.Show()  
        tx = Turtle.X  
        ty = Turtle.Y  
        error = 100  
        n = 0  
        While 0.5 < error  
            n = n + 1  
            Shapes.SetText(shpC, n)  
            Turtle.Move(distance)  
            Turtle.Turn(angle)  
            ex = Turtle.X - tx  
            ey = Turtle.Y - ty  
            error = Math.SquareRoot(ex * ex + ey * ey)  
        EndWhile  
        Turtle.Hide()  
    EndSub  
    
    1 person found this answer helpful.
    0 comments No comments

  3. Tryhest 221 Reputation points
    2021-02-20T21:25:24.827+00:00

    3d trains anim: GSK298

    70323-ttl.png70306-3d-train.log

    note: rename log to obj file

    1 person found this answer helpful.
    0 comments No comments

  4. Tryhest 221 Reputation points
    2021-02-23T04:07:40.627+00:00

    hexadip switch: NZR430
    70889-hxx.png

    1 person found this answer helpful.
    0 comments No comments