[Haskell-beginners] CSES programming problems at https://cses.fi/problemset/

Julian Ong julian_ong at yahoo.com
Sun Jun 28 23:27:07 UTC 2020

 I realized I did not answer the question Doug posed, but the algorithm as originally presented works correctly and calculates correctly the number of possible knight pairings for each k x k board and generates the correct output requested by the problem.
The issue is still that, as I have implemented it in Haskell, it doesn't run fast enough to pass the automated CSES testing for n=10000. I am very curious whether it's possible to pass the speed testing for this problem using Haskell and if so how.
    On Sunday, June 28, 2020, 09:49:02 AM PDT, Irfon-Kim Ahmad <irfon at ambienautica.com> wrote:  
  On 2020-06-28 11:26 a.m., Doug McIlroy wrote:
 I'm currently stuck on the Two Knights problem.
 Having placed one knight on the board, in how many
places can you put the other?
If you check the website indicated, it's a slight variation on that: 
"Your task is to count for k=1,2,…,n the number of ways two knights can be placed on a k×k chessboard so that they do not attack each other."
The input is n (an integer that can range from 1 to 10000), the output is a single integer for each value from 1 to n, one per line, the memory limit is 512MB, and the maximum runtime is 1.00 seconds. 


Beginners mailing list
Beginners at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20200628/5ead1b1b/attachment.html>

More information about the Beginners mailing list