Challenge of the Month - March 2013
-
Friday, March 01, 2013 8:01 PMModerator
Welcome to the monthly SmallBasic Challenge!
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 SmallBasic. 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 SmallBasic 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.
Also post feedback on the kind of challenges that you want to see more of in the future.
Small Challenge 1
Write a program to ask the user for their age and date of birth. Confirm that they are telling the truth or not.
Small Challenge 2
Write a program to convert a user input text to a set of musical notes using the Sound.PlayMusic method.
Small Challenge 3
Write a program to calculate triangular numbers.
http://en.wikipedia.org/wiki/Triangular_number
Curriculum Challenge 1.2
Write a program that:
- Positions the TextWindow in the middle of the screen.
- Set the Pen colour to red and background colour to yellow.
- Asks for a number and then some text.
- Displays the input number (Cyan, column 10) and text (Green, column 30) in different colours on the same line at different column positions.
Graphical Challenge 1
Write a program to show a fire with flames.
Graphical Challenge 2
Write a program with an arrow that rotates to always point towards the mouse.
Physics Challenge
Make a graphical program with some scales and some blocks. When the user adds the blocks to the scales they will rotate to the heavier side.
Assume the blocks have the same density so their mass is proportional to their area so you can have different sized or shaped blocks.
If you fancy a harder challenge, then make a see-saw where the weights can be added at different distances from the central pivot.
Game Challenge
Write a copy of the classic Binatone football game (my favorite), or one of the others.
See http://www.youtube.com/watch?v=WKWRU-OPBa8.
Community Challenges (By Nonki)
(a) Paint graphics window with color gradations.
(b) Make a most simple web browser for a most simple HTML file.
(c) Make a program to simulate Brownian motion.
(d) Create a metronome.
Do you have an idea for a future challenge? Please post it here!
- Edited by litdevMicrosoft Community Contributor, Moderator Friday, March 01, 2013 8:08 PM
- Edited by litdevMicrosoft Community Contributor, Moderator Friday, March 01, 2013 9:07 PM
- Edited by litdevMicrosoft Community Contributor, Moderator Friday, March 01, 2013 9:15 PM
- Edited by litdevMicrosoft Community Contributor, Moderator Friday, March 01, 2013 9:30 PM
All Replies
-
Friday, March 01, 2013 11:22 PMAnswerer
GC 2:
SFP468
A spark to start a fire is necessary. But mainly you need dry kindling.
-
Saturday, March 02, 2013 8:54 AMModerator
Nice Zock77,
To center the image on 200,200 we can do this at the start:
ArrowImage = ImageList.LoadImage("http://cdn4.iconfinder.com/data/icons/markerstyle_icons/PNG/64px/arrow-right.png") Arrow = Shapes.AddImage(ArrowImage) width = ImageList.GetWidthOfImage(ArrowImage) height = ImageList.GetHeightOfImage(ArrowImage) Shapes.Move(Arrow,200-width/2,200-height/2)
-
Saturday, March 02, 2013 3:35 PM
'SC 3:
n=1
While n>0
TextWindow.WriteLine("Wich triangle number do you want to know.")
n=TextWindow.ReadNumber()
TextWindow.WriteLine("The number is "+(n*n/2+n/2)+".")
TextWindow.WriteLine("")
EndWhile
Program.End()- Edited by Flostian Saturday, March 02, 2013 3:36 PM
-
Saturday, March 02, 2013 3:55 PM
'SC 2:
'How to use: 'Write in the big box the notes you want to play ([Name of note]+[time]) 'Use "O"+[number] to change octaves. 'With the bottoms on the top you can here the notes (F2 -F8 have same effects (F1: one octave down, F9: one octave up)) 'Press LeftCtrl or I to insert the last played note. 'Click on the buttons 1-9 to write an other part of your song '(maybe part 1 strophe and part 2 refrain) 'Write in the box order the order of the parts '(maybe 121221222 (strophe,refrain,strophe,2x refrain,strophe,3x refrain)) 'Click on "start" to play the music 'Click on "Play just box" if you want to play only the choised box 'Click on "Play last [x] notes" to play just the last x notes of the choised box. GraphicsWindow.BackgroundColor="Yellow" GraphicsWindow.Height=600 GraphicsWindow.Width=1000 GraphicsWindow.CanResize="false" GraphicsWindow.Top=50 GraphicsWindow.Title="Music-creator by Flostian" GraphicsWindow.FontSize=35 GraphicsWindow.KeyDown=key Controls.ButtonClicked=Knopf a[1]="C" a[2]="D" a[3]="E" a[4]="F" a[5]="G" a[6]="A" a[7]="B" aktteil=1 For i=1 to 9 teilt[i]="" Endfor start=Controls.AddButton("Start!",60,500) For i= 1 To 7 ton[i]=Controls.AddButton(a[i],-40+i*100,30) EndFor For i= 1 To 9 part[i]=Controls.AddButton(i,100+i*80,330) EndFor GraphicsWindow.FontSize=45 GraphicsWindow.DrawText(60,330,"Part:") GraphicsWindow.FontSize=18 GraphicsWindow.DrawText(720,45,"octave:") O=Controls.AddTextBox(800,40) Controls.SetSize(O,30,30) Controls.SetTextBoxText(O,"5") m=Controls.AddmultilineTextBox(60,120) Controls.SetSize(m,880,100) Controls.SetTextBoxText(m,"O5 ") 'GraphicsWindow.DrawText(60,260,"Die letzten ") letzten=Controls.AddTextBox(160,256) Controls.SetSize(letzten,40,30) Controls.SetTextBoxText(letzten,"10") GraphicsWindow.DrawText(205,260,"notes") sple=controls.AddButton("Play last",60,254) GraphicsWindow.DrawBoundText(60,405,1000,"Order of parts:") ablauf=controls.AddTextBox(200,400) Controls.SetTextBoxText(ablauf,"1") box=Controls.AddButton("Play just box",395,254) Sub Knopf For i= 1 To 7 If ton[i]=Controls.LastClickedButton Then lo=Controls.GetTextBoxText(O) Sound.PlayMusic("O"+lo+" "+a[i]+"4") lt=i EndIf EndFor If Controls.LastClickedButton=box Then Sound.PlayMusic(Controls.GetTextBoxText(m)) EndIf If Controls.LastClickedButton=start Then stück="" teilt[aktteil]=Controls.GetTextBoxText(m) For i=1 To Text.GetLength(Controls.GetTextBoxText(ablauf)) stück=stück+teilt[Text.GetSubText(Controls.GetTextBoxText(ablauf),i,1)] EndFor Sound.PlayMusic(stück) EndIf If Controls.LastClickedButton=sple Then letztetöne=text.GetSubTextToEnd(controls.GetTextBoxText(m),Text.GetLength(Controls.GetTextBoxText(m))-3*Controls.GetTextBoxText(letzten)+1) okt=5 For i= 1 To (Text.GetLength(Controls.GetTextBoxText(m))+1)/3-Controls.GetTextBoxText(letzten)*3+1 If Text.GetSubText(Controls.GetTextBoxText(m),i*3-2,1)="O" Then okt=Text.GetSubText(Controls.GetTextBoxText(m),I*3-1,1) EndIf EndFor Sound.PlayMusic("O"+okt+letztetöne) EndIf For i=1 To 9 If Controls.LastClickedButton=part[i] Then teilt[aktteil]=Controls.GetTextBoxText(m) aktteil=i Controls.SetTextBoxText(m,teilt[i]) EndIf EndFor EndSub Sub key If GraphicsWindow.LastKey="LeftCtrl" Or GraphicsWindow.LastKey="I" Then 'Sound.PlayMusic("O"+lo+" "+a[lt]+"4") Controls.SetTextBoxText(m,controls.GetTextBoxText(m)+" O"+lo+" "+a[lt]+"4") EndIf For i=2 To 8 t="F"+i If GraphicsWindow.LastKey=t Then lo=Controls.GetTextBoxText(O) Sound.PlayMusic("O"+lo+" "+a[i-1]+"4") lt=i EndIf EndFor If GraphicsWindow.LastKey="F9" Then Controls.SetTextBoxText(O,(Controls.GetTextBoxText(O)+1)) EndIf If GraphicsWindow.LastKey="F1" Then Controls.SetTextBoxText(O,(Controls.GetTextBoxText(O)-1)) EndIf EndSubP.S.:Is there a way to play semi-tones?- Edited by Flostian Saturday, March 02, 2013 4:00 PM
-
Sunday, March 03, 2013 6:12 AM
Triangular number Challenge
'Challenge of the month : March 2013'By Amir'Date : 03-03-2013TextWindow.Title="Math Challenge [March 2013]"Main()GotostartSubMainTextWindow.Clear()TextWindow.Write("How many triangular numbers are you want to calculate? ")n_Upto=TextWindow.ReadNumber()Fori=0Ton_Upto-1sum=0Forj=1Toi+1sum=sum+jEndForTextWindow.WriteLine(sum)EndForEndSubstart:TextWindow.WriteLine("Try again with defferent value? Y or N")reply=TextWindow.Read()Ifreply="N"Orreply="n"Orreply="Y"Orreply="y"ThenIfreply="N"Orreply="n"ThenTextWindow.WriteLine("Exiting program...")Program.Delay(5000)Program.End()ElseMain()EndIfElseTextWindow.WriteLine("Enter Y or N only")GotostartEndIfGotostartMerry Xmas!
-
Sunday, March 03, 2013 11:04 AMModerator
@Flostian2 good answers - the triangular number is always an integer, you clever method produces a decimal which you could round to an integer using Math.Round before displaying.
Really good music player - the challenge was to input some text such as "Hello World" or "My name is Flostian" and somehow convert this to musical notes - I guess it was not clearly described, as you assumed to input the music notes as input which in this case creates a fine program and I like the layout and option to have different parts.
Interestingly this works:
Sound.PlayMusic("Hello World")Any ideas what is happening?
@Amir works well and nice use of Nonki's code formatting.
- Edited by litdevMicrosoft Community Contributor, Moderator Saturday, March 09, 2013 11:32 PM
-
Sunday, March 03, 2013 11:19 AMAnswerer
Interestingly this works:
Sound.PlayMusic("Hello World")Any ideas what is happening?
I believe it just tries to play what makes sense and ignores the rest.
I had once a microcomputer (MSX) which had those same micro music language as a string.
Although it could play 3 of them at the same time. SB seems just to play 1. =(
Also, it had a micro drawing language similar to Logo, but w/o a turtle.
Something like -> draw "U10 L90 U10 L90 U10 L90 U10"
Those micro commands would draw a square! :D
Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)
- Edited by GoToLoopEditor Sunday, March 03, 2013 11:20 AM
- Edited by GoToLoopEditor Sunday, March 03, 2013 11:20 AM
-
Sunday, March 03, 2013 2:51 PM
Interestingly this works:
Sound.PlayMusic("Hello World")Any ideas what is happening?
How about this? SZV536
notes= "HeyJude,dontmakeitbad,Takeasadsong,andmakeitbetter."
notes=notes+"Remembertoletherintoyourheart,Thenyoucanstart,tomakeitbetter"
notes= Text.ConvertToUpperCase(notes)For i=1 To Text.GetLength(notes)
d=Text.GetSubText(notes,i,1)
d_code= Text.GetCharacterCode(d)-64 ' charactercode
oct=math.Floor(d_code/8)
If oct>0 Then
octV="8O"+oct+4 ' 8 means pitch O4 means octave4
d=Text.GetCharacter(d_code-8*oct+64)
else
octv="8O4"
EndIf
NewNotes=text.Append(NewNotes,octv+d)
EndFor
TextWindow.WriteLine(NewNotes)Sound.PlayMusic(newnotes)
- Edited by NaochanON Sunday, March 03, 2013 2:55 PM
-
Monday, March 04, 2013 7:31 AM
Community Challenges (By Nonki) (d) Create a metronome
LWQ467-0 (renewed)
- Edited by NaochanON Monday, March 04, 2013 2:04 PM version upped
-
Monday, March 04, 2013 9:20 AMAnswerer
-
Monday, March 04, 2013 4:18 PMCurriculum Challenge 1.2 : LJN728
-
Monday, March 04, 2013 6:55 PMModerator@AshkoreDracson - spot on answer.
-
Monday, March 04, 2013 9:33 PM
My 2 favourite challenges so far, from Feb
Just finished the feb Text Challenge <The Random Password Generator> from last month.
see http://smallbasic.com/program/?FXJ326
It asks for the size of the password and how many numbers you want it to contain. Then randomly generates a text variable and number variable. Joins these 2 variables together and then randomly shuffles that to give the Randomly Generated Password.
My solution to feb math challenge 2
http://smallbasic.com/program/?HLB836
Using Babylon method and asks the user "to how many decimal places".
-
Tuesday, March 05, 2013 5:51 AMAnswerer
This is an alpha version of my game challenge: ZVL057.
You can only see this graphics.
Nonki Takahashi
-
Tuesday, March 05, 2013 9:28 AMAnswerer
I enabled paddles: ZVL057-0.
Press "S" and "D" for player 1, "K" and "L" for player 2.
This version is still alpha but I made it a clock for testing subroutines.
Nonki Takahashi
-
Tuesday, March 05, 2013 1:22 PMAnswerer
This is a beta version of my game challenge: ZVL057-1.
You can play the game with key "S", "D", "K" and "L". But not smooth...
Nonki Takahashi
- Edited by Nonki TakahashiEditor Tuesday, March 05, 2013 1:25 PM
-
Wednesday, March 06, 2013 3:38 AMAnswerer
This is the final version of my game challenge: ZVL057-2.
Use "S" and "D" for player 1, "K" and "L" for player 2.
In browser, click game screen once before playing.
Nonki Takahashi
-
Wednesday, March 06, 2013 9:52 PMAnswerer
Triangular number Challenge
'Challenge of the month : March 2013'By Amir'Date : 03-03-2013TextWindow.Title="Math Challenge [March 2013]"Main()GotostartSubMainTextWindow.Clear()TextWindow.Write("How many triangular numbers are you want to calculate? ")n_Upto=TextWindow.ReadNumber()Fori=0Ton_Upto-1sum=0Forj=1Toi+1sum=sum+jEndForTextWindow.WriteLine(sum)EndForEndSubstart:TextWindow.WriteLine("Try again with defferent value? Y or N")reply=TextWindow.Read()Ifreply="N"Orreply="n"Orreply="Y"Orreply="y"ThenIfreply="N"Orreply="n"ThenTextWindow.WriteLine("Exiting program...")Program.Delay(5000)Program.End()ElseMain()EndIfElseTextWindow.WriteLine("Enter Y or N only")GotostartEndIfGotostart
Merry Xmas!
How did you do this code formatting??
A spark to start a fire is necessary. But mainly you need dry kindling.
-
Wednesday, March 06, 2013 10:43 PMI'll give you a link to how to do it: http://social.technet.microsoft.com/wiki/contents/articles/15083.small-basic-forum-code-blocks.aspx
I am an 11 year old that knows Small Basic and is learning Java and C. 'Binary is as easy as 1, 10, 11.'
- Edited by Math Man Wednesday, March 06, 2013 10:43 PM
-
Thursday, March 07, 2013 8:32 AMAnswerer
This is an alpha version of my community challenge (b): DZH703.
Just shows source code of HTML.
Nonki Takahashi
-
Thursday, March 07, 2013 9:44 AMAnswerer
-
Thursday, March 07, 2013 1:30 PMAnswerer
-
Thursday, March 07, 2013 9:40 PMAnswerer
Football game: QPZ194
W and S For Player1
Up and Down For Player 2
A spark to start a fire is necessary. But mainly you need dry kindling.
- Edited by Zock77Editor Thursday, March 07, 2013 9:41 PM
-
Thursday, March 07, 2013 10:08 PMModerator
Great repros of the Binatone game.
If I remember correctly, one feature of this game is that if the ball is moving towards a goal, then the 'attacker' paddle doesn't bounce the ball back, but rather deflects its path 'like a shot' on the way to the goal, making it harder for the defending 'goal keeper' paddle to defend. I think the deflection also depended on whether the attacking paddle is moving down or up as the ball passes through it.
@Nonki - for your game perhaps use keydown and keyup events to eliminate the repeat key delay.
- Edited by litdevMicrosoft Community Contributor, Moderator Thursday, March 07, 2013 10:13 PM
- Edited by litdevMicrosoft Community Contributor, Moderator Thursday, March 07, 2013 10:27 PM
-
Friday, March 08, 2013 1:39 AM
Community Challenges (By Nonki)
(a) Paint graphics window with color gradations. All shapes type. ZCX763
-
Saturday, March 09, 2013 11:56 PMOwner
I'll give you a link to how to do it: http://social.technet.microsoft.com/wiki/contents/articles/15083.small-basic-forum-code-blocks.aspx
I am an 11 year old that knows Small Basic and is learning Java and C. 'Binary is as easy as 1, 10, 11.'
Math Man, what's the pain of the editor that you mention in a comment on that page? We want to turn all the pains into precise bugs that we can get fixed. We have to identify the specific issues.
Thanks!
Ed Price (a.k.a User Ed), SQL Server Customer Program Manager (Blog, Small Basic, Wiki Ninjas, Wiki)
Answer an interesting question? Create a wiki article about it! -
Sunday, March 10, 2013 12:03 AMIt used to be that it would not let you scroll up or down in the wiki-editor. Apparently now they've got that fixed, though.
I am an 11 year old that knows Small Basic and is learning Java and C. 'Binary is as easy as 1, 10, 11.'
-
Sunday, March 10, 2013 12:28 AMOwner
I did my first Blog feature of this challenge: http://blogs.msdn.com/b/smallbasic/archive/2013/03/09/create-a-metronome-in-small-basic-community-challenge.aspx
I'd also like to feature the game, flames, and the arrow challenge in later blog posts.
Thanks everyone!
Ed Price (a.k.a User Ed), SQL Server Customer Program Manager (Blog, Small Basic, Wiki Ninjas, Wiki)
Answer an interesting question? Create a wiki article about it!- Edited by Ed Price - MSFTMicrosoft Employee, Owner Sunday, March 10, 2013 12:30 AM
-
Sunday, March 10, 2013 9:08 AMAnswerer
Thanks litdev,
I changed a little not to kick back by attacking paddle. But kept to use keydown because I need repeat key to control paddles.
Program ID: ZVL057-3
Nonki Takahashi
- Edited by Nonki TakahashiEditor Sunday, March 10, 2013 9:09 AM
-
Sunday, March 10, 2013 10:23 AM
I started challenge number 1, and then realised it would be harder then I thought... How do computers compare dates to determine order? Also, can someone remind me how to post code from SB editor to here and maintain formatting? When I copy and paste, there are extra lines between code, and when I use the post code box above, SB is not on the dropdown menu...
'March 2013 challenge 1 'Robin Andrews TextWindow.Writeline("Enter DOB in this format:dd/mm/yyyy") DOB = textwindow.read() TextWindow.WriteLine("Thank you. Now enter your age in years") givenAge = TextWindow.ReadNumber() ' year = Text.getsubtext(DOB,Text.GetLength(DOB)-3,4) actualAge=2013-year If givenAge=ActualAge Then TextWindow.WriteLine("You told the truth!") Else TextWindow.writeline("liar!") EndIf TextWindow.Write(actualAge)Kind Regards,
Robin.
-
Sunday, March 10, 2013 10:30 AMAnswerer
This is a hint for community challenge (c):
What is the most appropriate Small Basic object to show Brownian motion?
Nonki Takahashi
-
Sunday, March 10, 2013 5:56 PMWhen you do "Insert codeblock", you don't have to select a language. Just click in the left window and paste your code.
Jan [ WhTurner ] The Netherlands
-
Sunday, March 10, 2013 6:29 PMAnswerer
When you do "Insert codeblock", you don't have to select a language. Just click in the left window and paste your code.
I disagree w/ that! When you post w/o specifying a codeblock type, you can see how confusing the result is looking at Robinmujician's post!
More than half of it is completely green!!!
I generally choose VB.net when posting codes here! :D
Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)
- Edited by GoToLoopEditor Sunday, March 10, 2013 6:30 PM
- Edited by GoToLoopEditor Sunday, March 10, 2013 6:30 PM
-
Monday, March 11, 2013 1:26 PMAnswerer
Robin,
Have you ever use Microsoft Office Excel? In Excel, internal value of 01/01/1900 is 1. 02/01/1900 is 2. Internally computer compares dates as integers. But Small Basic doesn't have this kind of conversion function between date and integer (days from such as 31/12/1989). So we should write it.
Nonki Takahashi
- Edited by Nonki TakahashiEditor Monday, March 11, 2013 1:30 PM
-
Monday, March 11, 2013 5:55 PM
I made some time ago a subroutine which calculates the number of days between two given dates:
Sub ddelta '' calculate the number of days from one date upto the second date '' input: y1 m1 d1 and y2 m2 d2 year, month and day for the two dates '' output: dd number of days '' all local variables start with _ (underscore) ''============================================= _mm="1=31;2=0;3=31;4=30;5=31;6=30;7=31;8=31;9=30;10=31;11=30;12=31" _i=y1 leap() _mm[2]=29-lp ''leapyear correction first year If y1=y2 Then ''begin and end year equal If m1=m2 Then ''begin and end month equal dd=d2-d1 Else dd=_mm[m1]-d1 ''days to the end of the first month For _i=m1+1 To m2-1 '' full months between begin and end month dd=dd+_mm[_i] EndFor dd=dd+d2 ''days in the last (partial) month EndIf Else dd=_mm[m1]-d1 For _i=m1+1 To 12 ''rest of the year dd=dd+_mm[_i] EndFor For _i=y1+1 To y2-1 ''full years between begin and end date leap() dd=dd+366-lp EndFor _i=y2 leap() _mm[2]=29-lp For _i=1 to m2-1 ''first full months in the last year dd=dd+_mm[_i] EndFor dd=dd+d2 EndIf EndSub ''ddelta Sub leap '' output: lp=1 for non-leapyears and =0 for leapyears lp=Math.Ceiling(Math.Remainder(_i,4)/4) if Math.Remainder(_i,100)=0 Then lp=1 EndIf If Math.Remainder(_i,400)=0 Then lp=0 EndIf EndSub
You can use this as a start for further programs
Jan [ WhTurner ] The Netherlands
- Edited by WhTurner33 Monday, March 11, 2013 5:56 PM
-
Monday, March 11, 2013 7:29 PMModerator
To check if some-one's age is consistent with their date of birth doesn't really need to do a complex number of days difference.
For a given age you can work out the earliest and latest birth date and just check against this.
-
Friday, March 15, 2013 2:36 AMAnswerer
This is a hint for community challenge (c):
What is the most appropriate Small Basic object to show Brownian motion?
Nonki Takahashi
Second hint for community challenge (c):
You can write this program in four lines.
Nonki Takahashi
-
Friday, March 15, 2013 9:27 AM
My solution to Small Challenge 3 Write a program to calculate triangular numbers.
http://smallbasic.com/program/?LZB311
It has a bug in it.
It seems that if you type in a number that's too big it returns an Error that mentions something about a decimal point or something. I thought it might have something to do with the answer being returned to the "answer textBox" being larger than the textBox size, but i'm not sure.
Does anyone know what's happening to cause this error?
-
Friday, March 15, 2013 2:16 PM
I used a different method.
TextWindow.Write("Enter your Age: ") inputAge = TextWindow.Read() TextWindow.Write("Enter the year were you born: ") inputYOB = TextWindow.Read() TextWindow.Write("Enter the month were you born in: ") inputMOB = TextWindow.Read() TextWindow.Write("Enter the day were you born on: ") inputDayOB = TextWindow.Read() sysYear = Clock.Year sysMonth = Clock.Month sysDay = Clock.Day years = sysYear - inputYOB 'needs to equal inputAge to be true months = sysMonth - inputMOB 'needs to be <= sysMonth to be true days = sysDay - inputDayOB 'if input MOB = sysMonth then needs to be < 0 to be false If inputAge = years And inputMOB <= sysMonth Then If inputMOB = sysMonth Then If days < 0 Then noMatch() Goto end EndIf If days = 0 Then TextWindow.WriteLine("happy bd") EndIf EndIf TextWindow.WriteLine("Age and DOB given MATCH") Else noMatch() end: EndIf Sub noMatch TextWindow.WriteLine("Age and DOB do not match") EndSub -
Friday, March 15, 2013 7:34 PMModerator
Good method, but what if I say I am 10, born on 1 November 2002?
I am 10 for any date between 15/3/2002 and 15/3/2003.
-
Saturday, March 16, 2013 1:22 AM
litdev, thanks for the code check.
I tested it and can't see the problem you predict.
To test this prediction i reset the variable sysYear = 2002 'Clock.Year
http://smallbasic.com/program/?NNZ780
If your prediction is true could you elaborate.
If your prediction is false do you think the logic could've been set out a better way to read.
Thanks
-
Saturday, March 16, 2013 3:13 AM
Small Challenge 2
Write a program to convert a user input text to a set of musical notes using the Sound.PlayMusic method.
Interesting.Question: is there an event or a way i can allow the user to break the While loop or End the program in the TextWindow or can this only be done in the GraphicsWindow?
TextWindow.Write("Enter some characters: ") input = TextWindow.Read() i = 1 While i = 1 Sound.PlayMusic(input) EndWhile -
Saturday, March 16, 2013 6:56 AMHow did you work out the width of the textWindow?
-
Saturday, March 16, 2013 10:02 AMIf you change in the While-loop the variable i to any value but 1, the loop ends.
Jan [ WhTurner ] The Netherlands
-
Saturday, March 16, 2013 7:03 PM
Yes, but i was wondering if the user could input something while the program is running to break it.
Like <<Press Enter to Stop>>
if you know what i mean.
-
Sunday, March 17, 2013 9:45 PMOwner
I finally got a second blog post up to "advertise" this contest. It's about Zock's arrow program:
The game and fire challenges are also cool.
Did anybody do the sound challenge yet?
Thanks!
Ed Price (a.k.a User Ed), SQL Server Customer Program Manager (Blog, Small Basic, Wiki Ninjas, Wiki)
Answer an interesting question? Create a wiki article about it! -
Monday, March 18, 2013 4:19 PM
My version of challenge#3:
RXN233
Very similar to 4mirs, but I didn't look until I'd done it myself!
-
Tuesday, March 19, 2013 1:22 AMAnswerer
This is a hint for community challenge (c):
What is the most appropriate Small Basic object to show Brownian motion?
Nonki Takahashi
Second hint for community challenge (c):
You can write this program in four lines.
Nonki Takahashi
This is a sample screen shot:
Can you find something in the screen?
Nonki Takahashi
-
Tuesday, March 19, 2013 2:27 AMAnswerer
This is an alpha version of my physics challenge: VGK484.
You can move blocks with mouse. But scale doesn't move yet.
Nonki Takahashi
-
Tuesday, March 19, 2013 2:35 AMAnswerer
This is my Small Challenge 1: FDK603.
Age Checker v0.1
It's 19/03/2013 today.
Your age? 51
Your date of birth (dd/mm/yyyy)? 19/07/1961
Your age is correct.
It's 19/03/2013 today.
Your age?Nonki Takahashi
-
Tuesday, March 19, 2013 6:09 AM
Physics Challenge QRR040
Make a graphical program with some scales and some blocks.
This is not finished. but if click and move a larg block and release it on the plate,
the scale swings and finally stops.
-
Wednesday, March 20, 2013 3:17 AMAnswerer
This is a beta version of my community challenge (a): VFP128.
Nonki Takahashi
I published another beta version of community challenge (a): VFP128-0
Added angle textbox. You can input 0<= angle <= 45 [degree].
For other angles, I'm going to normalize them between 0..45 and use same subroutines.
Nonki Takahashi
-
Thursday, March 21, 2013 5:53 AM
Physics Challenge QRR040
This is not finished
Finished. QRR040-1
* Scale swings. But You can move weight to adjust balance.
-
Saturday, March 23, 2013 7:06 AMAnswerer
This is an alpha version of my physics challenge: VGK484.
You can move blocks with mouse. But scale doesn't move yet.
Nonki Takahashi
This is a final version of physics challenge: VGK484-2.
Nonki Takahashi
- Edited by Nonki TakahashiEditor Saturday, March 23, 2013 9:37 AM silverlight
-
Saturday, March 23, 2013 12:46 PMAnswerer
This is a beta version of my community challenge (a): VFP128.
Nonki Takahashi
I published another beta version of community challenge (a): VFP128-0
Added angle textbox. You can input 0<= angle <= 45 [degree].
For other angles, I'm going to normalize them between 0..45 and use same subroutines.
Nonki Takahashi
This is the final version of my community challenge (a): VFP128-1
Nonki Takahashi
-
Tuesday, March 26, 2013 6:04 PM
Suggestion for April 2013 Challenge:
Small Basic Showcase Challenge (Beginners to Experienced) for April 2013
Write an interactive program that allows the user to run some of your favourite challenges from one program.
-
Friday, March 29, 2013 12:21 PMAnswerer
These are my ideas for a future challenge:
(1) Draw the net of a die (dice).
(2) Draw a picture of a flower.
(3) Draw a picture of a car.
Nonki Takahashi
-
Friday, March 29, 2013 1:27 PM
My idea for future challenge
Write a program to validate date input.
Merry Xmas!
-
Saturday, March 30, 2013 12:57 AM
Small Challenge 1
WXH412 (My entry)I had a problem with it, it isn't exactly precise... it is only accurate if it's after the user's birthday. I contemplated if it could be fixed, but i came up with nothing. any idea how i could make it more precise?
Small Basic Beginner. :3
-
Saturday, March 30, 2013 3:46 PMAnswerer
8BiT PoNy,
Your program is very good and simple. But if you need accurate result, you should ask birth date and check the date is before or after today.
Please refer my sample FDK603. Core of this code is:
If (month = tm And day <= td) Or (month < tm) Then ageFromBod = diff Else ageFromBod = diff - 1 EndIfwhile td = today's day, tm = today's month, day = bd's day, month = bd's month.
Caution: FDK603 has bug comparing day with tm (td is correct as above).
Nonki Takahashi
- Edited by Nonki TakahashiEditor Saturday, March 30, 2013 3:57 PM
-
Sunday, March 31, 2013 3:17 AM
Game Challenge RZD792 *Note :This is not same as Binatone. PC vs Player(you) type.
Can you win to PC? Enjoy.
- Edited by NaochanON Sunday, March 31, 2013 3:26 AM Link added
-
Sunday, March 31, 2013 5:37 AM
I just redid the Small Challenge 1, Write a program to ask the user for their age and date of birth. Confirm that they are telling the truth or not.
http://smallbasic.com/program/?FMZ566
Hopefully I got it right this time. Appreciate any fb on this program, I did a bit of experimenting.
The Challenges are great as usual, look forward to April. I noticed Nonki has suggested 3 graphical's for next month. I've been avoiding the graphic challenges so far (except the Welcome screen), because they've looked pretty hard. I'm definitely going to do one next month. Might have to get some tips, I noticed before how MathMan used arrays and Nonki was using Trig in one of his.
Thanks and happy long weekend.
-
Sunday, March 31, 2013 5:50 AM
@ 4mir '
Good idea. I just did a bit of this in: http://smallbasic.com/program/?FMZ566
It's interesting because there's a lot of checks you can do. A lot, but finite.
e.g. apart from the usual format check like dd/mm/yyyy
you can also check for:
- 30 days has September, April, June and etc....
- leap years http://en.wikipedia.org/wiki/List_of_leap_years
Could be a good program to put in a program library. I think this is a necessary check for the Age & DOB validation challenge above, Small Challenge 1.
-
Monday, April 01, 2013 5:06 AM
Jibba Jabba~
We're all here to help with any questions you have! Don't hesitate to ask for a tip or to get insight on a keyword!
I can write 1000 lines of code in roughly 10 seconds. Here's how:
i = 1
For i = 1 to 1000
TextWindow.WriteLine("Code")
Program.Delay(10)
EndFor
Make Sense? -
Monday, April 01, 2013 7:09 AM
Hey NaochanON nice program. Runs really well.
Your code seems really organised and easy to read.
A bit advanced for me but is the variable s=1 for scaling?
- Edited by Jibba Jabba Monday, April 01, 2013 7:21 AM
-
Monday, April 01, 2013 7:51 AM
Hey NaochanON nice program. Runs really well.
Your code seems really organised and easy to read.
A bit advanced for me but is the variable s=1 for scaling?
Thank you for you reply.
Yes, "s" is for scaling. If s<=1 , it works well, but not if s>1.
BTW , Could you win to PC? ( I can't ever)
- Edited by NaochanON Monday, April 01, 2013 7:52 AM
-
Monday, April 01, 2013 8:28 AM
@ NaochanON
No PC wins. But if I played it a bit more I reckon I could. Love how it speeds up as well.
Feedback for you:
- Some games have beginner, intermediate and expert mode.
- Also I've got a touch pad so when the cursor is out of the graphicsWindow I lose control. Could you wire up the mouseMove event to the Left and Right Arrow keys as well as to the mouse? and set windowResize = "false". Maybe?
Top game, a keeper. No bugs. Very tight and smooth.
I like checking out the code of more experienced programmers. If it's ok with you i'd like to put a copy of your program with reference to you (of course) in my notes?
-
Monday, April 01, 2013 1:14 PM
@ NaochanON
No PC wins. But if I played it a bit more I reckon I could. Love how it speeds up as well.
Feedback for you:
- Some games have beginner, intermediate and expert mode.
- Also I've got a touch pad so when the cursor is out of the graphicsWindow I lose control. Could you wire up the mouseMove event to the Left and Right Arrow keys as well as to the mouse? and set windowResize = "false". Maybe?
Top game, a keeper. No bugs. Very tight and smooth.
I like checking out the code of more experienced programmers. If it's ok with you i'd like to put a copy of your program with reference to you (of course) in my notes?
Mode selection, Arrow key used playing style, Disable windowresize ...... Now I'm fixing the program.
New version will be uploaded soon. You may copy, refer useful codes.
-
Monday, April 01, 2013 1:54 PM
Small Challenge 1 How about this?
Age=17 ' Age= textwindow.read()
dob="02/05/1993" ' dob =textwindow.read()
'------------ Today --------------- 01/04/2013 ----
thisday = Clock.Day
thismonth = Clock.Month
thisyear = Clock.Year
'-------------- entered Birth day ------------
day = Text.GetSubText(dob, 1, 2)
month = Text.GetSubText(dob, 4, 2)
year = Text.GetSubText(dob, 7, 4)
'---------------- Calculation of Age ------------------
If thismonth>month Then
calcAge= thisyear-year
ElseIf thismonth=month then
If thisday>=day then
calcAge= thisyear-year
EndIf
Else
calcAge= thisyear-year-1
EndIf
TextWindow.WriteLine(" Calculated Age = "+calcAge)
'------------------------------------------------------------------
If Age=calcAge Then
TextWindow.WriteLine(" Correct ")
Else
TextWindow.WriteLine(" Incorrect ")
EndIf -
Monday, April 01, 2013 9:00 PM
NaochanON
Looks like a good method. I'll check it out. Thanks.
-
Saturday, April 06, 2013 11:57 PM
Mode selection, Arrow key used playing style, Disable windowresize ...... Now I'm fixing the program.
New version will be uploaded soon. You may copy, refer useful codes.
Added Level selection .....RZD792-1
and arrow key version .... JHJ100-0
- Edited by NaochanON Sunday, April 07, 2013 12:06 AM added link

