none
Challenge of the Month - May 2013 RRS feed

  • General discussion

  • 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.

    Curriculum Challenge 1.4

    (1) Write a program that loops through the first 100 numbers, 1, 2, 3 ... 99, 100.  It then Writes out to the TextWindow every number that is a multiple of 3 or 7.

    (2) Write a program that gets some text input by the user and loops through each character and counts the number of vowels a, e, i, o or u.

    Small Challenge 1

    Write a program that finds all the numbers less than 1000 that contain only digits that sum to 10, e.g. 55, 73, 136, but not 423.  How many are there?

    Small Challenge 2 (from last month)

    Write a program to play a 'guess the word' game, by obtaining Flickr pictures of the word and displaying them, or displaying part of the dictionary definition of the word, or the number of letters in the word, or which vowels it contains or any other hints you can think of.  Give each hint out and check if the guess is right before giving a new hint.

    Intermediate Challenge 1

    Write a program to display a menu that a till operator might use in a restaurant.  They click on the items the customer wants and it works out the bill.

    Physics Challenge

    Back to basics - write a program where a ball can roll down an inclined slope - use an image for the ball and show it rotating as it accelerates while rolling.  To make it tougher try the ball on different angled slopes - it should accelerate faster on the steeper slopes.

    Game Challenge

    Write a clone of the MS game MineSweep.

    Community Suggestion 1 (By Nonki)

    (1) Make a simple addition game with 20 questions (from 1+1 to 9+9) and measuring time.

    (2) Draw a picture of the earth and the moon.

    (3) Make a 30-second animation.

    Community Suggestion 2 (By NaochanON)

    Make a shape (for example ; car, man, animal...etc), move, and rotate it.

    Image....   below.

    Community Suggestion 3 (By Jibba Jabba)

    (1) Curriculum Challenge 3.4 Events and Interactivity.

    Write an email address validation program.  And maybe invite/challenge other members to test and break it.

    (2) Graphical Challenge

    Draw a house with doors, windows etc that when you click on them you turn the lights on, open/close the doors etc.

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



    Wednesday, May 1, 2013 5:48 PM
    Moderator

All replies

  • Re above: "The Curriculum seems to have disappeared, if anyone has a copy or knows where it is now,.."

    Litdev, the disappearing curriculum seems to have been fixed.

    8bit has kindly posted the link. Here it is: http://social.technet.microsoft.com/wiki/contents/articles/16299.small-basic-curriculum.aspx

    And so I don't forget for next month, ICT2COMP_Teacher posted a good challenge. http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/6dc63173-f157-4390-b2aa-8cebb9c83150/

    Wednesday, May 1, 2013 9:09 PM
    Moderator
  • Sorry my mistake copy+paste from last month - thanks
    Wednesday, May 1, 2013 10:21 PM
    Moderator
  • Just finished (1) of Curriculum Challange 1.4. it's a bit rough, but it counts to 100, then it counts the multiples of 3 in 3 to 99, then it counts the multiples of 7 in 7 to 98. import it: HTS885

    or, use it here: http://smallbasic.com/program/?HTS885


    Small basic beginner today, expert tomorrow.

    Thursday, May 2, 2013 12:00 AM
  • okay, so i've ran into a problem with my entry for curriculum Challenge (2). I think i've wrote the code alright, but it doesn't work the way i want it to. the output i want, is it to show how many vowels are in the text the user writes. eg "number of "a" in text: 3"
    Here's the code:

    TextWindow.WriteLine("Hey! enter in some text, and i'll tell you how many vowels are present.")
    txt = TextWindow.Read()
    
    txt1 = Text.ConvertToLowerCase(txt)
    vowele= Text.GetIndexOf(txt1, "a") 
    vowelr= Text.GetIndexOf(txt1, "e")
    vowelt= Text.GetIndexOf(txt1, "i")
    vowely= Text.GetIndexOf(txt1, "o")
    vowelu= Text.GetIndexOf(txt1, "u")
    TextWindow.WriteLine("how many times 'a' comes up: " + vowele)
    TextWindow.WriteLine("how many times 'e' comes up: " + vowelr)
    TextWindow.WriteLine("how many times 'i' comes up: " + vowelt)
    TextWindow.WriteLine("how many times 'o' comes up: " + vowely)
    TextWindow.WriteLine("how many times 'u' comes up: " + vowelu)

    and the output of the program is:

    if anyone could help, that would be great.


    Small basic beginner today, expert tomorrow.

    Thursday, May 2, 2013 1:14 AM
  • Your program gives the position of each vowel in the inputstring, not the number.

    Jan [ WhTurner ] The Netherlands


    Thursday, May 2, 2013 7:39 AM
    Answerer
  • Do something like this:
    Text = "There is some text here."
    
    TextWindow.WriteLine("Text = " + Text)
    
    For i = 1 To Text.GetLength(Text)
      TempText = Text.GetSubText(Text,i,1)
      If TempText = "A" Or TempText = "a" Then
        NumAs = NumAs + 1
      ElseIf TempText = "E" Or TempText = "e" Then
        NumEs = NumEs + 1
      ElseIf TempText = "I" Or TempText = "i" Then
        NumIs = NumIs + 1
      ElseIf TempText = "O" Or TempText = "o" Then
        NumOs = NumOs + 1
      ElseIf TempText = "U" Or TempText = "u" Then
        NumUs = NumUs + 1
      EndIf
    EndFor
    
    TextWindow.WriteLine("how many times 'a' comes up: " + NumAs)
    TextWindow.WriteLine("how many times 'e' comes up: " + NumEs)
    TextWindow.WriteLine("how many times 'i' comes up: " + NumIs)
    TextWindow.WriteLine("how many times 'o' comes up: " + NumOs)
    TextWindow.WriteLine("how many times 'u' comes up: " + NumUs)



    It is written: "'As surely as I live,' says the Lord, 'every knee will bow before me; every tongue will acknowledge God.'" Romans 14:11

    Thursday, May 2, 2013 2:50 PM
    Answerer
  • litdev, thank you for posting this challenge again.

    This is my small challenge 2: BDK263.

    This program need to be run in local and commented in for File object lines.


    Nonki Takahashi

    Friday, May 3, 2013 4:16 AM
    Moderator
  • hi 8bit,

    Great solution to Curriculum Challenge 1.4 (1) Write a program that loops through the first 100 numbers, 1, 2, 3 ... 99, 100.  It then Writes out to the TextWindow every number that is a multiple of 3 or 7.

    Great because you used the most direct method of solving it, using Steps of 3 and 7.

    I completely overlooked this approach and started using the Math object, created my 1st 2 dimensional array and went "overboard" with user input prompting (declaring variables) and output. No regrets on my part though because I learnt a lot. I'll post my solution below.

    Thanks for posting your solution, I never would've thought of using step. :)

    Friday, May 3, 2013 9:05 AM
    Moderator
  • My very complicated solution to the 1st challenge: (1) Write a program that loops through the first 100 numbers, 1, 2, 3 ... 99, 100.  It then Writes out to the TextWindow every number that is a multiple of 3 or 7.

    Caution: reading this code my cause headaches. http://smallbasic.com/program/?PGM326

    My approach was:

    1. write using reusable code. The calculation routine contains no constants except for counters.
    2. allow the user to declare all the variables.
    3. hold all the results in 1 variable. Wow those multidimensional arrays are amazing.
    4. no compromise on the format and flow of the user input. Reason: small basic is powerful so if you want it to do something then it can be done (within reason of course). This "no compromise" resulted in a time consuming 147 lines of code. Both input and output routines could be revised. Probably worth doing as an exercise.

    Very enjoyable challenge as it led me to create my 1st 2 dimensional array.

    Would love to hear some comments/wisdom on when compromising a solution for the purpose of simplifying the code is a good way to go.??

    Friday, May 3, 2013 9:38 AM
    Moderator
  • What do you think of this?

    For i = 1 To 100
      If Math.Remainder(i,7) = 0 Or Math.Remainder(i,3) = 0 Then
       y = y + 1
       Num[y] = i
      EndIf
    EndFor
    
    For t = 1 To y
      TextWindow.WriteLine(Num[t])
      EndFor


    It is written: "'As surely as I live,' says the Lord, 'every knee will bow before me; every tongue will acknowledge God.'" Romans 14:11

    Friday, May 3, 2013 2:07 PM
    Answerer
  • I like.:) Basically the same method.

    Instead of using Or I stored "Math.Remainder(i,3)" 3 in divisibleBy[1]. Allows user to input as many multiples as they want.

    And used answer[n][divisibleBy[j]] instead of Num[y], to return the answers with the associated multiple.

    What freaked me out is the amount of effort to control the textWindow UI. Unreal. Trying to maintain grammar and punctuation. e.g. Returning: 5, 6, 7 and 8. Or just 5 and 7. Or simply 6. Then substituting a conditional red * at the prompt when a input error occured. So much code for 3 user variables.

    Thanks for your sample. I like how the value of y just carries forward to the next loop. I'm just starting to learn something every time i look at someone else's code.

    checkIntegersFrom = 1
    checkIntegersTo = 100
    divisibleBy = "1=3;2=7"
    
    For j = 1 To Array.GetItemCount(divisibleBy)
      For i = checkIntegersFrom To checkIntegersTo      
        If Math.Remainder(i, divisibleBy[j]) = 0 Then
          n = n + 1
          answer[n][divisibleBy[j]] = i
        EndIf
      EndFor
    EndFor
    
    TextWindow.Write(answer)

    Friday, May 3, 2013 3:16 PM
    Moderator
  • I guess it give you the place of the numbers
    Friday, May 3, 2013 7:41 PM
  • Okay, thanks every one for your help! Zock, thanks alot! it's now up and working. import it: BWB179

    or, use it here: http://smallbasic.com/program/?BWB179

    oh, and thanks JibbaJabba. :3


    Small basic beginner today, expert tomorrow.

    Friday, May 3, 2013 10:33 PM
  • No prob!

    It is written: "'As surely as I live,' says the Lord, 'every knee will bow before me; every tongue will acknowledge God.'" Romans 14:11

    Saturday, May 4, 2013 12:36 AM
    Answerer
  • Minesweeper:

    GraphicsWindow.Width=480
    GraphicsWindow.Height=480
    GraphicsWindow.Top=110
    GraphicsWindow.Left=Desktop.Width/2-240
    GraphicsWindow.Title="Please Wait"

    GraphicsWindow.BrushColor=GraphicsWindow.GetColorFromRGB(100,200,1)
    h=Shapes.AddRectangle(480,480)
    Shapes.SetOpacity(h,50)

    GraphicsWindow.KeyDown=key

    af=0

    rf=256

    na[1]=-17
    na[2]=-1
    na[3]=15
    na[4]=16
    na[5]=-16
    na[6]=-15
    na[7]=1
    na[8]=17


    For I=1 To 256
      f[i]=1
    EndFor

    For i=1 to 256
    fz[i]=0
    endfor

    For i= 1 to 40
    neu:
    zz=math.GetRandomNumber(256)
    If fz[zz]=-1 Then
      Goto neu
    EndIf

    fz[zz]=-1

    For j=1 To 8
    If fz[zz+na[j]]>-1 Then
    fz[zz+na[j]]=fz[zz+na[j]]+1
    EndIf
    EndFor
    If math.Remainder(zz,16)=1 Then
      For k=1 To 3
      If fz[zz+na[k]]>-1 Then
      fz[zz+na[k]]=fz[zz+na[k]]-1
      endif
      EndFor
    EndIf
    If math.Remainder(zz,16)=0 Then
      For k=6 To 8
      If fz[zz+na[k]]>-1 Then
      fz[zz+na[k]]=fz[zz+na[k]]-1
      endif
      EndFor
    EndIf

    endfor  

    GraphicsWindow.FontSize=30

    GraphicsWindow.PenWidth=0
    o=0
    For i= 1 to 16
    For j=1 to 16
      o=o+1
      If fz[o]>0 then
      GraphicsWindow.BrushColor=GraphicsWindow.GetColorFromRGB(fz[o]*60,0,225-60*fz[o])
      hin[o]=Shapes.addText(fz[o])
      Shapes.HideShape(hin[o])
      Shapes.Move(hin[o],j*30-28,i*30-33)
      endif
    EndFor
    endfor

    GraphicsWindow.PenWidth=2
    GraphicsWindow.BrushColor="blue"
    For i=1 To 256
    d[i]=Shapes.AddRectangle(30,30)
    dx=math.Remainder((i-1),16)
    dy=Math.Floor((i-1)/16)
    shapes.animate(d[i],(dx)*30,(dy)*30,100*math.SquareRoot(dy*dy+dx*dx))
    EndFor

    Program.Delay(2500)

    For i=1 to 256
    Shapes.ShowShape(hin[i])
    endfor

    For i=1 to 15
      GraphicsWindow.DrawLine(30*i,0,30*i,480)
      GraphicsWindow.DrawLine(0,30*i,480,30*i)
    EndFor

    GraphicsWindow.PenColor="red"
    GraphicsWindow.PenWidth=5
    GraphicsWindow.BrushColor="blue"
    for i= 1 to 16
      For j=1 To 16
        k[i*16+j]=Shapes.AddEllipse(24,24)
        Shapes.SetOpacity(k[i*16+j],0)
        Shapes.Move(k[i*16+j],j*30-27,i*30-27)
      EndFor
    endfor

    GraphicsWindow.Title="Minesweeper"
    Sound.PlayChimes()
    GraphicsWindow.MouseDown=Mo


    '-----------------------------------------------------------------------------------------------------------


    Sub mo
      ziel=1+math.Floor(GraphicsWindow.MouseX/30)+16*Math.floor(GraphicsWindow.MouseY/30)
      If Mouse.IsLeftButtonDown And f[ziel]=1 Then
        Sound.PlayClick()
        Shapes.Remove(d[ziel])
        f[ziel]=0

        If fz[ziel]=-1 Then
          gameover()
        EndIf

        If fz[ziel]=0 Then
          r=ziel
          oeffnenachbarn()
        EndIf

      EndIf

      If Mouse.IsRightButtonDown and f[ziel]<>0 Then
        Sound.PlayClick()
        If f[ziel]=1 Then
          Shapes.SetOpacity(k[ziel+16],100)
          f[ziel]=2
          af=af+1
          GraphicsWindow.Title="Minesweeper - mines found: "+af+"/40"
          Goto weiter
        EndIf
        If f[ziel]=2 Then
          Shapes.SetOpacity(k[ziel+16],0)
          f[ziel]=1
          af=af-1
          GraphicsWindow.Title="Minesweeper - mines found: "+af+"/40"
        EndIf
        weiter:
      EndIf

      If Mouse.IsLeftButtonDown And f[ziel]=0 And fz[ziel]=0 Then
        r=ziel
        oeffnenachbarn()
      EndIf


    EndSub

    Sub gameover
      GraphicsWindow.Clear()
      GraphicsWindow.BackgroundColor="Yellow"
      GraphicsWindow.PenWidth=0
      GraphicsWindow.BrushColor="orange"
      Shapes.addTriangle(0,240,310,170,310,310)
      Shapes.AddTriangle(240,0,310,310,170,310)
      Shapes.AddTriangle(480,240,170,310,170,170)
      Shapes.AddTriangle(240,480,170,170,310,170)
      Shapes.AddTriangle(90,90,170,310,310,170)
      Shapes.AddTriangle(390,390,310,170,170,310)
      Shapes.AddTriangle(390,90,170,170,310,310)
      Shapes.AddTriangle(90,390,170,170,310,310)
      GraphicsWindow.Title="Minesweeper - Gameover"
      Sound.PlayMusic("o1 c9")
      a=1
      Timer.Interval=30
      Timer.Tick=we
    EndSub

    Sub oeffnenachbarn
      start=1
      letzte=8
      If math.Remainder(r,16)=0 Then
        letzte=5
      EndIf
      If math.Remainder(r,16)=1 Then
        start=4
      EndIf
      For i=start To letzte
      Shapes.Remove(d[r+na[i]])
        f[r+na[i]]=0
      EndFor
    EndSub


    Sub key
      If GraphicsWindow.LastKey="Escape" Then
        Program.End()
      EndIf
    EndSub

    Sub we
      If a=1 Then
        GraphicsWindow.BackgroundColor="Red"
      Else
        GraphicsWindow.BackgroundColor="Yellow"
      EndIf
      a=-a
    EndSub

                          
    Saturday, May 4, 2013 8:49 AM
  • Very nice! :3 

    Small basic beginner today, expert tomorrow.

    Saturday, May 4, 2013 4:06 PM
  •  

    http://smallbasic.com/program/?BDK263

    I´ve problem with w variable. Not value assigned

    Would you see this?

    Thanks

    ----------------------------------------------------------------------------------------------------------------------------------------------------------

      While w <> " "
         nWords = nWords + 1
         words[w] = 1
    ' The following line could be harmful and has been automatically commented.
    ' w = File.ReadLine(path, nWords)
       EndWhile
    ' The following line could be harmful and has been automatically commented.
    ' File.DeleteFile(path)
       nWords = Array.GetItemCount(words)
       index = Array.GetAllIndices(words)


    carlosfmur - Buenos Aires

    Monday, May 6, 2013 4:13 AM
  • Carlos, uncomment the File commands that are commented out automatically for security reasons when downloaded.
    Monday, May 6, 2013 9:55 AM
    Moderator
  • This is a sample of community suggestion 1 (1) : VZC916.

    4+9=13
    1+1=2
    4+3=7
    1+3=4
    7+8=15
    2+7=9
    6+2=8
    6+1=7
    3+8=11
    6+9=15
    6+4=10
    9+5=14
    4+4=8
    7+7=14
    3+3=6
    6+5=11
    9+7=16
    5+7=12
    4+4=8
    1+8=9
    Correct:20/20
    Time=53.155[sec]
    Continue?


    Nonki Takahashi

    Tuesday, May 7, 2013 2:51 AM
    Moderator
  • Solution to (2) Write a program that gets some text input by the user and loops through each character and counts the number of vowels a, e, i, o or u.

    Import: XRC452

    Features a quick and friendly UI, uses a multidimensional array and NO BUGS that I could find.

    I just nominated an updated version of this program XMX755 for the blog, because it has additional features, including a "Quick Input Mode" which i'm going to use in a Point of Sale (POS) program which has a manual input screen.

    Tuesday, May 7, 2013 6:49 AM
    Moderator
  • This is a beta version of game challenge: FMN979.

    This program runs properly in local.  Please uncomment lines with File object before running. 

    Screen shot of a program Minesweeper for Small Basic 0.1b


    Nonki Takahashi


    Tuesday, May 7, 2013 2:53 PM
    Moderator
  • Here's another way of doing curriculum Challenge (2), using arrays.

    Import: FJQ534

    http://smallbasic.com/program/?FJQ534

    Wednesday, May 8, 2013 12:09 AM
    Moderator
  • Good program.
    Screen shot of a Minesweeper

    Nonki Takahashi

    Wednesday, May 8, 2013 8:06 AM
    Moderator
  • This is my sample of community suggestion 1 (2) Draw a picture of the earth and the moon.

    re = 6378 ' equatorial radius of the earth [km]
    rm = 1738 ' equatorial radius of the moon [km]
    ro = 834400 ' radius of the orbit of the moon [km]
    km = 1 / rm ' [px/km]
    GraphicsWindow.BackgroundColor = "Black"
    ' draw the earth
    GraphicsWindow.BrushColor = "Blue"
    x = 40
    y = 200
    r = re * km
    GraphicsWindow.FillEllipse(x - r, y - r, 2 * r, 2 * r)
    GraphicsWindow.BrushColor = "Gray"
    GraphicsWindow.DrawText(x - r, y + 10, "the earth")
    ' draw the moon
    GraphicsWindow.BrushColor = "Silver"
    x = x + ro * km 
    r = rm * km
    GraphicsWindow.FillEllipse(x - r, y - r, 2 * r, 2 * r)
    GraphicsWindow.BrushColor = "Gray"
    GraphicsWindow.DrawText(x - r, y + 10, "the moon")

     

    Nonki Takahashi


    Wednesday, May 8, 2013 3:52 PM
    Moderator
  • I like doing it to scale - on this scale how far is the sun? at 150,000,000 km
    Wednesday, May 8, 2013 9:21 PM
    Moderator
  • Community Suggestion 2 (By NaochanON)

    Make a shape (for example ; car, man, animal...etc), move, and rotate it.  NWM720  

    Thursday, May 9, 2013 1:12 AM
    Answerer
  • Probably my biggest program so far.
    PNF416
    This is my entry for the Intermediate Challenge (Restaurant Menu for the Clerk)

    I can write 1000 lines of code in roughly 10 seconds. Here's how:
    i = 1

    For i = 1 to 1000
    TextWindow.WriteLine(i+ ". Code")
    Program.Delay(10)
    EndFor

    Make Sense?

    Thursday, May 9, 2013 3:13 AM
  • The sun is 150,000,000/1,738=86,306[px] away from the earth.

    If the resolution of your display is 32[px/cm], it is 86,306/32=2,697[cm]=27[m] away.

    And the equatorial radius of the sun is 696,000[km].  So the size (diameter) of the sun on this scale is 696,000/1,738*2=801[px].  (801/32=25[cm])


    Nonki Takahashi

    Thursday, May 9, 2013 1:26 PM
    Moderator
  • Joman,

    Very good program and interface - well laid out, works well and the code is very clear.


    Thursday, May 9, 2013 5:53 PM
    Moderator
  • Joman,

    In parts of the world where the decimal marker is a comma (as in the Netherlands) the calculation of the subtotal doesn't work well,


    Jan [ WhTurner ] The Netherlands

    Thursday, May 9, 2013 6:00 PM
    Answerer
  • The sun is 150,000,000/1,738=86,306[px] away from the earth.

    If the resolution of your display is 32[px/cm], it is 86,306/32=2,697[cm]=27[m] away.

    And the equatorial radius of the sun is 696,000[km].  So the size (diameter) of the sun on this scale is 696,000/1,738*2=801[px].  (801/32=25[cm])


    Nonki Takahashi


    Uh... Would you mind speaking in English? :]

    It is written: "'As surely as I live,' says the Lord, 'every knee will bow before me; every tongue will acknowledge God.'" Romans 14:11

    Thursday, May 9, 2013 6:32 PM
    Answerer
  • Nonki's picture of the earth and moon are to scale (distance between them and their size).

    On the same scale the Sun would be about 27 meters away if you had a big enough screen and its size would be about 25 cm diameter, so grapefruit sized across the road!

    Thursday, May 9, 2013 7:25 PM
    Moderator
  • WhTurner33~

    What if I copied my existing code and at start up, ask the user if the decimal marker should be a comma or period? Do you think that's an okay way to approach it?


    I can write 1000 lines of code in roughly 10 seconds. Here's how:
    i = 1

    For i = 1 to 1000
    TextWindow.WriteLine(i+ ". Code")
    Program.Delay(10)
    EndFor

    Make Sense?

    Friday, May 10, 2013 3:08 AM
  • litdev~

    Thank you very much for the feedback! As I have stated in the help menu, I want to try to add a print function so it will take the info and make it a .txt file.

    The only problem I have had in the past is that I don't know what code I need for making a .txt file on, say, the C:\ drive. I only know how to make directories - or folders - with the File command. Anything I am missing?


    I can write 1000 lines of code in roughly 10 seconds. Here's how:
    i = 1

    For i = 1 to 1000
    TextWindow.WriteLine(i+ ". Code")
    Program.Delay(10)
    EndFor

    Make Sense?

    Friday, May 10, 2013 3:13 AM
  • px: pixel
    m: meter (1 yard = 0.9 m)
    km: kilometer (1 mile = 1.6 km)
    cm: centimeter (1 inch = 2.54 cm)

    So...

    On the same scale the Sun would be about 30 yards away if you had a big enough screen and its size would be about 9.8 inches diameter, so grapefruit sized across the road!


    Nonki Takahashi


    Friday, May 10, 2013 7:29 AM
    Moderator
  • Hi Joman, you can use File.WriteLine to create a file.

    You need to include "/" in the filePath.

    txt = "write me to line 1 in a new file"
    filePath = Program.Directory + "/" + "the text file.txt"
    
    File.WriteLine(filePath, 1 , txt)

    Some generic POS software asks for currency at setup.

    Others are written specifically for their country of origin.

    Friday, May 10, 2013 9:08 AM
    Moderator
  • Joman, 

    The problem is that the output of calculations in my version of the operating system have a comma in the answer. (e.g. the subtotal is 2,50) . A new order then  adds  e.g. 9.95 to this, but 2,50+9.95 is treated as a string of characters and the numbers are concatenated.

    You can write text to a file with the File.Append command.

    I found another little error in your program:

    When I click "New order" the summary-window is cleared, but if I then click a new order, the subtotal of the last order is added to the new order (the subtotal and other totals are not reset to zero)

    After putting a SubTot=0 at the end of Sub Setup, The Subtotal is calculated CORRECT. Presumebly the variable is then considered a number instead of as a string !


    Jan [ WhTurner ] The Netherlands



    Friday, May 10, 2013 9:12 AM
    Answerer
  • WhTurner33~ Then I will just label it as only for North America. Right, yes, I forgot to clear the variables for those totals. I will include that when I add the print (make text file) button. Please expect the new version to come out in a week. If not a week and a half. Thank you :)

    I can write 1000 lines of code in roughly 10 seconds. Here's how:
    i = 1

    For i = 1 to 1000
    TextWindow.WriteLine(i+ ". Code")
    Program.Delay(10)
    EndFor

    Make Sense?

    Saturday, May 11, 2013 12:44 AM
  • Jibba Jabba~ Thank you! That makes a lot of sense. Yes, for the whole currency issue, I think I will just leave it as for North America and for anywhere else that uses Dollars. Thank you!

    I can write 1000 lines of code in roughly 10 seconds. Here's how:
    i = 1

    For i = 1 to 1000
    TextWindow.WriteLine(i+ ". Code")
    Program.Delay(10)
    EndFor

    Make Sense?

    Saturday, May 11, 2013 12:49 AM
  • My solution to Curriculum Challenge 1.4:    NGK861

    This is my first program here, and ever.

    Saturday, May 11, 2013 1:58 AM
  • Very nice, Unstoppable_1! Definentially easier and simpler than mine! why didn't i think of doing that... :3

    Small basic beginner today, expert tomorrow.


    • Edited by 8Bit Pony Saturday, May 11, 2013 2:04 AM
    Saturday, May 11, 2013 2:03 AM
  • Hi Unstoppable_1

    Congrats on your 1st program ever. I posted mine about 4 months ago and haven't looked back. A bottomless pit of learning here.

    If you haven't already checked out the curriculum 8bit has kindly posted the link. Here it is: http://social.technet.microsoft.com/wiki/contents/articles/16299.small-basic-curriculum.aspx

    There's heaps of good stuff on the wiki and blog as well e.g. http://social.technet.microsoft.com/wiki/contents/articles/15081.small-basic-programming-tips/revision/6.aspx is a good introduction to writing code.

    Hey, btw, love your profile name. Classic stuff.


    Saturday, May 11, 2013 3:21 PM
    Moderator
  • Thank you for the kind words and an advice. I will check the resources. Here is my 2nd program, it's for the Small Challenge 1. It's:  RJJ372. I counted 63 cases.

    http://smallbasic.com/smallbasic.com/program/?RJJ372 (doesn't let me to post a hyperlink).

    I am just not sure if I misunderstood the task, or there is a typo.

    Small Challenge 1

    Write a program that finds all the numbers less than 1000 that contain only digits that sum to 10, e.g. 55, 73, 137, but not 423.  How many are there?

    137 doesn't add up to 10 to me. 136 does.

    Sunday, May 12, 2013 12:45 AM
  • oh yeah! 137 = 11! good eye. :3

    Small basic beginner today, expert tomorrow.

    Sunday, May 12, 2013 1:18 AM
  • Hello Nonki, I am trying your Minesweeper. I like it,very nice! Can I highlight mine RightMouse click the mine, so it doesn't explode?  It doesn't work for me.

    Sunday, May 12, 2013 3:31 AM
  • Yes, this is still beta so right button doesn't work yet.  Please wait for next version.

    Nonki Takahashi

    Sunday, May 12, 2013 3:48 AM
    Moderator
  • Intermediate Challenge 1    (Sushi restaurant)   JWF370 


     
    Sunday, May 12, 2013 4:00 AM
    Answerer
  • Hi Unstoppable 1

    For Small Challenge 1 I got the same result, 63 cases. I assumed 137 was a typo as well.

    Also got the same result for  Curriculum Challenge 1.4 (1)


    Cloud quote of the week by Andrew Meyer: "Don’t lose my files bro!" -Andrew Meyer

    Sunday, May 12, 2013 8:53 AM
    Moderator
  • Solution to Community Suggestion 3 challenge 1:

    http://smallbasic.com/program/?DWG456

    Works very well.

    Sunday, May 12, 2013 8:29 PM
  • Of course this was a typo - fixed.  I would like to say it was deliberate to keep you guys checking, but it was just a mistake.
    Sunday, May 12, 2013 9:25 PM
    Moderator
  • Personally I think the odd deliberate typo would be a useful feature. An additional paradigm to puzzle solving.

    Cloud quote of the week by: "Don’t lose my files bro!" -Andrew Meyer

    Sunday, May 12, 2013 11:04 PM
    Moderator
  • NaochanON

    I love this GUI. You eat with you eyes. Everything in a food premise should look edible or at least clean enough to eat off. I've spent lots of other peoples money equipping commercial kitchens and would insist on a POS terminal like this. I'd change 3 menu items and the food cost would have it offset in 1 sitting. This has got commercial merit.

    And the code is really neat, easy to follow.


    Cloud quote of the week by: "Don’t lose my files bro!" -Andrew Meyer


    Sunday, May 12, 2013 11:22 PM
    Moderator
  • New version using GraphicsWindow: http://smallbasic.com/program/?SKG602
    Monday, May 13, 2013 2:40 AM
  • Kroltan,

    I think the character minus '-' may be valid for e-mail address.


    Nonki Takahashi

    Monday, May 13, 2013 9:45 AM
    Moderator
  • Yes, the minus is valid, as is the plus-sign '+' (at least with gmail.com)

    The above is valid in the namepart (left of @). I don't know if this is true for the domainpart.


    Jan [ WhTurner ] The Netherlands




    Monday, May 13, 2013 10:27 AM
    Answerer
  • This could get complicated. I haven't started this one yet but had a quick look at Wikipedia and 1 other site. If you use the protocols set out in Wikipedia then you should be able to filter out all the non valid strings. Bit of a job though.

    Then the other site talks about maybe's. Characters that technically are allowed but would be ridiculous to use, unless you had a specific reason, because they can get lost or confuse/conflict.

    The validation rules could be determined by who/what you're writing it for.

    http://en.wikipedia.org/wiki/E-mail_address

    http://www.remote.org/jochen/mail/info/chars.html


    Cloud quote of the week by: "Don’t lose my files bro!" -Andrew Meyer

    Monday, May 13, 2013 11:53 AM
    Moderator
  • Well, you can update the initial state of the emailMask variable, add the "-" to it. Not on my home now, so I cant update, but it's simple.
    Monday, May 13, 2013 1:54 PM
  • Hello Nonki, I am trying your Minesweeper. I like it,very nice! Can I highlight mine RightMouse click the mine, so it doesn't explode?  It doesn't work for me.

    Unstoppable_1 and everyone,

    I updated my game challenge as FMN979-0.  This program runs properly in local.  Please uncomment lines with File object before running. 

    Have fun!


    Nonki Takahashi

    Monday, May 13, 2013 2:31 PM
    Moderator
  • My 1st Physics Challenge. Thanks Mathman, LitDev and Zock77.

    It doesn't really solve the challenge but a good challenge for me. I haven't applied all the trig and physics methods to it yet. But I learnt how to change spin direction (especially for the deceleration) and bring it to stop. It looks a bit weird with no ramps as I got the spin direction to change with the direction back up.

    Code sample CXF691, you'll need to bring your own ball unless you download the zip http://sdrv.ms/12g9tSY from my Skydrive.


    You have to have a dream so you can get up in the morning. - Billy Wilder


    Friday, May 17, 2013 11:21 AM
    Moderator
  • I've wrote a sample of community suggestion 1 (3) 30-second animation: VXK727.

    Run in local for appropriate work.


    Nonki Takahashi

    Friday, May 17, 2013 3:43 PM
    Moderator
  • I forgot to post solution to Small Challenge 1. FZP682


    You have to have a dream so you can get up in the morning. - Billy Wilder

    Friday, May 17, 2013 10:20 PM
    Moderator
  • This is my challenge for community suggestion 2: MQF956.

    Run it in local for proper work.

    Screen shot of a challenge  


    Nonki Takahashi

    Sunday, May 19, 2013 2:06 PM
    Moderator
  • This is my challenge for community suggestion 3 (2): XLB916.

    Screen shot of a challenge


    Nonki Takahashi

    Sunday, May 19, 2013 3:51 PM
    Moderator
  • My solution to Small Challenge 1:

    jdm206

    My solutions to Curriculum 1.4, 1 and 2:

    jgw462

    Is there any way to text wrap within the editor so that I can see my whole big long string of 'or' statements on the screen?


    Allen

    Sunday, May 19, 2013 8:13 PM
  • Hello Allen.

    Your program works well. If you wish to shorten the OR statement then:

    Yes, it's a good idea to avoid really long 1line statements that are beyond the screen width.

    One solution is to put all the vowels, aeiou, into 1 variable, an array. An array is a variable that can hold more than value. Each value has an index.

    Then loop thru the array and check against the IF condition.

    myword = Text.ConvertToLowerCase(TextWindow.Read())
    length = Text.GetLength(myword)
    count = 0
    vowel = "1=a;2=e;3=i;4=o;5=u"
    
    For i = 1 To length
      currentLetter = Text.GetSubText(myword, i, 1)
      For j = 1 To Array.GetItemCount(vowel)    
        If vowel[j] =  currentLetter Then
          count = count + 1
        EndIf
      EndFor
    EndFor


    You have to have a dream so you can get up in the morning. - Billy Wilder


    Monday, May 20, 2013 12:45 AM
    Moderator
  • Community Suggestion 1 Make a 30-second animation.  and

    Community Suggestion 2    NGN430   An  ant moves to search a sugar cube.

    Monday, May 20, 2013 1:15 PM
    Answerer
  • These are ideas for a future challenge:

    (1) Write ASCII code table.

    (2) Make any kind of roulette (wheel).


    Nonki Takahashi

    Friday, May 24, 2013 9:29 AM
    Moderator
  • My solution to Community Challenge 1: Curriculum Challenge 3.4 Events and Interactivity.

    NZN745

    There's a significant and relevant debate going on about this one RE the sample in the Curriculum being TOO HARD to follow. I still don't follow it but I will go back and try to. I chose to abandon the sample because it did my head in (health & safety issue) and fortunately after 4 months of SB and this forum was able to solve it.

    So I wrote a program to describe my approach to solving it:

    It's called the "SB forum function loop"

    TextWindow.Title = "SB forum function loop"
    fun = "1=Helping out;2=More practice;3=Satisfaction"
    While "true"
      TextWindow.Write(fun[1] + " = ")
      TextWindow.Write(fun[2] + " = ")
      TextWindow.Write(fun[3] + " = ")
      Program.Delay(80)
    EndWhile


    You have to have a dream so you can get up in the morning. - Billy Wilder

    Friday, May 24, 2013 10:05 PM
    Moderator
  • This is my physics challenge: NZR510-4.

    Screen shot of a program Tennis Ball


    Nonki Takahashi



    Tuesday, May 28, 2013 2:40 PM
    Moderator
  • Suggestion for Community Challenge - June'13, from an earlier thread by: ICT2COMP_Teacher

    When people register on a theatre website, the email address is used as the login name and the user is requested to enter a password to use with the account.

    A user’s details include: email address, password, first name, surname and address.
    These are stored in a csv file.

    When a user logs in, they enter their email address and must enter their password before accessing their account details.

    code a program which:
    • asks for an email address and password
    • searches the file for the email address
    • if the password is correct it displays the customer details
    • it displays a suitable error message if the password is incorrect.


    You have to have a dream so you can get up in the morning. - Billy Wilder


    Friday, May 31, 2013 2:44 PM
    Moderator
  • Thanks for posting this Nonki.

    Every time I read your code I discover a new program oblect. Amazing.


    You have to have a dream so you can get up in the morning. - Billy Wilder

    Friday, May 31, 2013 8:36 PM
    Moderator