Learning about the Model-View-ViewModel pattern for WPF applications. (It's awesome)
Trying to get my small (eventually) cross platform windowing library to work on OS X. Gotta love errors that make no sense.
[code]
<Error>: Unknown Error
[/code]
Thanks GDB. You're the best kind of debugger. :|
Trying to compile corona on centos. Anyone ever do it? Problem is that is is a 7 year old library. It for some reason cannot find libpng/libjpeg and g++ 4 isn't liking it either :\.
I'm trying Project Euler again. I'm on number 12. Any clue on why my code is going slow, or is this just a side effect of my brute forcing?
[cpp]#include <iostream>
using namespace std;
long long fact(long long);
int main()
{
bool done = false;
long long i = 1;
for(; fact(i) < 500; i++) {}
cout << i << endl;
system("pause");
return 0;
}
long long fact(long long x)
{
int num_divisors = 2;
for(int i = 2; i < sqrt((double)x); i++)
{
if(x % i == 0)
{
num_divisors++;
}
}
return num_divisors * 2;
}[/cpp]
[editline]10:13PM[/editline]
Fuck, I just realized I was doing it wrong.
I am doing Project Euler as well. I started last wednesday and did up to number 10. I haven't worked since. I should work on 11 now.
Now my beautiful code looks like:
[cpp]#include <iostream>
using namespace std;
long long fact(long long);
int main()
{
long long i = 1, q = 1;
for(; fact(q) < 500; i++)
{
q += i;
}
cout << i << endl;
system("pause");
return 0;
}
long long fact(long long x)
{
int num_divisors = 2;
for(int i = 2; i < sqrt((double)x); i++)
{
if(x % i == 0)
{
num_divisors++;
}
}
return num_divisors * 2;
}[/cpp]
What am I doing wrong this time?
Casting long long to double could slow the program down a bit, but not really that much.
Also, wouldn't you need a long double to fit a long long?
[cpp]
long long timeAgo;
// in a galaxy far far away...
[/cpp]
[QUOTE=esalaka;24934591]Casting long long to double could slow the program down a bit, but not really that much.
Also, wouldn't you need a long double to fit a long long?[/QUOTE]
No. Floating-point numbers trade precision for range. So a double will cover the entire range of 64-bit integers, but it will discard some of the less significant digits.
I'm not entirely sure whether the loss of precision is important in this particular application. It all depends on whether the value is rounded up or just truncated. If it's the latter (I think it probably is), then it's probably going to be a problem.
[editline]06:41AM[/editline]
Your code is slow because you're brute forcing.
Think of it this way. We store UNIX time values as the number of seconds since January 1, 1970. It is usually stored in a single 32-bit integer. This number won't exceed the limits of a 32-bit integer until 2036.
Now, a 64-bit integer is that value squared. A 64-bit number could count seconds for roughly 580,000,000,000 years. If your loop does 1,000,000 iterations per second, then you won't run out of values for 580,000 years.
You'll never get anywhere by incrementing a number that requires a long long int one value at a time.
Actually, if I may make a correction, 32-bit UNIX time will end in 2038, not 2036.
[QUOTE=Z_guy;24908930]I've added graphics to my minesweeper clone.
[img]http://img440.imageshack.us/img440/8831/minesweeper.png[/img]
If you want to try it you can download it here: [url=www.zguyserver.mine.nu/files/Minesweeper.rar]Download[/url].
Feel free to come with suggestions.[/QUOTE]
Two things :)
1) Need a way to restart the game easily
2) Minesweeper on Windows does this (pretty neat), if on your first guess you hit a mine, it rescrambles the game and makes it so you didn't hit a mine.
That way you can never lose on the first go.
[QUOTE=streeter;24935775]Two things :)
1) Need a way to restart the game easily
2) Minesweeper on Windows does this (pretty neat), if on your first guess you hit a mine, it rescrambles the game and makes it so you didn't hit a mine.
That way you can never lose on the first go.[/QUOTE]
The feature that you can't lose on first hit it for noobs who can't pick a good starting square. Use Mines-perfect so you can turn this feature off so you can play minesweeper the way it's supposed to be played. I can't believe that Windows minesweeper doesn't rearrange the whole field when you are about to click a mine - makes you feel like badass minesweeper God :P
[QUOTE=sim642;24937680]The feature that you can't lose on first hit it for [b]noobs who can't pick a good starting square[/b]. Use Mines-perfect so you can turn this feature off so you can play minesweeper the way it's supposed to be played. I can't believe that Windows minesweeper doesn't rearrange the whole field when you are about to click a mine - makes you feel like badass minesweeper God :P[/QUOTE]
Are you seriously implying that skilled minesweepers are better at picking a starting square?
[QUOTE=noctune9;24937861]Are you seriously implying that skilled minesweepers are better at picking a starting square?[/QUOTE]
He explicitly stated it.
[editline]08:44AM[/editline]
So I'm trying to get my Gcode renumbering program onto the school computers. How can I get it so that I don't need a DLL (MSVC100P.dll or something) to run it?
[QUOTE=Agent766;24937873]He explicitly stated it.
[editline]08:44AM[/editline]
So I'm trying to get my Gcode renumbering program onto the school computers. How can I get it so that I don't need a DLL (MSVC100P.dll or something) to run it?[/QUOTE]
C++?
Switching from /MD to /MT forces it statically link to the library. Will give you a 500kb+ program but it doesn't require MSVC100P.dll.
[editline]10:59AM[/editline]
Also, why is it that no one uses the IRC anymore? We really should bring some life back into it. I remember it dieing due to the people who were opped though. Maybe we should start a new channel.
[QUOTE=high;24938863]I remember it dieing due to the people who were opped though. Maybe we should start a new channel.[/QUOTE]
I doubt it, the channel didn't require much maintenance to begin with. Maybe there's too many ops.
[QUOTE=high;24938863]Also, why is it that no one uses the IRC anymore? We really should bring some life back into it. I remember it dieing due to the people who were opped though. Maybe we should start a new channel.[/QUOTE]
I never knew there's an IRC channel! In which network is it?
#fpcoders on gamesurge I think
[QUOTE=gparent;24938950]I doubt it, the channel didn't require much maintenance to begin with. Maybe there's too many ops.[/QUOTE]
I remember a ton of bitching constantly and ops doing nothing about it :(.
I'd totally use IRC if I wasn't :tinfoil: about everyone seeing my IP/domain every time I logged in.
[QUOTE=high;24939185]I remember a ton of bitching constantly and ops doing nothing about it :(.[/QUOTE]
I haven't been very active recently, but I'll try to look over the channel more often. Recently, life has been busy with the international competition I'm taking part of and it's demanding a lot of my time.
[QUOTE=ROBO_DONUT;24939282]I'd totally use IRC if I wasn't :tinfoil: about everyone seeing my IP/domain every time I logged in.[/QUOTE]
You can set a custom mask on GameSurge. Along with some IRC client magic, it will mask on launch.
Am I the only person in the world that doesn't use IRC?
Yes. [url=http://www.irssi.org/]Start now[/url].
[QUOTE=gparent;24939330]You can set a custom mask on GameSurge. Along with some IRC client magic, it will mask on launch.[/QUOTE]
I'm a total nub to IRC :\. I'd assume that's the title thing mentioned [url=http://www.gamesurge.net/cms/HostServ]here[/url]?
I'm going to try to set up irssi. Brace for failure.
[QUOTE=ROBO_DONUT;24939282]I'd totally use IRC if I wasn't :tinfoil: about everyone seeing my IP/domain every time I logged in.[/QUOTE]
Then use a shell account as a proxy.
[QUOTE=eXeC64;24940132]Then use a shell account as a proxy.[/QUOTE]
I got the authserv title thing up and running, so I'm good.
[QUOTE=Agent766;24932753]Now my beautiful code looks like:
[cpp]
...
for(int i = 2; i < sqrt((double)x); i++)
...
[/cpp]
What am I doing wrong this time?[/QUOTE]
Bit late, but there's a way to optimise your for loop:
for(int i = 2; i*i < x; i++)
No casting and I'm pretty sure multiplying is faster than square rooting.
I've been working on a DLL export viewer, which should help me debug things.
[img]http://dl.dropbox.com/u/2399384/exportviewer.png[/img]
I've been working on a new lighting system this past weekend. It supports dynamic lighting and shadows.
[img]http://i55.tinypic.com/mif5gx.png[/img] [img]http://i56.tinypic.com/29fwls5.png[/img] [img]http://i55.tinypic.com/s4cqoi.png[/img]
I actually had to write this system twice. Once because I never did this before so I just wanted to work. But after realizing that one light alone dropped the fps from 310 to 50 didn't look too good. So I scrapped it and remade it fully optimized. I benched marked it and I ran a scene with about 20 + lights in an area with 30 + active blockers (things that cause shadows). And still maintained an fps of around 90+. And this was while I was recording it. So yeah, perty gud. :P
Here's 2 videos of it. First one was before optimization.
[url]http://www.youtube.com/watch?v=NFxENq0xiWU[/url]
[url]http://www.youtube.com/watch?v=tILhn-kLBZg[/url]
Second one is unlisted because I'm just talking the whole time. :/
I love this
Been keeping up with your youtube.
BTW did you know that our site is down?
Sorry, you need to Log In to post a reply to this thread.