locked
Challenge of the Month - August 2016 RRS feed

  • 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 perform a 'find and replace' feature for text in a file.

    Maths Challenge

    Write a program to calculate display numbers with either a fixed number of significant figures or fixed number of decimal places.

    Game Challenge

    Write a breakout type game


    Check out the Community Suggestion Challenges also made sticky for a month

    • Optical Illusions (By Yvan) - LINK
    • Avatar Generator (By Nonki) - LINK
    • The Kodalith effect (By Yvan) - LINK

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

    Monday, August 1, 2016 8:46 AM

All replies

  • program no : BQT169

    section: Maths Challenge

    Write a program to calculate display numbers with either a fixed number of significant figures or fixed number of decimal places.

    This program calculate the force gravity of the Earth on the Moon, displays the gross result in conditions that Small Basic allows, then with this program, he converted this huge number in scientific notation in power of 10 with 3 decimal places like precision.

    Wednesday, August 3, 2016 4:55 PM
    Answerer
  • puzzle game:CQK281
    Thursday, August 4, 2016 6:58 AM
  • Maths Challenge

    Write a program to calculate display numbers with either a fixed number of significant figures or fixed number of decimal places.

    This is my solution for this challenge:

    v = 9
    n = 99
    While n * 1 = n
      v = n
      n = Text.Append(9, n)
    EndWhile
    TextWindow.WriteLine(v + " is valid number.")
    TextWindow.Write("The fixed number of " + v)
    TextWindow.WriteLine(" is " + Text.GetLength(v) + ".")
    
    v = 0.1
    n = 0.01
    While n * 10 = v
      v = n
      n = Text.Append("0.0", Text.GetSubTextToEnd(n, 3))
    EndWhile
    TextWindow.WriteLine(v + " is valid number.")
    TextWindow.Write("The fixed number of decimal places in " + v)
    TextWindow.WriteLine("is " + (Text.GetLength(v) - 2) + ".")
    Make sense?


    Nonki Takahashi

    Monday, August 8, 2016 7:10 AM
  • This is my first step for game challenge (breakout game): SNZ703.

    Screen shot of a program Breakout 0.1a


    Nonki Takahashi


    Thursday, August 11, 2016 10:01 AM
  • @Nonki,

    great game, perfect simulation !!

    Friday, August 12, 2016 3:01 PM
    Answerer
  • I love the idea of monthly challenge in the forum ;-)

    I heard about it only today, from Ed new blog.

    It is always good idea to follow the new Forum Ninjas blogs :-)


    signature   Ronen Ariely
     [Personal Site]    [Blog]    [Facebook]    [Linkedin]

    Thursday, August 18, 2016 3:46 AM
  • Hello pituach,

    you can check all challenges here.  Thanks.


    Nonki Takahashi

    Wednesday, August 24, 2016 2:22 AM
  • I found a similar (not exact) solution for the text challenge (find and replace): XMG163-1.

    Usage:

    Option? from to[<input][>output]

    Option? abc cba
    abcdefg
    cbadefg

    Option? Text Test<tr02.sb
    ' tr - translate command 0.21
    ' Copyright (c) 2014 Nonki Takahashi.  All rights reserved.
    '
    ' History:
    '  0.21 2014-02-19 Minor changed for Silverlight. (XMG163-1)
    '  0.2 2014-02-19 Completed. (XMG163-0)
    '  0.1a 2014-02-18 Created as alpha version. (XMG163)
    '
    Not = "False=True;True=False;"
    WQ = Test.GetCharacter(34)
    TestWindow.Write("Option? ")
    buf = TestWindow.Read()
    ParseArgs()
    string[1] = args[1]
    string[2] = args[2]
    EspandStr()
    eof = "False"
    nLine = 0
    nChar = 0
    If args["stdin"] <> "" Then
      mas = 0 ' dummy for remote
      mas = Test.GetLength(File.ReadContents(args["stdin"]))
    EndIf
    While Not[eof]

    Note that the filename (input or output) must be absolute path if you run this program from Small Basic IDE. If you run this exe (program) from Explorer or Command Prompt, you can use relative file path.


    Nonki Takahashi



    • Edited by Nonki Takahashi Wednesday, August 24, 2016 8:45 AM input or output
    Wednesday, August 24, 2016 8:41 AM