Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks.
Pattern p = Pattern.compile("[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?"); Matcher m = p.matcher("-0.2847715"); if (m.find()) { System.out.println(m.group(1)); }
why does it return null? is the regex wrong?
Because your matching group doesn't contain any characters. It will only match strings of digits (positive or negative) that start with e or E. If you add an exponent to your number, you'll see that it works fine.
You'd probably find it useful to use a regex debug tool for this sort of stuff, like RegExr
It is matching them, but you're requesting the value of group 1, which is just the ([eE][-+]?[0-9]+) part. If you want the entire match, you can get group 0 instead, or just call #matches() to get a bool back.
Morfildur, that 1D vs 2D array got me interested, so I googled a bit. Isn't it a bad approach to use 1D? You lose readability and better debugging in that case. On the other hand, what about calculations you need to do for the 1D array to act like 2D? That is surely overhead as well, so is it worth it in the end? I assume compilers are also smart enough to optimise anyway.
On September 28 2013 21:49 darkness wrote: Morfildur, that 1D vs 2D array got me interested, so I googled a bit. Isn't it a bad approach to use 1D? You lose readability and better debugging in that case. On the other hand, what about calculations you need to do for the 1D array to act like 2D? That is surely overhead as well, so is it worth it in the end? I assume compilers are also smart enough to optimise anyway.
In 99% of the cases the overhead doesn't matter since you aren't programming time critical applications for a tiny microprocessor but applications that just have to be fast enough on an average PC. My simple PHP solution takes a few microseconds to calculate any sudoku riddle i could find and it's not optimized at all. It's easily fast enough for what it is supposed to do, which is what matters.
Solving Sudoku is not a difficult thing for a PC, so you can easily throw away all thoughts about optimizing and just go with what feels easiest.
For me a 1D array felt easier, though for the most part because PHP doesn't have true 2D arrays but only jagged arrays. I also only have to keep one variable on mind when looping through the grid instead of having to consider the cases where i reach the end of the row or have to go a step back at the start of a line, i can just increment/decrement my way through.
What is easier depends on your preference and in my opinion both a 1D and a 2D array have good arguments going for them, so there is no wrong choice. The same is true for deciding between a simple loop or a recursive solution, both are correct and fast enough. I just don't like recursion much, so i picked a loop instead.
What are some good colleges/universities for Computer Science/Game Development in the New Jersey area?
Any good questions I can ask said colleges/universities about their CS/Game Development program? I'm kind of at a loss here.
At the moment I'm a Junior in HS and am investigating Rutgers, Ramapo, Bloomfield, Fairleigh Dickinson, Lincoln Technical Institute, and am looking to try and find some more to help narrow down my search to 'the right fit'. Any comments/experiences of these colleges/universities would also help me. I'm just starting my journey into searching for the right college(I've been to 2 college fairs). I'm grateful for any additional information.
colleges/universities for Computer Science/Game Development
Not the same. In my area there are specialised schools for Game Development. They teach the very basic CS skills, but other than that they mostly focus on how to make pretty papers and sell your ideas to a publisher / lead a team.
If you want to be programmer in Game Development it does not actually matter much where you go, most CS departments run at least in the master degree some modules for 3d graphics, you are also free to choose your own bachelor work. To me computer science geared towards game developement specificly is humbug, as with any decent CS education you will easily be able to gain the knowledge required.
On September 28 2013 22:16 3FFA wrote: What are some good colleges/universities for Computer Science/Game Development in the New Jersey area?
Any good questions I can ask said colleges/universities about their CS/Game Development program? I'm kind of at a loss here.
At the moment I'm a Junior in HS and am investigating Rutgers, Ramapo, Bloomfield, Fairleigh Dickinson, Lincoln Technical Institute, and am looking to try and find some more to help narrow down my search to 'the right fit'. Any comments/experiences of these colleges/universities would also help me. I'm just starting my journey into searching for the right college(I've been to 2 college fairs). I'm grateful for any additional information.
lol nice. Also add this one for after you get out:
I hope the indie game industry keeps taking off and making that xtranormal video obsolete. But, make sure you know what the job market looks before you go in, so you know what you're getting yourself in to.
On September 28 2013 22:16 3FFA wrote: What are some good colleges/universities for Computer Science/Game Development in the New Jersey area?
Any good questions I can ask said colleges/universities about their CS/Game Development program? I'm kind of at a loss here.
At the moment I'm a Junior in HS and am investigating Rutgers, Ramapo, Bloomfield, Fairleigh Dickinson, Lincoln Technical Institute, and am looking to try and find some more to help narrow down my search to 'the right fit'. Any comments/experiences of these colleges/universities would also help me. I'm just starting my journey into searching for the right college(I've been to 2 college fairs). I'm grateful for any additional information.
Distinguish between game schools (e.g., Full Sail) vs. universities and colleges with game degree programs. Very, very generally speaking, university and college game degree programs are more "trustworthy" than game schools which is what the video critiques.
That being said, be careful about picking game degree programs. Depending on the college, the program can be a weaker version of a traditional degree offering. My personal advice: if you are interested in focusing on computer science (vs. art or design), then go for a traditional computer science degree. That way you have the flexibility of a complete education to fall back on if you decide to not pursue the game industry or it doesn't work out.
You should remove the points that just hilarious and you aren't really doing yourself a favor, it is just absolute arbitrary and your order is quite odd (why is average better than good?)
On September 28 2013 21:49 darkness wrote: Morfildur, that 1D vs 2D array got me interested, so I googled a bit. Isn't it a bad approach to use 1D? You lose readability and better debugging in that case. On the other hand, what about calculations you need to do for the 1D array to act like 2D? That is surely overhead as well, so is it worth it in the end? I assume compilers are also smart enough to optimise anyway.
In 99% of the cases the overhead doesn't matter since you aren't programming time critical applications for a tiny microprocessor but applications that just have to be fast enough on an average PC. My simple PHP solution takes a few microseconds to calculate any sudoku riddle i could find and it's not optimized at all. It's easily fast enough for what it is supposed to do, which is what matters.
Solving Sudoku is not a difficult thing for a PC, so you can easily throw away all thoughts about optimizing and just go with what feels easiest.
For me a 1D array felt easier, though for the most part because PHP doesn't have true 2D arrays but only jagged arrays. I also only have to keep one variable on mind when looping through the grid instead of having to consider the cases where i reach the end of the row or have to go a step back at the start of a line, i can just increment/decrement my way through.
What is easier depends on your preference and in my opinion both a 1D and a 2D array have good arguments going for them, so there is no wrong choice. The same is true for deciding between a simple loop or a recursive solution, both are correct and fast enough. I just don't like recursion much, so i picked a loop instead.
Not that it was really designed to, but it doesn't solve all Sudoku puzzles. For example, it fails to solve the first two problems described here:
First he describes a Sudoku board and some functions for parsing a grid, which might be useful to the original problem posed by Darkness.
Next he talks about constraint propagation and just a brute-force search for trying to solve the puzzle, neither of which are feasible for solving all puzzles.
Then he describes a depth-first search algorithm with backtracking which he uses to solve all the example puzzles he could find. Finally, he discusses the performance of the algorithm and how it runs on a few million randomly-generated puzzles, with about 99.95% taking less than 0.1 seconds, and the longest at 1439 seconds (this one has no solution).
I know this isn't what Morfildur was trying to show or what darkness was asking exactly, but the article's a nice read and it's interesting if you're curious about search algorithms. It also provides another idea for how to define the Sudoku board which is what darkness was asking originally, using a hashmap and board positions.
As well, to add to the talk of performance, here the performance comes more from choice of algorithm than implementation details. For example, many choices of search either can't solve many of the problems, or they're very inefficient and will basically run forever, but by choosing the right algorithm, many of those problems can be solved very quickly. There's a good example of this under the "Search" section of the article, where Norvig describes why the brute-force approach isn't viable.
Obviously, you would get an error now if you mess up the order. However, isn't there a problem with overusing wrappers? You may end up with tons of class files. And is this approach useful to do for the sake of methods and what not? Yeah, I know it's required to use wrappers for Collections but I'm asking if it's good to implement wrappers for any other general use.
On September 29 2013 09:06 darkness wrote: So I had a lecture this Friday and my lecturer was explaining wrapper classes besides the well-known ones like Integer, Boolean, etc.
He was trying to explain that it's easy to mess up the order of passed arguments to a method. E.g. you've declared
public int calculate(int energy, int mass) {}
However, you may call the method wrong like calculate(mass, energy) instead of calculate(energy, mass).
So as far as I remember, he has written code similar to this to solve that problem by using wrappers.
Obviously, you would get an error now if you mess up the order. However, isn't there a problem with overusing wrappers? You may end up with tons of class files. And is this approach useful to do for the sake of methods and what not? Yeah, I know it's required to use wrappers for Collections but I'm asking if it's good to implement wrappers for any other general use.
I would phrase his lecture another way. The problem with the calculate function is that the types of energy and mass are not precise enough. Because both of their types are int, we're (implicitly) stating that energy and mass values are interchangeable when they are clearly not.
The way to fix this problem is to give energy and mass more precise types. The way in Java you introduce new types is to create new classes that correspond to these new types. So the wrapper class Energy and Mass are implementations of more precise types for energy and mass values within your program that are not interchangeable. It turns out that you need no additional methods on Energy or Mass objects, so they act as a simple wrapper over the int type.
In the absence of any kind of optimization, the cost of a wrapper is potentially significant. You are replacing a bare int with an object (whose contents are its type tag along with the int itself). Creation of a Mass object induces a heap allocation which is much more expensive that allocating an int (on the stack). Finally, accesses to the underlying integer also induce a method call. Therefore, the creation of many Mass objects or repeated access to Mass objects may become a performance bottleneck.
That being said, the compiler/JIT should inline calls to getMass which removes the overhead of accessing Mass objects. Unfortunately, the type tag and heap allocation cannot be optimized away, so these remain performance concerns in practice.
Whether such wrappers for the sake of better types is "worth it" depends on your program, i.e., its an engineering decision. You have to weigh the cost of potentially mixing up these types and the cost of the associated bugs with the actual performance hit that you induce by introducing better types. While the things I said above sound pretty grim, the performance cost may be insignificant compared to the rest of your program.
On September 29 2013 09:06 darkness wrote: So I had a lecture this Friday and my lecturer was explaining wrapper classes besides the well-known ones like Integer, Boolean, etc.
He was trying to explain that it's easy to mess up the order of passed arguments to a method. E.g. you've declared
public int calculate(int energy, int mass) {}
However, you may call the method wrong like calculate(mass, energy) instead of calculate(energy, mass).
So as far as I remember, he has written code similar to this to solve that problem by using wrappers.
Obviously, you would get an error now if you mess up the order. However, isn't there a problem with overusing wrappers? You may end up with tons of class files. And is this approach useful to do for the sake of methods and what not? Yeah, I know it's required to use wrappers for Collections but I'm asking if it's good to implement wrappers for any other general use.
Depending on the language, you don't need class files for each class. You can write multiple classes in C++ in one file, im unsure about Java but there I think you need the 1 file per class and that does get a little big. Nevertheless, there is a perfomance cost (very very tiny one but it does exist) to implementing those. An alternative would be using C/C++ 's typedef, although they dont give out compiler warnings if you mess up the order (since you define both as int and they can be casted) but it would be more visible in some IDE's (like eclipse) if you hover over the vars and functions and you check their types. If you really want a wrapper class (and aren't stuck on java) I suggest overloading operators in there ( = being most obvious)
On September 28 2013 22:16 3FFA wrote: What are some good colleges/universities for Computer Science/Game Development in the New Jersey area?
Any good questions I can ask said colleges/universities about their CS/Game Development program? I'm kind of at a loss here.
At the moment I'm a Junior in HS and am investigating Rutgers, Ramapo, Bloomfield, Fairleigh Dickinson, Lincoln Technical Institute, and am looking to try and find some more to help narrow down my search to 'the right fit'. Any comments/experiences of these colleges/universities would also help me. I'm just starting my journey into searching for the right college(I've been to 2 college fairs). I'm grateful for any additional information.
Distinguish between game schools (e.g., Full Sail) vs. universities and colleges with game degree programs. Very, very generally speaking, university and college game degree programs are more "trustworthy" than game schools which is what the video critiques.
That being said, be careful about picking game degree programs. Depending on the college, the program can be a weaker version of a traditional degree offering. My personal advice: if you are interested in focusing on computer science (vs. art or design), then go for a traditional computer science degree. That way you have the flexibility of a complete education to fall back on if you decide to not pursue the game industry or it doesn't work out.
Ok thanks! What questions should I ask to learn whether it is a traditional degree offering? I'm not exactly someone that went through a traditional degree in computer science so I have no idea as to how I tell a traditional CS degree from a shallow CS degree.
Also, is going to a Community College to get an Associate's degree and then transferring over to a 4 year college for the next 2 years to get the Bachelors a good idea that will save me/my parents money or will it most likely just leave me with 5-6 years instead of 4?
On September 28 2013 22:16 3FFA wrote: What are some good colleges/universities for Computer Science/Game Development in the New Jersey area?
Any good questions I can ask said colleges/universities about their CS/Game Development program? I'm kind of at a loss here.
At the moment I'm a Junior in HS and am investigating Rutgers, Ramapo, Bloomfield, Fairleigh Dickinson, Lincoln Technical Institute, and am looking to try and find some more to help narrow down my search to 'the right fit'. Any comments/experiences of these colleges/universities would also help me. I'm just starting my journey into searching for the right college(I've been to 2 college fairs). I'm grateful for any additional information.
Distinguish between game schools (e.g., Full Sail) vs. universities and colleges with game degree programs. Very, very generally speaking, university and college game degree programs are more "trustworthy" than game schools which is what the video critiques.
That being said, be careful about picking game degree programs. Depending on the college, the program can be a weaker version of a traditional degree offering. My personal advice: if you are interested in focusing on computer science (vs. art or design), then go for a traditional computer science degree. That way you have the flexibility of a complete education to fall back on if you decide to not pursue the game industry or it doesn't work out.
Ok thanks! What questions should I ask to learn whether it is a traditional degree offering? I'm not exactly someone that went through a traditional degree in computer science so I have no idea as to how I tell a traditional CS degree from a shallow CS degree.
Also, is going to a Community College to get an Associate's degree and then transferring over to a 4 year college for the next 2 years to get the Bachelors a good idea that will save me/my parents money or will it most likely just leave me with 5-6 years instead of 4?
A standard computer science degree (vs. a more vocational-focused degree) will roughly look like:
(1) Introductory programming (2) Discrete mathematics, theory of computation, and algorithms (3) Systems and architecture (4) Specialization courses such as operating systems, compilers, networks, databases, etc.
You should be able to peruse a department's website for their degree requirements and see if it matches roughly with this skeleton. Degree programs that skimp on one or more of these topics will leave you less prepared for the job market and narrow the scope of jobs that you can take out of the gate.
Going to a community college is fine if your financial situation demands it. How it plays out depends entirely on the community college and the target 4-year institution and boils down to what credits the latter accepts from the former. That's something that the 4-year institution's CS department should be able to answer if you have the list of classes that you have taken from the community college.
I've got a question related to Java coding. I'm quite new to coding, it only has been 3 classes i've had up to now and no lie, I find it quite hard. For one of my code, I'm supposed to get this result: + Show Spoiler +