none
Challenge of the Month - April 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.

    Also post feedback on the kind of challenges that you want to see more of in the future.

    Text Challenge

    • Write a program that records your typing speed (words per minute).  Consider using a multi-line textbox for the user to type into.


    Maths Challenge

    • Try to write the fastest code to calculate the sum of all prime factors of the first 1000 numbers.

    For example the first 10 numbers (1 has no prime factors) have the following prime factors (2, 3, 2+2, 5, 2+3, 7, 2+2+2, 3+3, 2+5) and their sum is 45.

    Graphics Challenge

    • Write subroutines to convert between RGB colour values and HSL (to and from).  RGB are the Red, Green and Blue components, while HSL are the Hue, Lightness and Saturation.  Using HSL to set colours can give nice effects.  Start here to learn about HSL and maybe search for some online algorithms to help writing the conversioncode.
    • Write a program using the HSL conversion to change the Hue (colour) of an image by changing each pixel.  For performance reasons (it will be slow), try using fairly small images, say 100 by 100 pixels (that is still 10000 pixels to change).

    Game Challenge

    • Write a program to play GO.  Some AI would be great to play against the computer.  Read about AlphaGo.


    Community Suggestions

    This month the communty suggestons for challenges were posted in separate threads. Thanks for all suggestions.

    Post answers here or on the challenge threads linked to below.

    • Create a fully functional calculator (8-digit, basic calculator, not scientific) but do all the calculations by hand...meaning that if the user wants 356 * 8...the program should multiply 8*6 then 8*5+4 then 8*3+4. Just like you would do it if you had to multiply with pencil and paper. This would require addition, subtraction, multiplication and division and as an added challenge, negative numbers.  By jherch77 (ORIGINAL POST).
    • Write a program to calculate how much power (watt)  is necessary to climb an elevation of 5% grade.  By Yvan Leduc (ORIGINAL POST).
    • Write a program that could quantify the number of Watts uses the writing, storage on different servers, and the delivery to the addressee of a simple e-mailBy Yvan Leduc (ORIGINAL POST).
    • A knight's tour is a sequence of moves of a knight on a chessboard such that the knight visits every square only once. If the knight ends on a square that is one knight's move from the beginning square (so that it could tour the board again immediately, following the same path), the tour is closed, otherwise it is open By Yvan Leduc (ORIGINAL POST).


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


    Saturday, April 2, 2016 9:12 AM
    Moderator

All replies

  • This is my program for April Challenge

    HERE is my data: ( see the screen capture )

    Write a program to calculate how much power (watt)  is necessary to climb an elevation of 5% grade .

    consider:

    1) weight of the bike, and the biker,

    2) air resistance factor

    3) gravity  factor (9.8 m/s²)    

    4) rolling resistance factor

    5) Time to climb hill

    6) Elevation gain 5%

    PROGRAM NO: WGF044

    Monday, April 4, 2016 5:40 PM
    Answerer
  • Graphics Challenge, TXB454.

    Friday, April 8, 2016 5:38 PM
    Moderator
  • Looks great, Flower-Power like: Here's another one or two (from kodim23.png, more after NavigateUp) (100x80). And another one from

    List of color palettes (Wiki)

    BTW: Even better, nice find: rather new CP article Fundamental ImageProcessing

     with great effects and filters. Allmost finished porting to SB Ext incl. Emboss, Sharpen, etc. and results look like

    (SobelFilter, Cartoon Effect, orig. image)




    Friday, April 8, 2016 7:44 PM
    Answerer
  • What a gorgeous program !!

    love it!

    so, SB is powerful !!!

    thanks for sharing !, i'll have to keep it, in my computer:

    i name it: Hue variation by LitDev .sb

    Yvan :)

    Friday, April 8, 2016 7:50 PM
    Answerer
  • Amazing effects !

    sometime i use those effects that we have in Photoshop kind of software.

    But now, we can perform our own effects with SB.

    Sky is the limit !!!!!!!!!!

    Yvan :)

    Wonderful !!

    Friday, April 8, 2016 7:53 PM
    Answerer
  • @ Pappa - cool effects and nice blog about it - I am going to add a couple of these effects too.
    Saturday, April 9, 2016 5:49 PM
    Moderator
  • Hi LitDev,

    I suggest for May challenge, a way to do SOLARISATION effect, that i used to do in my darkroom, in silver photography,, let's say on black and white image.

    The principle was: we enlarge a print, and then in the development bath, just after 1 min of developp, we open the darkroom light ( 60 watt ) a fraction of a second, and the finish the development and put it in the fixing bath. What happened, we have solarized this image, :

    wikipedia:  https://en.wikipedia.org/wiki/Solarisation

    Solarisation (or solarisation) is a phenomenon in photography in which the image recorded on a negative or on a photographic print is wholly or partially reversed in tone. Dark areas appear light or light areas appear dark. The term is synonymous with the Sabattier effect when referring to negatives, but is technically incorrect when used to refer to prints

    <sup class="noprint Inline-Template Template-Fact" style="white-space:nowrap;"></sup>

    results is:

    here is a real silver solarisation by Man Ray in 1931.

    http://www.wikiart.org/en/man-ray/solarisation-1931

    and a Photoshop kind of solarisation:

    https://www.flickr.com/photos/garywium/5798041435

    Saturday, April 9, 2016 7:09 PM
    Answerer
  • Yvan, we are sort of doing image stuff this month so it fits well now so go ahead.
    Saturday, April 9, 2016 7:56 PM
    Moderator
  • That's a tuff challenge for me, but i'll try !!!!!

    give me a couples of day's :)

    Saturday, April 9, 2016 8:28 PM
    Answerer
  • @LitDev, I knew, you would like it and already saw your WiP.

    Saturday, April 9, 2016 8:29 PM
    Answerer
  • Hi LitDev,

    here is my version of the SOLARISATION effect, on a black and white image.

    It take 1 - 2 minutes for process,

    the result is fascinating, as I already  made true solarisation when I had a darkroom, the result is not as close as to a silver print solarisation. Although I'm not trying to reproduce fully silver process. The latter was a chemical process with a reaction in wihch atoms of silver were unpredictable and random, while in digital we can control the results. So this version is another worth! We enter the field of art which is subjective! But I'm happy with have concentrated me on this algorhytm, while respecting the base principles of solarisation, namely that the program should not reverse the middle gray values.

    program no: TWW426

    Sunday, April 10, 2016 2:02 PM
    Answerer
  • Nice effect, or another way, TWW426-0.
    Sunday, April 10, 2016 2:57 PM
    Moderator
  • WOW !!! LOVE IT !!!!!!!

    SPECTACULAR !!!!!!!!!!!!!

    THANKS :)

    Sunday, April 10, 2016 3:59 PM
    Answerer
  • This is my version for graphics challenge: CPW085.

    Screen shot of a program Hue Changer 0.1


    Nonki Takahashi


    Tuesday, April 12, 2016 11:34 PM
    Moderator
  • Great programming !!

    I especially like the hex to decimal SUB and the manner with which you solved this fundamental problem in the approach to graphic images.

    Sub Math_Hex2Dec
      ' Math | Convert hexadecimal to decimal
      ' param sHex
      ' return iDec
      iDec = 0
      iLen = Text.GetLength(sHex)
      For iPtr = 1 To iLen
        iDec = iDec * 16 + Text.GetIndexOf("0123456789ABCDEF", Text.GetSubText(sHex, iPtr, 1)) - 1
      EndFor
    EndSub

    Wednesday, April 13, 2016 12:51 AM
    Answerer
  • Math Challenge, NJT376.
    Thursday, April 14, 2016 5:32 PM
    Moderator
  • The line  iDec = iDec * 16 + Text.GetIndexOf("0123456789ABCDEF", Text.GetSubText(sHex, iPtr, 1)) - 1  in the Sub Hex2Dec can be simplified to:

     iDec = iDec * 16 + Text.GetIndexOf("123456789ABCDEF", Text.GetSubText(sHex, iPtr, 1))

    Explanation: if the Hex is 0 the index is 0 


    Jan [ WhTurner ] The Netherlands


    Friday, April 15, 2016 5:08 PM
    Answerer
  • Here is my version of Solarisation in Colors from a Black and White image.

    The mathematical formula that I use in this program for solarise does not exist elsewhere, it is a home invention, a kind of recipe for bread House, with the try-error procedure, after several hours, I arrived at this formula.

    Too bad I can not save my solarized image , than that someone tell me how?

    I tried LDsaveimage, but it is the original black and white image that is saved!

    program: KRQ248-0



    • Edited by YLedEditor Sunday, May 8, 2016 11:38 PM update program no
    Saturday, April 16, 2016 9:21 PM
    Answerer
  • Most likely not the fastest way for Math challenge, but may contain the least lines:

    XNW568

    Sunday, April 17, 2016 1:02 AM
  • Here is my version of Solarisation in Colors from a Black and White image.

    The mathematical formula that I use in this program for solarise does not exist elsewhere, it is a home invention, a kind of recipe for bread House, with the try-error procedure, after several hours, I arrived at this formula.

    Too bad I can not save my solarized image , than that someone tell me how?

    I tried LDsaveimage, but it is the original black and white image that is saved!

    program: GWM263


    Wow, this is fantastic!

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

    Answer an interesting question? Create a wiki article about it!

    Tuesday, April 19, 2016 2:18 AM
    Owner
  • Thank you very much so Ed for super good comments it is always a great pleasure to receive good feedback, it help me to going farther and farther and push myself beyond my unknown limits !!

    Hoping that my English is , say 75% good, i use Bing Translator, to go French Canadien to English.

    Cheers :)

    Tuesday, April 19, 2016 1:40 PM
    Answerer
  • This is my game challenge: Go Simulator 0.6 (PTB804-4).

    • You can play with very weak AI "Random".
    • You can also save and replay SGF kifu file.

    Screen shot of a program Go Simulator 0.6 (kifu between Fan Hui vs AlphaGo)


    Nonki Takahashi


    Friday, April 29, 2016 2:22 AM
    Moderator
  • Suggestion for May: Rotation  -- In multiple stages

    1. Placing multiple shapes around a circle - Example: Peddles on a flower
    2. Rotating the shapes around the center - Example: Farris Wheel
    3. Rotating the shapes themselves as they rotate around the center - Example: A rotating marquee, where the bottoms of the letters always face the center
    4. Vary the radius of the of the circle as the shapes rotates - Example: The rotating letters would pulse in and out from the center as they rotated.
    Friday, April 29, 2016 5:41 PM
    Answerer
  • nice job Nonki

    Friday, April 29, 2016 9:51 PM
    Moderator
  • Fantastic !!  amazing programming ! love it !
    Sunday, May 1, 2016 1:42 AM
    Answerer