-
Jul 24th, 2017, 11:19 AM
#1
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:
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 01:38 PM.
Reason: Extended the Deadline
-
Jul 25th, 2017, 04:46 AM
#2
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
would
be just as acceptable?
Last edited by 2kaud; Jul 25th, 2017 at 05: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++23 Compiler: Microsoft VS2022 (17.6.5)
-
Jul 25th, 2017, 08:21 AM
#3
Re: Contest 12 - Knight Moves
Casing doesn't matter, nor does alphabetical sorting.
-
Jul 25th, 2017, 10:30 AM
#4
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++23 Compiler: Microsoft VS2022 (17.6.5)
-
Jul 25th, 2017, 10:56 AM
#5
Re: Contest 12 - Knight Moves
This one will take into account how many passes the code makes vs. how concise the code is.
-
Jul 25th, 2017, 07:33 PM
#6
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?
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jul 26th, 2017, 03:10 PM
#7
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 04:59 PM.
-
Jul 27th, 2017, 03:21 AM
#8
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
-
Jul 27th, 2017, 05:26 AM
#9
Re: Contest 12 - Knight Moves
Originally Posted by Spooman
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++23 Compiler: Microsoft VS2022 (17.6.5)
-
Jul 27th, 2017, 07:29 AM
#10
Re: Contest 12 - Knight Moves
Originally Posted by 4x2y
@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
-
Jul 27th, 2017, 07:54 AM
#11
Re: Contest 12 - Knight Moves
-
Aug 3rd, 2017, 01:50 PM
#12
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!
-
Aug 11th, 2017, 07:29 PM
#13
Addicted Member
Re: Contest 12 - Knight Moves
Is it canceled? Is all entries are wrong?
-
Aug 11th, 2017, 07:56 PM
#14
Re: Contest 12 - Knight Moves
Originally Posted by Absolute_Zero
Is it canceled? Is all entries are wrong?
No it's still being judged
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Aug 11th, 2017, 09:11 PM
#15
Addicted Member
Re: Contest 12 - Knight Moves
I see, but it takes too long to judge just 3 entries
-
Aug 11th, 2017, 09:27 PM
#16
Re: Contest 12 - Knight Moves
They're not all written in the same Programming Language. Got to wait for another judge...
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Aug 18th, 2017, 08:19 AM
#17
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!
-
Aug 18th, 2017, 05:35 PM
#18
Re: Contest 12 - Knight Moves
-
Aug 18th, 2017, 06:18 PM
#19
Re: Contest 12 - Knight Moves
Originally Posted by 4x2y
Congratulations 2kaud
Yeah... Congrats from me too
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Aug 19th, 2017, 12:12 AM
#20
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 12:16 AM.
-
Aug 19th, 2017, 01:47 AM
#21
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 02:31 AM.
-
Aug 19th, 2017, 05:23 AM
#22
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++23 Compiler: Microsoft VS2022 (17.6.5)
-
Aug 19th, 2017, 08:38 PM
#23
Addicted Member
Re: Contest 12 - Knight Moves
Congrats 2kaud, but I liked 4x2y's entry, he used a smart way to find moves out of board
-
Aug 20th, 2017, 04:51 AM
#24
Re: Contest 12 - Knight Moves
Originally Posted by Absolute_Zero
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++23 Compiler: Microsoft VS2022 (17.6.5)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|