Contest 12 - Knight Moves-VBForums
Results 1 to 24 of 24

Thread: Contest 12 - Knight Moves

  1. #1

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,171

    Contest 12 - Knight Moves

    Programming Contest Knight Moves

    For all those who haven't participated in the contest please read the FAQ

    Overview
    Given a position on a chessboard, list all available positions that a knight can move to.

    For example, if I input G1 then the program should output:
    Code:
    H3, F3, and E2


    Languages
    C, C#, C++, F#, Java, JavaScript(musts include HTML and CSS, but markup/styling will not be graded), LUA, Perl, Python, and VB.Net

    Deadline
    August 4th, 2017

    Rules for Contest
    The rules followed will be specific to the contest and not the game.
    • You must submit the source code and include a fiddle(ideone, dotnetfiddle, codepen, etc.)
    • Allow the user to enter the String in the following format: E2(where E is the column name and 2 is the row index)



    Marking

    Each entry will be judged on the following things.
    • Accuracy - Does the program follow all of the rules?
    • Length - How concise is the submitted code?
    • Execution - How quick did the code execute?
    • Efficiency - How efficient is the algorithm(s) you chose?



    Prizes
    You will get to brag that you won a VBForums contest and I'll also include a special avatar!

    Please submit all entry's to the forum below with the title in the following format "Contest 12: Knight Moves - [User Name]"
    Contest Entries Forum
    Last edited by dday9; Jul 24th, 2017 at 02:38 PM. Reason: Extended the Deadline

  2. #2
    Hyperactive Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    402

    Re: Contest 12 - Knight Moves

    Do you also allow g1 (as opposed to G1) or is this considered invalid input?

    Does the order of the available positions in the output be as shown or would another order be judged as good. ie for the example given

    Code:
    G1
    H3, F3, and E2
    would

    Code:
    G1
    H3, E2, and F3
    be just as acceptable?
    Last edited by 2kaud; Jul 25th, 2017 at 06:57 AM. Reason: Added order question
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++17 Compiler: Microsoft VS2017 (15.4.4)

  3. #3

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,171

    Re: Contest 12 - Knight Moves

    Casing doesn't matter, nor does alphabetical sorting.

  4. #4
    Hyperactive Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    402

    Re: Contest 12 - Knight Moves

    Accuracy - Does the program follow all of the rules?
    Length - How concise is the submitted code?
    Execution - How quick did the code execute?
    Efficiency - How efficient is the algorithm(s) you chose?
    What is the weighting of these? I guess accuracy would be first, but what about concise code that is slower than more efficient verbose code? I've noticed in previous contests that concise code seems to win over efficient code?
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++17 Compiler: Microsoft VS2017 (15.4.4)

  5. #5

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,171

    Re: Contest 12 - Knight Moves

    This one will take into account how many passes the code makes vs. how concise the code is.

  6. #6
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    21,492

    Re: Contest 12 - Knight Moves

    @dday9 - I made a submission and I just realized, I did Bishop moves instead of Knight moves :blush

    Can I have that removed and resubmit later?

  7. #7
    Fanatic Member Spooman's Avatar
    Join Date
    Mar 2017
    Posts
    832

    Re: Contest 12 - Knight Moves

    dday9

    1. Is VB6 ok?
    2. What is a "fiddle" ?
    3. How would I include an image?

    EDIT:

    4. Now that I think about it, how do I upload the code? ..

    Spoo
    Last edited by Spooman; Jul 26th, 2017 at 05:59 PM.

  8. #8
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,376

    Re: Contest 12 - Knight Moves

    @Spooman

    4-
    Please submit all entry's to the forum below with the title in the following format "Contest 12: Knight Moves - [User Name]"
    Contest Entries Forum



  9. #9
    Hyperactive Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    402

    Re: Contest 12 - Knight Moves

    Quote Originally Posted by Spooman View Post
    dday9

    1. Is VB6 ok?
    2. What is a "fiddle" ?
    3. How would I include an image?
    Re 'fiddle'. See http://www.vbforums.com/showthread.p...ing-Characters for more info.
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++17 Compiler: Microsoft VS2017 (15.4.4)

  10. #10
    Fanatic Member Spooman's Avatar
    Join Date
    Mar 2017
    Posts
    832

    Re: Contest 12 - Knight Moves

    Quote Originally Posted by 4x2y View Post
    @Spooman

    4-
    Thanks .. that's the where.

    What I don't know is the what.
    I'm familiar with pasting a code snippet to a thread using the CODE wrapper, and with uploading an IMAGE.
    But what is involved here?

    Spoo

  11. #11
    Fanatic Member Spooman's Avatar
    Join Date
    Mar 2017
    Posts
    832

    Re: Contest 12 - Knight Moves

    Quote Originally Posted by 2kaud View Post
    Thanks. Good link.

    And it appears to address the VB6 question .. not allowed.
    At the risk of sounding cheeky .. that sucks.

    So I'll settle with posting two images here.

    Init example
    Name:  chess1.png
Views: 752
Size:  3.6 KB

    Max example
    Name:  chess2.png
Views: 749
Size:  4.0 KB

    The foregoing "sucks" comment aside, I nonetheless had fun developing the app.

    Spoo

  12. #12

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,171

    Re: Contest 12 - Knight Moves

    So far we only have 3 entries for the contest (excluding Spoo's nonqualified VB6 entry). Keep in mind, the contest ends on 11:59PM CST so be sure to submit your entry before then!

  13. #13
    Addicted Member
    Join Date
    Dec 2011
    Posts
    186

    Re: Contest 12 - Knight Moves

    Is it canceled? Is all entries are wrong?
    On Error GoTo Hell

  14. #14
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    21,492

    Re: Contest 12 - Knight Moves

    Quote Originally Posted by Absolute_Zero View Post
    Is it canceled? Is all entries are wrong?
    No it's still being judged

  15. #15
    Addicted Member
    Join Date
    Dec 2011
    Posts
    186

    Re: Contest 12 - Knight Moves

    I see, but it takes too long to judge just 3 entries
    On Error GoTo Hell

  16. #16
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    21,492

    Re: Contest 12 - Knight Moves

    They're not all written in the same Programming Language. Got to wait for another judge...

  17. #17

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,171

    Re: Contest 12 - Knight Moves

    I want to thank everyone who participated in the Knight Moves contest!

    I got to the judging a little later than I had hoped to because I had some moderators flake on me that promised to judge C++ entries, but it has been judged none-the-less. And the winner for the contest is....


    2kaud for his C++ entry!

  18. #18
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,376

    Re: Contest 12 - Knight Moves

    Congratulations 2kaud



  19. #19
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    21,492

    Re: Contest 12 - Knight Moves

    Quote Originally Posted by 4x2y View Post
    Congratulations 2kaud
    Yeah... Congrats from me too

  20. #20
    PowerPoster
    Join Date
    Jun 2013
    Posts
    3,144

    Re: Contest 12 - Knight Moves

    Had my solution implemented already a few weeks before (really weird this VB6-exclusion BTW),
    and have choosen a different approach (based on a stepwise progressing rotation of 1/8th of a full circle -
    using a 2D-Matrix-Class for recalculation, in combination with an "OnBoard-check" of the resulting Coords in each step):

    Maybe that's interesting for others (because it's a bit "outside the box" algo-wise).

    Code:
    Function GetKnightStrikePositions(BoardPos As String) As cArrayList
      Set GetKnightStrikePositions = New_c.ArrayList(vbString) 'set the return-type-instance
      On Error GoTo 1
      
      Dim x As Double, y As Double, M As cCairoMatrix, i As Long
          x = Asc(UCase$(Trim$(BoardPos))) - 65    'convert the Chess-Notation into x, ...
          y = Asc(Right$(Trim$(BoardPos), 1)) - 49 'and y Coords ... [0 to 7],[0 to 7]
      If Not OnBoard(x, y) Or Len(Trim$(BoardPos)) <> 2 Then Err.Raise 5 'sanity-check
    
      Set M = Cairo.CreateIdentityMatrix     'Ok, the whole approach is based on a 2D-Matrix-Class
          M.TranslateCoords x + 0.5, y + 0.5 'move to the center of the given (Int-Coord-based) Field
      
      For i = 1 To 8                 'check all 8 potential positions in a loop
          x = 1: y = 2               'the typical 1:2-move of the knight (from the current point)
          M.CalculatePoint x, y      'let the Matrix calculate the location of the new Point for us
          If OnBoard(Int(x), Int(y)) Then GetKnightStrikePositions.Add Chr$(65 + Int(x)) & Chr$(49 + Int(y))
          M.RotateCoordsDeg -360 / 8 'clockwise rotate the Matrix further by 1/8th of the full circle
      Next
      
    1 If Err Then GetKnightStrikePositions.Add "Invalid BoardPos"
    End Function
    
    Private Function OnBoard(ByVal x As Long, ByVal y As Long) As Boolean
      OnBoard = Not (x < 0 Or x > 7 Or y < 0 Or y > 7) 'outsourced "OnBoard-check"
    End Function
    Usage then for example:
    Code:
      MsgBox GetKnightStrikePositions(InputBox("Enter Knight-position")).Join(", ")

    Olaf
    Last edited by Schmidt; Aug 19th, 2017 at 01:16 AM.

  21. #21
    Fanatic Member Spooman's Avatar
    Join Date
    Mar 2017
    Posts
    832

    Re: Contest 12 - Knight Moves

    dday

    You definitely need to repost that video here

    http://www.vbforums.com/showthread.p...37#post5182937

    EDIT-1:
    Oh yeah, congrats from me too, even though it wasn't written in VB6

    EDIT-2:
    Olaf
    (really weird this VB6-exclusion BTW)
    Amen
    Last edited by Spooman; Aug 19th, 2017 at 03:31 AM.

  22. #22
    Hyperactive Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    402

    Re: Contest 12 - Knight Moves

    Thanks to all.

    IMO VB6 should be allowed - anything to increase the number of participants. If a forum moderator can't comment upon code in the language for which they are a mod...........
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++17 Compiler: Microsoft VS2017 (15.4.4)

  23. #23
    Addicted Member
    Join Date
    Dec 2011
    Posts
    186

    Re: Contest 12 - Knight Moves

    Congrats 2kaud, but I liked 4x2y's entry, he used a smart way to find moves out of board
    On Error GoTo Hell

  24. #24
    Hyperactive Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    402

    Re: Contest 12 - Knight Moves

    Quote Originally Posted by Absolute_Zero View Post
    Congrats 2kaud, but I liked 4x2y's entry, he used a smart way to find moves out of board
    Yes, I like that as well
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++17 Compiler: Microsoft VS2017 (15.4.4)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.