# Challenge of the Month - October 2016

### 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 format numbers 1 to 100 in a neat 10 by 10 grid in the TextWindow
• Modify the program to colour numbers divisible by 5 red, and numbers divisible by 7 yellow.

Graphics Challenge

• Make an animation of a spinning top rotating and moving in the GraphicsWindow

Game Challenge

• Write a noughts and crosses game to play against the computer
• Perhaps add some nice graphics and sound effects to the game

Maths Challenges

• Write a program to calculate the change in the correct coinage of your currency.  Perhaps randomly set a price of something and ask the user to enter the money given and the program works out the correct change.

For example:

Item costs £2.65 and user gives £5.

The change is:

1 £2 coin

1 20p coin

1 10p coin

1 5p coin

• Write a program to calculate the sum of the first 100 prime numbers

Community Suggestion Challenges

• 12 bit 4096 colors (By YLed) LINK
• Draw a Leaf (By Nonki) LINK
• Special 31st - draw a Pumpkin (By YLed) LINK

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

Saturday, October 1, 2016 8:25 AM

### All replies

• Hi ! LitDev

this is my solution for the Math Challenge, correct coinage in Canadian Currency \$

To test the program, I entered several different situations of amounts, everything seems to work properly, if you find a bug in this program do not hesitate to let me know, thanks!

I have include cents for program purpose.

program: XMN630

• Edited by Wednesday, October 5, 2016 10:35 PM new icons coins
Wednesday, October 5, 2016 6:31 PM
• Hi ! LitDev

this is my solution for the Math Challenge, correct coinage in Canadian Currency \$

To test the program, I entered several different situations of amounts, everything seems to work properly, if you find a bug in this program do not hesitate to let me know, thanks!

I have include cents for program purpose.

program: XMN630

Great job on the cash register!

Ed Price, Azure Development Customer Program Manager (Blog, Small Basic, Wiki Ninjas, Wiki)

Saturday, October 8, 2016 1:16 PM
• Tic-Tac-Toe

I found on the internet this wonderful PDF that explains how and with what approach we can program a game of Tic-Tac-Toe

Department of Electrical Engineering and Computer Sciences at UC Berkeley

• Edited by Saturday, October 8, 2016 7:54 PM
Saturday, October 8, 2016 7:49 PM
• hello have tried on leaf cameup with a funny result i think so ID GGF374 will excuse me as a newcomer coments will

be wellcomed with thanks mahreen miangul

Monday, October 10, 2016 6:03 AM
• Graphics Challenge    LKL810

rotating moving Top.  (not spinning)

Tuesday, October 11, 2016 3:22 AM
• Graphics Challenge    LKL810

rotating moving Top.  (not spinning)

for coments and improvement ID NTF885  sours code graphics challenge mahreen miangul 'mahreen miangul all help from
' Exploring Shapes Small Basic
GraphicsWindow.Title = "mahreen miangul"
graphicswindow.Width = 1000
GraphicsWindow.Height = 420
GraphicsWindow.BackgroundColor = GraphicsWindow.GetColorFromRGB(125,75,175) with thanks mahreen miangul

GraphicsWindow.BrushColor = GraphicsWindow.GetRandomColor()
graphicswindow.FontSize = 88
graphicswindow.drawboundtext(100, 10, 600, "mussa-maina")

GraphicsWindow.BrushColor = "fuchsia"
graphicswindow.FontSize = 88
graphicswindow.drawboundtext(420, 100, 600, "😚")

miangul:
GraphicsWindow.BrushColor = GraphicsWindow.GetRandomColor()
graphicswindow.FontSize = 66
Shapes.Move(Sball, 340, 0)
x = 866
GraphicsWindow.PenWidth = 11
GraphicsWindow.PenColor = "darkslategray"
GraphicsWindow.DrawRectangle(919, 0, 80, 450)
GraphicsWindow.BrushColor = "yellowgreen"
GraphicsWindow.FillRectangle(920, 0, 79, 450)
GraphicsWindow.BrushColor = GraphicsWindow.GetRandomColor()
graphicswindow.FontSize = 22
graphicswindow.drawboundtext(940, 8, 600, "m")
graphicswindow.drawboundtext(940, 30, 600, "a")
graphicswindow.drawboundtext(940, 52, 600, "h")
graphicswindow.drawboundtext(940, 74, 600, "r")
graphicswindow.drawboundtext(940, 96, 600, "e")
graphicswindow.drawboundtext(940, 118, 600, "e")
graphicswindow.drawboundtext(940, 140, 600, "n")
graphicswindow.drawboundtext(940, 208, 600, "m")
graphicswindow.drawboundtext(940, 230, 600, "i")
graphicswindow.drawboundtext(940, 252, 600, "a")
graphicswindow.drawboundtext(940, 274, 600, "n")
graphicswindow.drawboundtext(940, 296, 600, "g")
graphicswindow.drawboundtext(940, 318, 600, "u")
graphicswindow.drawboundtext(940, 340, 600, "l")
Shapes.Animate(Sball, x, 40, 490)
Program.Delay(500)
If (Shapes.GetLeft(Sball) = x) Then
Shapes.Animate(Sball, 0, 340, 500)
EndIf
goto miangul
Tuesday, October 11, 2016 6:03 AM
• Graphics Challenge    LKL810

rotating moving Top.  (not spinning)

Tuesday, October 11, 2016 11:31 AM
• 3D spinner: PWN348
• Edited by Saturday, October 15, 2016 8:33 PM
Saturday, October 15, 2016 8:33 PM
• @tryhest

Marvelous, 3D spinner !!! i'll vote for that :)

Saturday, October 15, 2016 9:02 PM
• Hi !

This is my solution to Text challange

Program id :CDN158

Monday, October 17, 2016 4:18 PM
• Hi !

This is my solution to Text challange

Program id :CDN158

Nice job

Monday, October 17, 2016 7:59 PM
• Really nice code !!!
Monday, October 17, 2016 10:10 PM
• Hi Litdev !

this is my very first step for the noughts and crosses  challenge.

Computer start to play at center:

program no: FFZ090

• Edited by Saturday, October 22, 2016 4:15 PM
Saturday, October 22, 2016 4:09 PM
• This is my updated version of Tic-tac-toe: LBW762-13.

Nonki Takahashi

Monday, October 24, 2016 5:29 AM
• @Nonki

Great !!!  tic-tac-toe game !

Monday, October 24, 2016 2:29 PM
• Final version and it really works !

October challenge

Write a noughts and crosses game to play against the computer

• Perhaps add some nice graphics and sound effects to the game

program: XXK191

This version is most like a decision tree,  with Subs plus If and Then structure.

How to play:

computer start first, and using the keyboard , enter 1-9 for your turn play :

123

456

789

• Edited by Thursday, October 27, 2016 1:23 PM
Thursday, October 27, 2016 1:59 AM
• OXO or Noughts and Crosses is a video game developed by A S Douglas in 1952 for the Electronic Delay Storage Automatic Calculator (EDSAC) computer, which simulates a game of noughts and crosses, also called tic-tac-toe

good links to Wikipedia , OXO game history   ( oxo, tic-tac-toe, noughts and crosses  )

Early history of video games

Electronic delay storage automatic calculator

OXO

Thursday, October 27, 2016 2:53 PM
• Hi. My tic tac toe solution

program:BJX729

Saturday, October 29, 2016 3:22 AM
• Yled beautiful graphics and can't win.  only draw.

Saturday, October 29, 2016 10:20 AM
• @NaochanON

thanks !    have you like the sound effect for each turn?

yes, it's only a you can win version, computer start allways at the center.

One day, when I get to know SB a little more, I will re - write my program but in a more mathematical way,

to  keep track of the current 'state' of the game by using ' two dimensional arrays' like (1,1) to (9.9).

Greeting !

Saturday, October 29, 2016 3:19 PM
• Hi Gucerni !

very fine programming !

Saturday, October 29, 2016 4:53 PM