none
Challenges for October 2018 RRS feed

  • General discussion

  • These are my challenges for October 2018.

    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.

    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.

    Hard Challenges

    Pascal Triangle

    Write a program which will draw a Pascal triangle in GraphicsWindow.

    Random Number Generator

    Create a program which accepts two numbers then prints out a random number somewhere between those two numbers. Make sure you write your own code to generate the random number (ie. don't use the built in Math.GetRandomNumber() function).

    You can be quite creative in how you achieve this but a common approach is to make use of the current time as part of your method.

    Correct HTML

    Create a program which will read in a file containing HTML and identify lines with incorrectly nested tags. This is an example of correctly nested tags:

    <H1>This is my <span>heading</span></H1>           <-- This is correct

    And this is an example of incorrectly nested tags:

    <H1>This is my <span>heading</H1></span>           <-- This is wrong

    Tic Tac Toe

    Build a game of Tic Tac Toe. I would suggest you start off building a two player version then if you want a little extra challenge see if you can build a version where you get to challenge the computer.

    Small Challenges

    1.  Write a program to check whether a number is odd or even.

    2.  Write a program that can convert numbers into triangles (in TextWindow).

    For example, If you give input as 5,

    The output should be 

    *

    **

    ***

    ****

    *****

    Similarly, If you give the input as 3,

    The output should be

    *
    **
    ***

    3. Write a program to print prime numbers from 1 to 1000.

    4. Write a simple program that can draw shapes on the Small Basic GraphicsWindow like the Paint application on Windows (Shapes editor).

    This is a sample Shapes Editor.

    GraphicsWindow.Show()
    rectangle Controls.AddButton("Add Rectangle",0,0)
    ellipse Controls.AddButton("Add Ellipse",0,50)
    Controls.ButtonClicked OnBC
    Sub OnBC
      If Controls.LastClickedButton rectangle Then
        func "rect"
        active "T"
        If func "rect" Then
          GraphicsWindow.MouseDown OnMDrect
        EndIf  
      Else
        func "ell"
        active "T"
        If func "ell" Then
          GraphicsWindow.MouseDown OnMDell
        EndIf    
      EndIf  
    EndSub  
    Sub OnMDell
      ellx GraphicsWindow.MouseX
      elly GraphicsWindow.MouseY
      ell Shapes.AddEllipse(0,0)
      Shapes.Move(ell,ellx,elly)
      If func "ell" Then
        GraphicsWindow.MouseMove OnMMell
        GraphicsWindow.MouseDown OnMDell2
      EndIf
    EndSub
    Sub OnMMell
      If func "ell" Then
        If active "T" Then
          width Math.Abs(ellx-GraphicsWindow.MouseX)
          height Math.Abs(elly-GraphicsWindow.MouseY)
          Controls.SetSize(ell,width,height)
        EndIf  
      EndIf  
    EndSub  
    Sub OnMDell2
      func ""
      active ""
      height 0
      width 0
      rect ""
      ell ""
    EndSub  
    Sub OnMDrect
      rectx GraphicsWindow.MouseX
      recty GraphicsWindow.MouseY
      rect Shapes.AddRectangle(0,0)
      Shapes.Move(rect,rectx,recty)
      If func "rect" Then
        GraphicsWindow.MouseMove OnMMrect
        GraphicsWindow.MouseDown OnMDrect2
      EndIf
    EndSub
    Sub OnMMrect
      If func "rect" Then
        If active "T" Then
          width Math.Abs(rectx-GraphicsWindow.MouseX)
          height Math.Abs(recty-GraphicsWindow.MouseY)
          Controls.SetSize(rect,width,height)
        EndIf  
      EndIf  
    EndSub  
    Sub OnMDrect2
      func ""
      active ""
      height 0
      width 0
      rect ""
      ell ""
    EndSub  



    Roshan - 8th Grade Student (Age 12) - Learning Small Basic, Visual Basic and C#


    Saturday, October 6, 2018 6:21 AM

All replies

  • Blinkig Eyes Cartoon-Ninja 8 ID HDM234
                                                                                                                                                 mahreen miangul
    Sunday, October 7, 2018 4:25 AM
  • Hi all,

    This is my solution for Write a program to check whether a number is odd or even.

    https://www.youtube.com/watch?v=aM5x3xm5LBU

    Thanks.


    Roshan - 8th Grade Student (Age 12) - Learning Small Basic, Visual Basic and C#

    Sunday, October 14, 2018 4:42 PM
  • This is my solution for the Pascal's triangle challenge: GCN044.

    Screen shot of a program Pascal's Triangle


    Nonki Takahashi

    Friday, October 19, 2018 9:09 AM
    Moderator
  • Hi all,

    This is my solution for Write a program to check whether a number is odd or even.

    https://www.youtube.com/watch?v=aM5x3xm5LBU

    Thanks.


    Roshan - 8th Grade Student (Age 12) - Learning Small Basic, Visual Basic and C#


    Nice video, Roshan!

    Nonki Takahashi

    Friday, October 19, 2018 9:17 AM
    Moderator
  • This is my solution for the Pascal's triangle challenge: GCN044.

    Screen shot of a program Pascal's Triangle


    Nonki Takahashi

    Amazing

    Roshan - 8th Grade Student (Age 12) - Learning Small Basic, Visual Basic and C#

    Sunday, October 21, 2018 10:11 AM


  • Nice video, Roshan!

    Nonki Takahashi

    Thank You!

    Roshan - 8th Grade Student (Age 12) - Learning Small Basic, Visual Basic and C#

    Sunday, October 21, 2018 10:11 AM
  • Hi all!

    This is my solution for the prime number challenge.

    https://www.youtube.com/watch?v=Mwq9z_SPtTE

    Improvements :

    • Reduced screen resolution for better code view.

    Thanks.


    Roshan - 8th Grade Student (Age 12) - Learning Small Basic, Visual Basic and C#

    Sunday, October 21, 2018 10:12 AM
  • paint update: LGN885

    • ld xtension required
    • allows to zoom and rotate
    • lmb+wheel=rotates all, wheel=zooms all
    • press 1=delete mode 2=add mode 3=outline mode
    • press q to draw rect
    • press z to zoom drawn object with cursor on it by mswheel
    • press x to delete object with cursor on it
    • any other key to draw circle




    • Edited by Tryhest Monday, October 22, 2018 11:26 AM
    Monday, October 22, 2018 11:24 AM
  • Multiple KeyBoard ID NPX318 when the red ball hits the Aircraft there is no reaction in sound or written like the one in Eora Duck Hunt Game ID XCC705-1.when the red ball hits the Aircraft there should be sound in the shape of music and there should also be written on window 'you hit the target!" or some thing
    Monday, October 22, 2018 12:22 PM
  • color update: BGJ192

    Monday, October 22, 2018 9:50 PM
  • 3d update: BMR546

    Tuesday, October 23, 2018 5:34 PM
  • 3d update: BMR546

    Hi,

    Looks Cool! Nice pascal triangle.

    Thanks.


    Roshan - 8th Grade Student (Age 12) - Learning Small Basic, Visual Basic and C#

    Wednesday, October 24, 2018 10:52 AM
  • paint update: LGN885

    • ld xtension required
    • allows to zoom and rotate
    • lmb+wheel=rotates all, wheel=zooms all
    • press 1=delete mode 2=add mode 3=outline mode
    • press q to draw rect
    • press z to zoom drawn object with cursor on it by mswheel
    • press x to delete object with cursor on it
    • any other key to draw circle




    Hi,

    Awesome Shapes editor.

    Thanks.


    Roshan - 8th Grade Student (Age 12) - Learning Small Basic, Visual Basic and C#

    Wednesday, October 24, 2018 10:53 AM
  • ninja updt: CJJ391

    Wednesday, October 31, 2018 5:33 AM