none
Challenge of the Month - May 2018 RRS feed

  • General discussion

  • 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 that will remain 'sticky' for the month.  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.

    Graphics Challenge

    Draw super colorful spiral using the Turtle.  Consider using color, line width, transparency and other methods to make the spiral a bright and interesting as possible.

    Colorful Hypnotic Spiral | www.imgkid.com - The Image Kid ...

    Musics Challenge

    Choose a musical instrument, perhaps trumpet, piano or drums etc.

    Think of a suitable way to play it (Key Presses, Mouse Clicks etc) and make it play music realistically by mimicing pressing the instrument keys or other action.

    TextWindow Challenge

    Get the user to input some text in the TextWindow.  Write the program to:

    • Accept any text input
    • Accept only a number as input
    • Accept only a 7 digit number
    • Accept only a 7 digit number where the digits sum to 30 (e.g. 4637811)
    • Accept only a 2 word name where each name starts with a capital (e.g. John Smith)


    The last 3 are harder and may take a little more imagination to code to work exactly like the first 2.

    Maths Challenge (Conics)

    Get the Turtle (or another way) to draw the main conic sections.  These are:

    • Circle
    • Ellipse
    • Parabola
    • Hyperbola

    Community Suggestion (By mussamaina)

    CPW302 - Blink the eyes of this face by extending the code only don't change the program - LINK

    Do you have an idea or a future challenge? Please post it here!

    Tuesday, May 1, 2018 5:48 PM
    Moderator

All replies

  • not turtle, but very simple solution:

    GraphicsWindow.BackgroundColor="tan"
    GraphicsWindow.Width=1200
    GraphicsWindow.Height=800
    For e=.1 To 1.9 Step .1
      l=100
      For t=-179.9 To 179.9 Step .07
        r=l/(1+e*LDMath.Cos(t))
        GraphicsWindow.Title=e
        xx=LDMath.Convert2Cartesian(400+e*100 300 r t)
        GraphicsWindow.SetPixel(xx[1] xx[2] "red")
      EndFor
    EndFor

    Wednesday, May 2, 2018 9:58 AM
  • ellipses v2
    GraphicsWindow.BackgroundColor="tan"
    GraphicsWindow.Width=1200
    GraphicsWindow.Height=800
    d15=15
    For e=.1 To 0.5 Step .03
      l=100
      For t=-179+pp To 0 Step .07
        r=l/(1+e*LDMath.Sinh(t*Math.Pi/180))
        GraphicsWindow.Title=e+":"+t
        xx=LDMath.Convert2Cartesian(400+e*100 300 r t)
        GraphicsWindow.SetPixel(xx[1] xx[2] "red")
        GraphicsWindow.SetPixel(xx[1] 600-xx[2] "red")
        GraphicsWindow.SetPixel(1050-xx[1] xx[2] "red")
        GraphicsWindow.SetPixel(1050-xx[1] 600-xx[2] "red")
      EndFor
      pp=pp+d15
      d15=d15*.9
    EndFor

    Wednesday, May 2, 2018 10:19 AM
  •  CPW302  blink the eyes of this face by extending the code only dont change the program

                                                                                                                                                  mahreen miangul

    Wednesday, May 2, 2018 1:28 PM
  • Maths Challenge (Conics)

        ID:  BDT938

    Wednesday, May 2, 2018 4:22 PM
    Answerer
  • you ask for challenges try to work on all challenges not selected ones    thanking you       

                                                                                                                                     mahreen miangul

    Thursday, May 3, 2018 10:04 AM
  • simple and indigenos way of drawing a Curve

    ' Curve in 10 Lines
    ' mahreen miangul 5th May 2018

    GraphicsWindow.Top = 80
    GraphicsWindow.BackgroundColor="olivedrab

    GraphicsWindow.PenColor = "yellow"
    GraphicsWindow.PenWidth = 8
    GraphicsWindow.drawellipse(250, 50, 200, 150)
    GraphicsWindow.BrushColor="olivedrab
    GraphicsWindow.PenColor = "olivedrab
    rectangle = Shapes.AddRectangle(270, 100)
    Shapes.Move(Rectangle, 240, 40)
    Shapes.Rotate(rectangle, 0)

    coments needed and wellcome                                                                                     mahreen miangul

    Thursday, May 10, 2018 7:18 AM
  • This is my solution Ellipse by Turtle: RWJ975.

    I solved the following equations.

    a / b * d2 cos _β2 = d1 * cos _β1
    d2 sin _β2 = d1 * sin _β1


    Nonki Takahashi


    Sunday, May 20, 2018 2:49 AM
    Moderator
  •  CPW302  blink the eyes of this face by extending the code only dont change the program

                                                                                                                                                  mahreen miangul


    This is my solution: PMQ151.

    Nonki Takahashi

    Sunday, May 20, 2018 3:32 AM
    Moderator
  •  with Thanks a good Solution                                                                      mahreen miangul
    Sunday, May 20, 2018 7:30 AM
  • can i draw the ellipse half to make it a curve the second question draw all this by graphics instead of turtle with thanks i hope i made my self clear                                                                              mahreen miangul

    Tuesday, May 22, 2018 6:54 AM
  • Maths Challenge (Conics) 2

    Similar to BTD938, but outline curves only, in 2 variants:

    1.) def = "False"       .. without graphical definition (no extension)

    2.) def = "True"        .. showing graph. definition/construction (uses LitDev)

      without/with graphical definition

    ID: BDT938-0

    PS: you can also switch between Subs  Hyperbola() or different way Hyperbola2()  (H..2()  uses LDMath)

    On a system without LD.., simply remove Sub Hyperbola2 and uncomment all lines containing 'tri' ID: BDT938-1


    Tuesday, May 22, 2018 8:12 PM
    Answerer
  • a good solution but make it without extention next time we are still learning code programming leave extentions for the next level may God bless you                                                                            mahreen miangul
    Wednesday, May 23, 2018 1:20 PM
  • JLF246 and DFN465 . program JLF246 is based on func = ell ,in program DFN465 i have added a func = text but i am getting funny results will somebody help with thanks                                                    mahreen miangul
    Thursday, May 24, 2018 1:12 PM
  • can i draw the ellipse half to make it a curve the second question draw all this by graphics instead of turtle with thanks i hope i made my self clear                                                                              mahreen miangul

    Hi mussamaina, how about this?

    ox = GraphicsWindow.Width / 2
    oy = GraphicsWindow.Height / 2
    w = 300
    h = 200
    For a = -30 To 90 Step 5
      _a = Math.GetRadians(a)
      x2 = ox + (w / 2) * Math.Cos(_a)
      y2 = oy + (h / 2) * Math.Sin(_a)
      If -30 < a Then
        GraphicsWindow.DrawLine(x1, y1, x2, y2)
      EndIf
      x1 = x2
      y1 = y2
    Endfor


    Nonki Takahashi

    Saturday, May 26, 2018 7:15 AM
    Moderator
  • a good solution but make it without extention next time we are still learning code programming leave extentions for the next level may God bless you                                                                            mahreen miangul

    ..see no problem. when using BDT938-0 just like it is (def = "False"), then NO extension method will ever be called under this branch.
    def = "True"  is only an additional feature, you can use, but is'nt necessary.
    To avoid compiler error, some lines are to comment out. That's mentioned above.
    If infeasible, the reduced version is ID: BDT938-1 (w/o Ext, edited above).

    BTW: Generally there's no need to be 'afraid' of extensions. Some provide methods which would'nt be available otherwise, others of them simply make life easier.
    eg. to replace a part in a string by ext. can be done in a single line (no real coding? hmm, for the lazy ones if you like, or just handy), else you have to find a way to use available basic commands in several lines (longer, slower, complexer).
    Thats one reason, i guess, for challenges w/o extension, to use what's there and find a way by combining these.


    Saturday, May 26, 2018 2:00 PM
    Answerer
  • All Curves and their Codes
    hello your code is far better than mine but your one is to advanced for people like us your code program is based on trignometric angles which is far advanced my code is based only on two functions rectangle and ellipse which can be fitted in any program for curve no hardwork needed like some body sugusted the lazy ones may god bless you. apraciation is needed from people like youself for progams like this and the effort done on themmmmmmmmm

                                                                                                                           mahreen miangul

                                                                                                                                                    


    • Edited by mussamaina Sunday, May 27, 2018 4:26 PM adding some text
    Sunday, May 27, 2018 4:23 PM
  • GraphicsWindow.Width = 1080
    GraphicsWindow.height = 600

    GraphicsWindow.brushcolor="purple"
    GraphicsWindow.FillEllipse(100,100,500,500)
    GraphicsWindow.brushcolor="red"
    GraphicsWindow.FillEllipse(150,200,100,100)
    GraphicsWindow.FillEllipse(450,200,100,100)
    GraphicsWindow.brushcolor="green"
    GraphicsWindow.FillEllipse(300,300,100,100)

    For i=900 To 2700
      x = 150*Math.sin(Math.GetRadians(i/10.0)) +350
      y = 150*Math.cos(Math.GetRadians(i/10.0)) +400
      GraphicsWindow.SetPixel(x,y "yellow")
    endfor

    the (mouth) Arc is down up it should be up down i cant rotate the arc around to face up word the above code is taken from you tube video small basic 

    Tuesday, May 29, 2018 6:11 AM
  • Change the for loop to   For i=2700 To 4500

    Jan [ WhTurner ] The Netherlands

    Tuesday, May 29, 2018 9:20 AM
    Answerer
  • was trying to draw a curve in a few lines for a long time please alter the pen size with thanks 

                                                                                                                        mahreen miangul

    Tuesday, May 29, 2018 11:07 AM
  • Are you referring to the line for the mouth in your post of 5 hours ago?

    put:    GraphicsWindow.DrawEllipse(x,y,2,2)

    in stead of the  SetPixel line.


    Jan [ WhTurner ] The Netherlands

    Tuesday, May 29, 2018 11:29 AM
    Answerer
  • nice editing                                                                                                            mahreen miangul
    Tuesday, May 29, 2018 2:51 PM
  • This is my solution for the graphics challenge: WBN030.

    Screen shot of a program Turtle Spiral


    Nonki Takahashi

    Thursday, May 31, 2018 2:48 PM
    Moderator