code logs -> 2009 -> Sat, 18 Apr 2009< code.20090417.log - code.20090419.log >
--- Log opened Sat Apr 18 00:00:20 2009
00:08
<@Vornicus>
Fold is one of those things that you don't need very often.
00:08
<@Vornicus>
But when you do it's pretty bloody obvious.
00:09
<@McMartin>
So, it turns out that every primitive recursive function can be expressed as a fold.
00:09
<@Vornicus>
Oh?
00:09
<@Vornicus>
Oh. Duh. I see it now, it's just a bit crazy.
00:10
<@McMartin>
This is basically why I'm not a fan; it's an alternate syntax for something that's usually prettier in standard recursive syntax.
00:11
<@Vornicus>
here's my "generate all tuples" as a fold: reduce(lambda result, k: result + [target + (k,) for target in result], original, [tuple()])
00:15 You're now known as TheWatcher[T-2]
00:22 You're now known as TheWatcher[zZzZ]
00:38
<@gnolam>
http://www.rockpapershotgun.com/2009/04/15/the-hard-maths-elevated/
00:39 * gnolam is impressed. Very, very impressed.
00:40
<@Derakon>
...holy crap
00:41
<@Derakon>
That's one heck of a modeling engine they have there.
00:46
<@McMartin>
<3 demoscene
00:49
<@McMartin>
Though, of course, the "4k" line has become more and more of a joke over time.
00:49
<@Derakon>
Ahh?
00:49
<@McMartin>
4k, + DX10, + DirectSound, etc.
00:49
<@Derakon>
Oh, they're using libraries? :(
00:49
<@McMartin>
Right. They're just using the equivalent of dlopen.
00:50
<@Derakon>
I thought all their engines and rendering and so on was in that 4k.
00:50
<@McMartin>
And also doing it to user32.dll and kernel32.dll.
00:50
<@McMartin>
Yeah, uh, no.
00:50
<@McMartin>
The device driver for whatever machine is running that is over a megabyte in size, guaranteed.
00:50
<@McMartin>
The mesh generator and vertex submitter is under 4k.
00:52
<@Derakon>
Any ideas for speeding up this caching primes generator? http://paste.ubuntu.com/153126/
00:53
<@Derakon>
It needs to be really very fast, and it's not. Takes 175ms to generate the primes between 98000 and 99000.
01:26
< simontwo>
Derakon, how about looping the prime cache backwards?
01:27
<@Derakon>
How does that help?
01:29
< simontwo>
it seems like you are testing, for each prime in the cache, if it's > n. presumably n is a larger number than any of the cached primes?
01:29
<@Derakon>
In this situation, yes...so I could eliminate that conditional, most likely.
01:30
< simontwo>
if there's a high likelyhood of that, testing if the lowest prime is > n, then the next-lowest and so on would result in a lot of false positives for each call of primes().
01:30
< simontwo>
and the number of false positives would grow with the size of the cache.
01:32
<@McMartin>
Actually
01:32
<@McMartin>
If you're going from [min, max] and min > sqrt(max)...
01:32
<@McMartin>
*every* prime in the cache is less than min.
02:05
<@Derakon>
This spelling is right, yes? One, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, nineteen, twenty, thirty, forty, fifty, sixty, seventy, eighty, ninety, one hundred.
02:06
<@McMartin>
Yes.
02:06
<@Derakon>
I suspect my issue with problem 17 on Project Euler has to do with data entry. ¬.¬
02:15
< simontwo>
I suspect my issue with problem 17 on Project Euler has to do with the fact that the problem sucks.
02:16
<@Derakon>
I got it solved. Wasn't too bad. But yeah, it'd be better if they handed you a list of the words and their lengths.
02:16
<@Derakon>
On the plus side, I now have a numerals-to-English converter.
02:16
<@Derakon>
And I know how to solve 18, but must leave for gaming soon.
02:18
<@Derakon>
Actually the hardest part of 18 may just be finding a sane way to convert their tree into something I can manipulate easily.
02:20
< simontwo>
yes
02:22
<@Derakon>
Right, I'm off.
02:22 Derakon is now known as Derakon[AFK]
02:40
<@Vornicus>
17 sucks.
03:18 NSGuest-277 [~nick@Nightstar-17219.tampfl.dsl-w.verizon.net] has quit [Ping Timeout]
03:25 gnolam [~lenin@Nightstar-1382.A163.priv.bahnhof.se] has quit [Quit: Z?]
04:00
<@Vornicus>
Things that also suck: not remembering to advance your counter.
04:02
<@Vornicus>
Aardvark! nope, that's not the right word. Okay, how about... Aardvark! ...nope.
04:38
<@Vornicus>
Topological sorting... with no guarantee that two things that look the same /are/ the same.
04:39
<@Vornicus>
This one is evil.
05:01
<@Vornicus>
oh. okay, it's not as evil as it could be.
05:42 Alek [~omegaboot@Nightstar-5734.dsl.emhril.sbcglobal.net] has quit [Quit: ]
06:02 Syloqs-AFH [Syloq@ServicesAdmin.Nightstar.Net] has quit [Connection reset by peer]
06:35 AnnoDomini [~farkoff@Nightstar-28115.neoplus.adsl.tpnet.pl] has joined #Code
06:35 mode/#code [+o AnnoDomini] by ChanServ
07:59 Doctor_Nick [~nick@Nightstar-12867.tampfl.fios.verizon.net] has joined #code
08:00 mode/#code [+o Doctor_Nick] by ChanServ
08:06 PinkFreud [~WhyNot@ServicesAdmin.Nightstar.Net] has quit [Operation timed out]
08:07 PinkFreud [~WhyNot@ServicesAdmin.Nightstar.Net] has joined #code
08:16 Derakon[AFK] is now known as Derakon
08:39 Derakon is now known as Derakon[AFK]
09:09 You're now known as TheWatcher
09:10 PinkFreud [~WhyNot@ServicesAdmin.Nightstar.Net] has quit [Operation timed out]
09:10 Vornicus [Vornicus@Admin.Nightstar.Net] has quit [Quit: ]
09:12 PinkFreud [~WhyNot@ServicesAdmin.Nightstar.Net] has joined #code
09:43 PinkFreud [~WhyNot@ServicesAdmin.Nightstar.Net] has quit [Ping Timeout]
09:44 PinkFreud [~WhyNot@ServicesAdmin.Nightstar.Net] has joined #code
10:18 Rhamphoryncus [~rhamph@Nightstar-7184.ed.shawcable.net] has quit [Quit: Rhamphoryncus]
11:08 SmithKurosaki [~jess@67.212.0.ns-4438] has quit [Operation timed out]
11:09 ToxicFrog [~ToxicFrog@Admin.Nightstar.Net] has quit [Operation timed out]
11:24 SmithKurosaki [~jess@Nightstar-24858.acanac.net] has joined #code
11:25 gnolam [lenin@Nightstar-1382.A163.priv.bahnhof.se] has joined #Code
11:25 mode/#code [+o gnolam] by ChanServ
11:30 oOcoolmanOo [~oOcoolman@Nightstar-20400.216.206-77.rev.gaoland.net] has joined #code
11:31
< oOcoolmanOo>
hi evrey one
11:33 ToxicFrog [~ToxicFrog@Admin.Nightstar.Net] has joined #code
11:33 mode/#code [+o ToxicFrog] by ChanServ
12:27 oOcoolmanOo [~oOcoolman@Nightstar-20400.216.206-77.rev.gaoland.net] has quit [Quit: ]
15:13 GeekSoldier [~Rob@Nightstar-8573.midstate.ip.cablemo.net] has quit [Quit: Praise "BOB"!]
16:04 Syloqs_AFH [Syloq@Admin.Nightstar.Net] has joined #code
16:05 Syloqs_AFH is now known as Syloqs-AFH
16:29 You're now known as TheWatcher[afk]
17:01 Candy [Candy@218.109.50.ns-22340] has joined #code
17:01 Candy [Candy@218.109.50.ns-22340] has left #code []
17:30 Derakon[AFK] is now known as Derakon
18:04
<@Derakon>
Man, this profiling output makes no sense to me. Where is all my time going? http://paste.ubuntu.com/153567/
18:07
<@Derakon>
Ah. It's going into doing a lookup into a large list. *replaces with a dict* Still too slow, but also much, much faster than before.
18:23 Vornicus [Vornicus@Admin.Nightstar.Net] has joined #code
18:23 mode/#code [+o Vornicus] by ChanServ
19:08 You're now known as TheWatcher
19:12 GeekSoldier [~Rob@Nightstar-8573.midstate.ip.cablemo.net] has joined #code
19:12 mode/#code [+o GeekSoldier] by ChanServ
19:32 GeekSoldier [~Rob@Nightstar-8573.midstate.ip.cablemo.net] has quit [Ping Timeout]
19:37 GeekSoldier [~Rob@Nightstar-8573.midstate.ip.cablemo.net] has joined #code
19:37 mode/#code [+o GeekSoldier] by ChanServ
20:24
< EvilDarkLord>
Derakon: Pastie your run method?
20:28 * EvilDarkLord eyes function names. PE:21 by any chance?
20:28
< EvilDarkLord>
*module names
20:33
< simontwo>
I just replied to an email whose sender had a 25 line signature.
20:34
< TheWatcher>
One of those "company disclaimer" ones?
20:38
<@Derakon>
EDL: Project Euler #21, yes. And I got it sorted out.
20:40
< EvilDarkLord>
Goody. If you want comparative timing, I have about half a second on a three-ish-year-old laptop.
20:40
<@Derakon>
I'm much slower than that. ¬.¬
20:40
<@Derakon>
16.97s.
20:41
<@Derakon>
Three-year-oldish iMac.
20:42
< simontwo>
TheWatcher, actually not.
20:43
< simontwo>
anyone can fit a EULA into a .sig. this one was personal...
20:43
<@Derakon>
Oh, question. Say you want to sum the numbers from 1 to n (1+2+3+...+n-1+n). There are n terms. Each can be written as (n-i), and the average value of i is n/2. So the sum of the numbers from 1 to n should be n(n-n/2) = n^2/2. But it isn't. What did I do wrong?
20:44
< EvilDarkLord>
The correct version is n(n+1)/2.
20:45
<@Derakon>
Ah, so my assumption of the average value of i is wrong, then.
20:45
< EvilDarkLord>
I suspect you're being off by one somewhere.
20:47
< EvilDarkLord>
Hmm, I think I see the problem.
20:48
< EvilDarkLord>
Right. You're not accounting for i=0, I think.
20:49
< EvilDarkLord>
Or the fact that you do not have i=n there. Pick one.
20:49
<@Derakon>
Fair enough.
20:49
<@Derakon>
I need to brush up on my big-O for an interview I have a week from Monday.
20:50
< EvilDarkLord>
Well, that's still big-O(n^2), so you're in the right ballpark.
20:51
<@Derakon>
Okay, yeah, but one thing I've learned since I left college is the importance of the smaller terms. :)
20:51
< EvilDarkLord>
And since you don't want to keep track of what all those machine instructions are actually doing usually, the ballpark is close enough.
20:51
<@Derakon>
(After all, the difference between 100n and .5n is huge)
20:51
< TheWatcher>
simontwo: I recommend applying copious amounts of fire, then
20:51
< EvilDarkLord>
(Oh, those. Yeah, sure.)
20:53
< EvilDarkLord>
You can always write it in C if Python isn't fast enough.
20:53
<@Derakon>
I think the gains from running in C would be outweighed by the losses from writing in C. :)
20:54
< EvilDarkLord>
C is not that hard if all you're doing is a prime checker. :)
20:54
< EvilDarkLord>
Well, until you want primes above MAX_INT I guess.
20:56
<@Derakon>
I've already solved several problems trivially thanks to arbitrary precision.
20:56
< EvilDarkLord>
Granted, all those tables involved in an efficient prime checker make it that much more likely you'll segfault along the way, but that's life.
20:57
< EvilDarkLord>
Ah yes. I seem to recall there being one problem in particular that was stupidly easy thanks to arbitrary precision.
20:57 * Derakon solves a problem that's only been solved by 8808 other people~
20:57
<@Derakon>
There's several.
20:57
<@Derakon>
Sum of the digits in 2^1000, for example.
20:57
< EvilDarkLord>
That's the one.
20:57
< EvilDarkLord>
len(str(2**1000))
20:57
< EvilDarkLord>
No, wait.
20:57
<@Derakon>
Not quite. :)
20:58
< EvilDarkLord>
sum([int(x) for x in str(2**1000)])
20:58
<@Derakon>
reduce(add, [int(c) for c in str(2**1000)], 0]
20:58
<@Derakon>
Hee.
20:58
< EvilDarkLord>
Ha! Mine is shorter!
20:58
<@Derakon>
Yeah, yeah.
20:58
<@Derakon>
I forgot about sum()
20:59
< EvilDarkLord>
And you forgot def add(a,b): return a+b :p
20:59
< EvilDarkLord>
(Plus whitespace)
20:59 Consul [~consul@Nightstar-1864.dsl.sfldmi.ameritech.net] has quit [Quit: Leaving]
20:59
< EvilDarkLord>
But yeah. That's a bit silly when you're using Python. With C there's Libraries and stuff for it, but quite a bit more work.
21:00
<@Derakon>
...wait a second. The problems renumber themselves?
21:00
< EvilDarkLord>
Which numbers?
21:00
<@Derakon>
My 022.py is for problem 19.
21:00
<@Derakon>
Maybe I just named the file wrong?
21:00
< EvilDarkLord>
I hear there were some changes after answers got published.
21:05
< simontwo>
someone published all the answers?
21:05
< EvilDarkLord>
I doubt it. But probably quite a lot.
21:05 * simontwo shrugs.
21:07 * EvilDarkLord approves of Derakon's use of functional programming in his answer to the 2**1000 one.
21:07
<@Derakon>
#22 is...silly.
21:08
<@Derakon>
"Here, read this text file and do some basic ASCII math on it."
21:09 Consul [~consul@Nightstar-1864.dsl.sfldmi.ameritech.net] has joined #code
21:09 mode/#code [+o Consul] by ChanServ
21:11 * TheWatcher ponders the perl version of that
21:13
< TheWatcher>
perl -e 'foreach $c (split(//,2**1000)) { $t += $c; } print $t;' I think...
21:16 GeekSoldier [~Rob@Nightstar-8573.midstate.ip.cablemo.net] has quit [Ping Timeout]
21:16
<@Derakon>
Hee. Problem 67 has 10687 solvers. Problems 66 and 68 have 1956 and 1962, respectively.
21:16
<@Derakon>
That's because anyone who solved #18 with a non-brute-force solution can easily solve #67.
21:16
<@Derakon>
(And there's a note in #18 referring to #67)
21:17
< TheWatcher>
Hm, no, as the string it splits is actually just "1.07150860718627e+301" rather than the actual number. hum *shrug*
21:17
< TheWatcher>
I have webapps to write, so
21:28
< EvilDarkLord>
TheWatcher: And Perl doesn't care about something silly like variable initialization so $t is 0 when you add to it for the first time?
21:29
<@Derakon>
EDL: if you aren't doing "use strict;", then all variables are initialized to "empty", whatever that means in-context.
21:29
<@Derakon>
E.g. dicts with no entries, lists with no elements, the empty string, 0, etc.
21:29
<@Derakon>
(This is part of why you always do 'use strict;' for serious work)
21:31
< TheWatcher>
EDL: if you're running it without strict settings, yeah
21:36 GeekSoldier [~Rob@Nightstar-8573.midstate.ip.cablemo.net] has joined #code
21:36 mode/#code [+o GeekSoldier] by ChanServ
21:38 Rhamphoryncus [~rhamph@Nightstar-7184.ed.shawcable.net] has joined #code
21:41
<@Derakon>
Oh, wow. Haven't seen this one before: OverflowError: (34, 'Result too large')
22:08
<@Vornicus>
Sweet.
22:08
<@Vornicus>
What are you doing?
22:08
<@Derakon>
I was trying to directly calculate the 1000th Fibonacci number (instead of calculating the 999 prior numbers) using Binet's formula.
22:09
<@Vornicus>
Heh.
22:09
<@Derakon>
phi^1000 breaks Python.
22:09
<@Vornicus>
Yeah, I imagine so.
22:09
<@AnnoDomini>
...
22:10
<@AnnoDomini>
Unfortunate number there. Rule 34 and all.
22:10
<@AnnoDomini>
And 'too large' in the same line? That's just... <_<
22:11
<@Consul>
Yeah, come check out the size of my number set.
22:14
< PinkFreud>
python's number calculation depends on host system mmeory, doesn't it?
22:14
<@Vornicus>
That there would be a float calculation
22:15
< PinkFreud>
and? :)
22:15
<@Vornicus>
So it uses the Double type, which on every system I'm aware of.
22:15
<@Vornicus>
is the 1/52/11 split.
23:56 KBot [AnnoDomini@Nightstar-29746.neoplus.adsl.tpnet.pl] has joined #Code
23:57 AnnoDomini [~farkoff@Nightstar-28115.neoplus.adsl.tpnet.pl] has quit [Ping Timeout]
23:57 KarmaBot [~karma.bot@Nightstar-28115.neoplus.adsl.tpnet.pl] has quit [Ping Timeout]
23:59 KBot is now known as KarmaBot
--- Log closed Sun Apr 19 00:00:34 2009
code logs -> 2009 -> Sat, 18 Apr 2009< code.20090417.log - code.20090419.log >