none
Challenge of the Month - September 2017 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.

    Text Challenge

    • Write a program to loop through the characters in a string, moving the first character to the end until all characters have been moved

    "Hello World" -> "ello WorldH" -> "llo WorldHe" -> "lo WorldHel" -> etc -> "Hello World"

    Interface Challenge

    • Write an interface to play songs on your PC.  It should have input for a folder where your files are, and a way to select and play, stop one of the music files.

    Graphics Challenge

    • Write a program to draw lightning flashes

    Test Program Challenge

    • Write some simple short programs to test all the features of one one the Small Basic objects

    Physics Challenge

    • Write a program to show white light being split into rainbow colours by a glass prism.  To make it harder make it so that the direction of the input white light can be moved (check out Snell's law).

    https://communitycloudatlas.files.wordpress.com/2014/06/prism_refraction.gif

    Game Challenge

    • Write a simple Bejeweled game, just using coloured circles

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

    Saturday, September 2, 2017 12:22 PM
    Moderator

All replies

  • Text Challenge

    str = "Hello World"
    For n = 0 To Text.GetLength(str)
      TextWindow.WriteLine(str)
      str = Text.Append(Text.GetSubTextToEnd(str, 2), Text.GetSubText(str, 1,1))
    EndFor

    Saturday, September 2, 2017 1:20 PM
    Answerer
  • Hi Team,

    PROGRAM CODE = CLH669

    Interface Challenge

    I Made A Sound Player

    Thanks,

    Saturday, September 2, 2017 2:42 PM
  • Hi Team,

    Text Challenge

    Program ID = LCZ397

    Thanks,

    Saturday, September 2, 2017 3:10 PM
  • Hi Team,

    Text Challenge

    Program ID = LCZ397

    Thanks,

    Hi Team,

    This My Update = LCZ397-0

    Thanks,

    Saturday, September 2, 2017 3:19 PM
  • Hi Team,

    PROGRAM CODE = CLH669

    Interface Challenge

    I Made A Sound Player

    Thanks,

    Hi Team,

    My Update = CLH669-1

    *Added A Data Base (.txt) Which Reads The Path Of The Previously Played Song 

    Sound Player 0.2

    Thanks,



    Sunday, September 3, 2017 7:16 AM
  • @ Roshan - well done good answers
    Sunday, September 3, 2017 11:08 AM
    Moderator
  • This is a solution for the test program challenge: GTZ663.

    Math.Abs() Test
    exp:expected, res:result
     1 FAIL |-1.7976931348623157E+308| exp=1.7976931348623157E+308 res=0
     2 FAIL |-8E28| exp=8E28 res=0
     3 FAIL |-79228162514264337593543950336| exp=79228162514264337593543950336 res=0
     6 FAIL |-79228162514264333195497438207| exp=79228162514264333195497438207 res=7
    9228162514264300000000000000
     7 FAIL |-79228162514264333100000000000| exp=79228162514264333100000000000 res=7
    9228162514264300000000000000
     8 FAIL |-79228162514264300000000000001| exp=79228162514264300000000000001 res=7
    9228162514264300000000000000
     9 PASS |-79228162514264300000000000000| exp=79228162514264300000000000000 res=7
    9228162514264300000000000000
    10 PASS |-7E28| exp=7E28 res=70000000000000000000000000000
    11 PASS |-1.2| exp=1.2 res=1.2
    12 PASS |-1E-28| exp=1E-28 res=0.0000000000000000000000000001
    13 PASS |-1E-29| exp=1E-29 res=0
    14 PASS |0| exp=0 res=0
    15 PASS |1E-29| exp=1E-29 res=0
    16 PASS |1E-28| exp=1E-28 res=0.0000000000000000000000000001
    17 PASS |1.2| exp=1.2 res=1.2
    18 PASS |7E28| exp=7E28 res=70000000000000000000000000000
    19 PASS |79228162514264300000000000000| exp=79228162514264300000000000000 res=7
    9228162514264300000000000000
    20 FAIL |79228162514264300000000000001| exp=79228162514264300000000000001 res=7
    9228162514264300000000000000
    21 FAIL |79228162514264333100000000000| exp=79228162514264333100000000000 res=7
    9228162514264300000000000000
    22 FAIL |79228162514264333195497438207| exp=79228162514264333195497438207 res=7
    9228162514264300000000000000
    25 FAIL |79228162514264337593543950336| exp=79228162514264337593543950336 res=0
    26 FAIL |8E28| exp=8E28 res=0
    27 FAIL |1.7976931348623157E+308| exp=1.7976931348623157E+308 res=0
    
    Pass: 11/23
    Press any key to continue...
    

    Nonki Takahashi

    Sunday, September 3, 2017 12:08 PM
    Moderator
  • This is my first step for the physics challenge: DQG281.

    Screen shot of a program Snell's Law


    Nonki Takahashi

    Monday, September 4, 2017 8:49 AM
    Moderator
  • great and well done as always nonki!

    update: DQG281-0

    regulates refractance index by mswheel

    Monday, September 4, 2017 10:50 AM
  • This is my second step for the physics challenge: VGR488.

    Screen shot of a program Wavelength vs Refractive Index


    Nonki Takahashi

    Monday, September 4, 2017 4:06 PM
    Moderator
  • great nonki!

    updated and changed colours: VGR488-1

    Monday, September 4, 2017 5:45 PM
  • Interface Challenge    ZSP762

    input folder name where sounds exist, then push "List".

    click sound button to play.

      

    Tuesday, September 5, 2017 7:26 AM
    Answerer
  • Hi Team,

    PROGRAM CODE = CLH669

    Interface Challenge

    I Made A Sound Player

    Thanks,

    Hi Team,

    My Update = CLH669-1

    *Added A Data Base (.txt) Which Reads The Path Of The Previously Played Song 

    Sound Player 0.2

    Thanks,



    Hi Team,

    This My Update = CLH669-2

    *Changed The Size Of TextBox

    Thanks,


    Tuesday, September 5, 2017 10:23 AM
  • This is my first step for the game challenge: FXH336.

    Just showing demos.

    Screen shot of a program Bejeweled in Small Basic 0.1a


    Nonki Takahashi

    Wednesday, September 6, 2017 8:46 AM
    Moderator
  • This is my third step for the physics challenge: MLM021.

    Screen shot of a program Prism 0.1


    Nonki Takahashi

    Wednesday, September 6, 2017 3:32 PM
    Moderator
  • great nonki!

    small update: MLM021-0

    • colors changed
    • added mswheel regulation of beam angle


    • Edited by Tryhest Friday, September 8, 2017 5:57 AM
    Friday, September 8, 2017 5:55 AM
  • This is the fourth step for the physics challenge: MLM021-1.

    Screen shot of a program Prism 0.2


    Nonki Takahashi

    Friday, September 8, 2017 8:53 AM
    Moderator
  • OK.. for the challenge of the month SB example, I have written an example for EVERY SB command.

    There were about 30 people that downloaded the work in progress. I suspect many were disappointed because a number of topics had not been fleshed out. I am happy to say I have completed the last major revision and all but minor editing is left to be accomplished. The latest and greatest complete reference guide is available at...

    https://sourceforge.net/projects/ms-small-basic-dev-guide/

    I had no idea what I was taken on. I expected this to take 2-3 days but it took about 2 weeks and 4-5 hrs per day. From this point on, corrections will be made as I write programs and reference my own examples. I have found a few occasions where commands were missing, or they needed to be included in appropriate topics.

    Please provide suggestions, snippets,  and corrections to...

    https://sourceforge.net/p/ms-small-basic-dev-guide/blog

    Two pdf versions are provided, the first is divided into 16 topics with additional Color chart and Master API reference - this is what I personally use. A request was made by mobile users to have a single "all in one" pdf file so that has been provided too. Each style of reference is about 6mb in size, the total download is 12mb and includes both styles zipped into one compressed file.



    • Edited by jwzumwalt1 Sunday, September 10, 2017 2:38 AM
    Sunday, September 10, 2017 2:08 AM
  • Hi Team,

    Update For Sound Player

    *Requires LD Extension

    *Added Volume Functions

    ID = CLH669-4


    Thanks,
    Thursday, September 14, 2017 1:32 AM
  • Hi Team,

    This is the Test case for Text.Append()

    • change testcase to check the working of the program
    • Shows pass and fail

    ID = HGV389

    Thanks,

    Friday, September 15, 2017 4:27 PM
  •      proogram ID JQK335 aroplane and  cannon code animation are not working will somebody help with thanks

                                                                                               mahreen miangul

    Wednesday, September 20, 2017 2:27 PM
  •      proogram ID JQK335 aroplane and  cannon code animation are not working will somebody help with thanks

                                                                                               mahreen miangul


    See JQK335-0
    Thursday, September 21, 2017 1:41 AM
    Answerer
  • Hi!

    This is my solution for the text challenge.

    Unfortunately, the program does not work in a webbrowser, so you need to copy and paste the code into Small Basic to run the program.

    Thanks,

    CODE:

    GraphicsWindow.Title = "Text!"
    GraphicsWindow.Width = Desktop.Width/2
    GraphicsWindow.Height = Desktop.Height/2
    textbox = Controls.AddMultiLineTextBox(10, 10)
    Controls.SetSize(textbox, GraphicsWindow.Width-20, GraphicsWindow.Height-50)
    Controls.Move(textbox, 10, Shapes.GetTop(textbox)+40)
    inputtextbox = Controls.AddTextBox(10, 10)
    Controls.SetSize(inputtextbox, GraphicsWindow.Width-70, 25)
    Button = Controls.AddButton("Enter", GraphicsWindow.Width-55, 10)
    Controls.ButtonClicked = OnButtonClick
    Sub OnButtonClick
      If Controls.LastClickedButton = Button Then
        inputstring = Controls.GetTextBoxText(inputtextbox)
        submit()
      EndIf
    EndSub
    Controls.SetSize(Button, 45, 25)
    Sub submit
      Controls.SetTextBoxText(textbox, "original text: " + inputstring + Text.GetCharacter(13))
      lenght = Text.GetLength(inputstring)
      For i = 1 To lenght
        text1 = text.GetSubText(inputstring, i+1, lenght)
        text2 = text.GetSubText(inputstring, 1, i)
        newtext = text1 + text2
        Controls.SetTextBoxText(textbox, controls.GetTextBoxText(textbox) + i + ": " + newtext + Text.GetCharacter(13))
      EndFor
    EndSub

    Sunday, September 24, 2017 8:17 AM
  • Hi,

    This Is The Solution For The Graphics Challenge

    ID = MFX525

    Thanks,


    Roshan 7th Grade Student - Learning Small Basic


    Wednesday, September 27, 2017 2:09 PM
  • This are my suggestions for a future CotM:

    1. PaletteViewer
    a.) Write a program to save colors (eg. SB supported HTML colors, websafe colors, ...) to a PDN Palette.txt or GIMP Palette.gpl file.

    b.) Write a program to read this .txt or .gpl palette file and show it's colors visually (perhaps with infos like name, #hex, R,G,B)

    2. RuntimeControls
    Write a program which allows it to add controls like Button, (ML)TB during its own runtime. The added controls also have to work with events.
    Sunday, October 1, 2017 2:11 PM
    Answerer