« first day (969 days earlier)      last day (1675 days later) » 

9:55 AM
So I have some code for the partition function
⎕←1{0=≢k←(⍺-1)↓⍳⌊⍵÷2:1⋄1++/(⊢∇⍵-⊢)¨k}¨20
 
@Sherlock9
627
 
But it quickly runs into problems trying to get as high as Problem 78 requires. Not sure how to get it to perform better. Save the results in an array ⍺⍺ maybe?
(Not so much the performance as WS FULL errors in the IDE)
Or maybe I should instead keep a list of just the previous partition numbers and use the recurrence relation p(n) = p(n-1) + p(n-2) - p(n-5) - p(n-7) etc
The origin of the above first attempt is Dennis' Python answer here
 
ngn
10:13 AM
@Sherlock9 if you need inspiration for solving a particular problem or want to compare solutions: pe 1..100 in k
 
Hm my attempt to generate the generalized pentagonal numbers looks this so far:
⎕←{{2÷⍨(3×⍵*2)+⍵,-⍵}¨⍳⍵}5
 
@Sherlock9
┌───┬───┬─────┬─────┬─────┐
│2 1│7 5│15 12│26 22│40 35│
└───┴───┴─────┴─────┴─────┘
 
I figured I'd get the indices of (previous list ⍺⍺) take the sum inside each box and the alternating sum down, either -/+/¨ or +/⊃-/
 
10:55 AM
@Sherlock9 you're calling the function with the same args a lot. memo can help, but of course optimizing for the specific case should often be much better
 
11:48 AM
@dzaima That would be nice, but the trouble is I need to find the first n where p(n) is divisible by 1000000
So I'm not sure how to optimize this without just using memo
 
@Sherlock9 oh yeah, that big numbers could be a problem, probably needing using a new algorithm
 
@dzaima I figured modding by 1000000 would help, but let's see if that even works for p(1000) (which is 2e31)
It does not. Back to the drawing board
 
 
1 hour later…
ngn
1:06 PM
@Sherlock9 ^ a quick translation of my k solution. could be improved a lot.
 
@ngn solving a challenge isn't fun, if you're just given the code :)
i'd have put that in a tio link at least
 
ngn
@dzaima fair enough. left as an exercise to the reader :)
 
1:28 PM
Thanks for not spoiling it :D
 
a better memo that doesn't involve lookups + an algorithm that prefers that (though still not suitable for actually finding a 0 as i'm too lazy currently to think about algorithms):
https://tio.run/##VVBNS8NAFLzvr9hbG9LgbvEU6Q@QELz1Ih6KNSLts4KXlNqLSiExWwQpngQpPfTgzZZCL0L7T94fiW9fEj/CQh4z82Zmt3PT97rDTn9wmecQS5w8y0OlhEDzJnE6Ox/WutH1ba0AIJDQJgmaDzoFdAEDQkZotpZI5xKfHuUVzw8QoPnE9N6SZl0yyQKTOQQ@jaRoM1qHoMErpdSR1gnav6Bkwv7WYyEgJKLexOxLuxA7aFZK/DSZzo5PaFDsrDB55zbsi9kGQkpmCsJTQo8IPisE/zPs7SJ@kJFqUeWejSTa0w5OXuzFspSU@03T12SnFX932nUP6rZ9ZH08mpzdsjfmh6pelZy0jHZLMoFYiDLFpicL7euieIvWy7nyts5cgHfJ3Gz3r6rxp
 
 
6 hours later…
8:00 PM
@TessellatingHeckler Yes, all typos.
 
8:52 PM
@dzaima @J.Sallé That's not a real NONCE ERROR, it is just pco throwing a DOMAIN ERROR but for some reason substituting the error message with "nonce error". However, when ⎕FIX hits an error (TIO "Code" is ⎕FIXed) it understands that the given script was invalid and so not in its own domain. Therefore ⎕FIX throws a DOMAIN ERROR.
 

« first day (969 days earlier)      last day (1675 days later) »