Vai al contenuto

Challenge 2018-10


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

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *

Questo sito usa Akismet per ridurre lo spam. Scopri come i tuoi dati vengono elaborati.