A Human Becoming
More than a Member
Gah. I'm trying to stay positive, but I'm struggling so badly with a Coursera mini-project.
Starting to think my brain just isn't built to code.
Gah. I'm trying to stay positive, but I'm struggling so badly with a Coursera mini-project.Starting to think my brain just isn't built to code.
It's due in about 56 hours. :SIf you don't struggle with a project it wasn't worth doing.![]()
So much time. You can sleep in about 56 hours.It's due in about 56 hours. :S
Gah. I'm trying to stay positive, but I'm struggling so badly with a Coursera mini-project.Starting to think my brain just isn't built to code.
I have work tomorrow.So much time. You can sleep in about 56 hours.
I am. We should team up to help each other!Are you doing the Intro Python course from Rice University? I haven't even started this week's yet.![]()
I've been told that I probably shouldn't get too fond of BlueJ, but it's just so beginner-friendly.
Is it recommended to use functions named "push" and "pop?" That's how our professor and material referred to them but I figured that was just used for instructional purposes.
*Edit*
Also, I've already changed the program and it works as intended. Guess doing it as a stack is a lot easier lol
Congrats! Is that for an undergraduate or graduate course?
Can anyone help me to grasp what the input sizein complexity theory actually is? I guess when traversing through a list for example, it would be the number of its elements, but surely it's not always that simple?
I feel this should be really easy to understand, but somehow I'm getting hung up on this.
Guys.... I don't want to alarm anybody but I think it might be the case that P = NP....
I have to be doing something horribly horribly wrong or else I'm going to be an incredibly famous (in Computer Science) millionaire.
wtf?
Hmmm....Guys.... I don't want to alarm anybody but I think it might be the case that P = NP....
I'm using it for the first time too - from what I undertand, requestAnimationFrame sends a request to the browser to repaint the screen as soon as possible - the time it aims for is meant to give you as close to 60fps as possible, and less when the tab is in the background, to save on power. So, the following gives you 60, as long as you keep the updating under the time of a 1/60th of a second:I have a question to HTML5-gaf (if it exists
I hear that requestAnimationFrame is the new king in town.
Well, I just cant wrap my head around it, honestly.
Currently, the game I am working on uses two loops. One is the update loop, done at set intervals (1000/60 ms, basically), the other is the draw loop, done at set intervals, again (1000/30 ms).
The problem is this: I do not really understand how the requestAnimationFrame decides when to render stuff. And if it aims to 60fps, how can I force 30fps instead? The game uses manually drawn sprites, so there really is no gain for smoother animations, as it would only make the animation finish faster. Do I request an empty frame every time after a normal renderframe for 30fps or what?
Also, I am currently working with two canvases (one for the static backgrounds, other for the UI and the units), but I plan on doing three, actually. The back layer will be the background, the middle layer for animated units (30fps refresh), and the front layer would be the UI, which includes pointers, cursors, menu switches, which can easily be done at 60 or even 120fps, so that would further mess with rAF-s. And I am also thinking of introducing a fourth layer speficially for spell effects, which would mix traditional pixelart with canvas-powered effects. Hm.
function mainloop() {
//...updating, drawing...
requestAnimationFrame(mainloop);
}
var fps = 30;
function mainloop() {
//...updating, drawing...
setTimeout(function() {
requestAnimationFrame(mainloop);
}, 1000 / fps);
}
var updateFPS = 60,
doDraw = true;
function mainloop() {
//...updating...
if (doDraw){
//...drawing...
}
setTimeout(function() {
doDraw = !doDraw;
requestAnimationFrame(mainloop);
}, 1000 / updateFPS);
}
I believe they use your name if you filled in one, while repos will show your username.Anybody here use Bitbucket? If so, I have a particular question. For the registration they ask of a username along with e-mail address and password. Is the username is shown to everybody (public)? Or is the name is? Like on NeoGAF. When you register with your username, it is a public handle that everybody recognise you as. The screenshots on their website shows name instead of usernames. I am not clear on how it work.
That'd be amazing but I don't think it is. Any particular thing that makes you think it is?
I'm currently trying to clean up my code and make things more concise, so question:
Passing a SqlDataReader into a constructor from within a Read loop: good idea or bad idea?
I have an algorithm that seems to solve k clique decision problem in polynomial time (I am 100% sure it runs in polynomial time) with a fairly convincing outline for a proof of correctness and about 50k trials in an implementation I wrote this morning where it passed verification.... I'm working on graphs with 500 vertices right now.
Is there anything I don't know about the problem? some edge case I'm missing, it can't really be this easy.
Why do you need to do that? If you need every bit of data that's returned by the query then I would pass a DataSet... otherwise I would think you could read the values you need from the data and pass those to the constructor.
Well like I said, I'm just trying to clean things up, make the code neater. Rather than having 10 lines of GetBlah that might have to be repeated a few times in different methods across different classes, I would just have all of that in the constructor.
I see some odd mentions here and there of SqlDataReader acting "weird" when you pass it around, but there are no real explanations.
Usually most people think it's polinomial but don't realize they are pushing the complexity somewhere else. For example something that in code looks like one operation but the underlying implementation is dependent on the length of the input.
I don't think so. there's a loop that will run at most the number of vertices + number of edges, number of edges is at most on the order of vertices squared in a simple graph and it's easy to generate a simple subgraph from a pseudo or multigraph. so that's squared on the outer loop.
then it checks each vertex and each edge, again for squared, we're up to 4th power now.
for each check it needs to know some stuff... about some stuff >_> in a step that will be at worst, squared.
for each execution of inner loop it may or may not do a thing that is linear in cost but this is dwarfed by the squared check.
this takes us up to 6th order, after that is a constant time op to decide, and the algorithm is done.
Two points:
First off, the fact that your estimate of the program's complexity doesn't include the value of k at all is a big red flag.
Second, k-Clique is not NP for fixed values of k. The 'easy' solution is O(n^k), and the best known solution is approximately O(n^(0.8*k)). The issue with the complexity of k-Clique is that the upper bound on k is n. Therefore, finding a clique of size n/2 for example has a complexity of ~ n^(n/2), which is not polynomial.
If you really want to test this out, pick a graph with a lot of nodes, that is highly connected, and set the value of k to a value like n/2.
What's a simple way to turn an integer variable into it's equivalent char representation?
In other words, how would I go about making an int variable of let's say, 1, and save it to a char variable of 1.
I know that I could just use ASCII values to get the numbers 0-9 but what about 11 or 211 or anything else beyond one digit.
You mean in C? You would have to add the ascii value for 0 (48 I think) for each digit, and put them in a char[]. To "look" at each digit you can do: (number / 10^n-1)%10, where n is the digit index (starting from the right, starting with 1).
C++ is what I'm using. And what I'd be needing this for is to number output of files from 1 to x depending on how many files I'd need to create. So the first file would be 1.txt, then 2.txt and so on until x.txt.
What's a simple way to turn an integer variable into it's equivalent char representation?
In other words, how would I go about making an int variable of let's say, 1, and save it to a char variable of 1.
I know that I could just use ASCII values to get the numbers 0-9 but what about 11 or 211 or anything else beyond one digit.
EDIT: I was hoping people who would help would not immediately post code, I just wanna be nudged into the right direction!
...
Code:...
itoa() is non-standard, so don't rely on it.
edit: Removed code as per your request. Look at "sprintf"
Yes, this is probably better. Though, you would have to call malloc() before using sprintf, right?
C++ is what I'm using. And what I'd be needing this for is to number output of files from 1 to x depending on how many files I'd need to create. So the first file would be 1.txt, then 2.txt and so on until x.txt.
cd /path/to/my/repo
$ git remote add origin https://[username]@bitbucket.org/[username]/[folder].git
$ git push -u origin --all # to push up the repo for the first time
git problems
cd /path/to/my/repo
git init
$ git remote add origin https://[username]@bitbucket.org/[username]/[folder].git
git add . # this adds all the files
git commit -a -m "Initial commit"
git push -u origin --all
Correct git practice is to initiate a new repo for every project you need on a remote such as bitbucket. So you do
which indeed means where Visual Studio or your IDE of choice stored your project. That means if /savedProjects/ is the folder then /savedProjects/myProject/ is the correct path. When you get there you doCode:cd /path/to/my/repo
which initiates a new git repo in that directory.Code:git init
When you've done that, you need to register that new repo with a remote. To do that you do the code you posted above (I'm not used to bitbucket but if it tells you to do this then it's probably correct).
Code:$ git remote add origin https://[username]@bitbucket.org/[username]/[folder].git
You need to add you existing files to your local commit:
Code:git add . # this adds all the files
Then you need to make an initial commit, so you do:
now you've created a commit in your local repo, but not in the remote one. To put it on the remote, you do the second line you posted:Code:git commit -a -m "Initial commit"
Code:git push -u origin --all
That should be all. I'm by no means an expert on this stuff but this is how I would do it.
Two points:
First off, the fact that your estimate of the program's complexity doesn't include the value of k at all is a big red flag.
Second, k-Clique is not NP for fixed values of k. The 'easy' solution is O(n^k), and the best known solution is approximately O(n^(0.8*k)). The issue with the complexity of k-Clique is that the upper bound on k is n. Therefore, finding a clique of size n/2 for example has a complexity of ~ n^(n/2), which is not polynomial.
If you really want to test this out, pick a graph with a lot of nodes, that is highly connected, and set the value of k to a value like n/2.
Here's some output from an implementation I wrote. I wound up having to rewrite everything from scratch as the library I was using before was giving me some weird results. I'm not sure all the data structures were properly updating, could easily have been my fault somewhere.
Anyways, these graphs were generated using the erdos-renyi algorithm with a 90% chance for an edge between any two vertices. It searches for a clique that is at least some fraction of the graph size. It does 15 graphs increasing vertex count by 10 each time. It does 10 loops of that where it increases the fraction of the clique by 1/10th each time until it's searching for complete graphs in the final pass.
http://www.pastebin.ca/2374578
Anyways, I just whipped this up today so there isn't much information in the output but you should at least be able to get some idea of the scaling. both with increased k and increased graph size.
Edit: rewrote a comparison function to take advantage of my sorted lists (was brute forcing it n^2 for testing purposes). upped the probability factor to 99.5% up to 300 size graph with k = 1/2 n, MUCH better performance.
http://pastebin.com/7s73HGgs
How are you verifying the correctness of your results?
The C++ way of doing things with streams is a little complicated to set up and understand, but std:stringstream would probably be the standard way of doing that in C++.
sprintf is not well liked, as you can easily end up with buffer overflow exploits. I may scoff at Microsoft's hated for strcpy and std::transform, but there's a very real problem in sprintf in that you cannot know how big a buffer to allocate for the output.
snprintf is a little safer, as you can both limit the amount of data you write to ensure you remain within your buffer, and you can query the amount of space the formatted output would take up, and be certain you've allocated enough memory for it. Though, this function is only standard in C++11 or C99.
I was looking up some interview questions since I have my first programming interview on Wednesday. It is a Javascvript/C# job, and even though I have didn't list those two languages on my resume, they requested an interview. I'm not sure if I'll get the job, I am mainly going because I think it will be a good experience.
Anyways, one question I saw was: Explain the difference between equality and equivalence.
I realized I wasn't sure how to answer this question, so I did some research. Of course, equality refers to the value and type of the data being the same ie:
int a = 3;
int b = 3;
a = b;
For equivalence, would this be a suitable answer?
Equivalence between two things depends on their truth value given a certain property (I'm not sure if property is the right word here) ie:
Given two arrays, each with the integer c, and two integers a,b where int a is in array 1 and int b is in array 2. If int a appears before c in array 1 and int b appears before c in array 2, then a and b are equivalent with respect to the ordering property that they both appear before c.
Not an expert but probably refers to the difference between the == and === operators in javascript.
The interview questions weren't javascript specific, but I'll take a look anyways, thanks.