Even though it's the first time I'm writing something this "big", it feels like I know C# quite good. It's been nice to learn LINQ also and I am very impressed by the features, and perhaps I have overused it here (if it's possible to do that).
SudokuFactory: Contains static methods to create so...
In any future sudoku the tiles themselves could even be disjoint, as long as one set consists of 9 tiles and is correct only if it has the numbers 1 through 9 distinct?
Below is my solution for this 'Team Split' problem.
In summary, the problem is to find relative strength of 2 teams by finding the difference between their total strength (individual strengths can be found using a quadraric expression of form ax2+bx+c)
The solution in Java manages to solve the ...
In all honesty, I find your code quite illogical, I would expect a SudokuBoard to have a width, a height, and a list of a set (or list) of tiles, where the set of tiles woudl be called a group
@SimonAndréForsberg Choosing an algorithm is a pre-coding activity. If it is an algorithm issue, the only reason for doing a code-review is to reverse-engineer the algorithm in order to choose a better one.
@SimonAndréForsberg I have doubts on your `SudokoFactory`, in some sudoko formats it creates the board ánd assigns the groups to the boards. In other formats (the simple one), the board needs to handle creating the groups itself.
@ChrisW Even if the question is only about picking a better algorithm, I think it can be a good question. I think it should be perfectly on-topic. The worst part about this particular question/code is his horribly bad variable names.
Doesn't matter if the OP cares about them or not, we care about them.
Your code is odd in the sense that it is going to a lot of effort to calculate that 103 is 1000.
I understand why you are doing it, but I took the liberty of changing the count() terminating function and replacing it with:
StringBuilder sb = new StringBuilder();
.......
.forEachOrdered(prod ->...
@skiwi Because I wrote the code just to be a SudokuSolver, I wasn't planning on making a game out of it. And I was frustrated with Visual Studio when I wrote it so I didn't extract the solving much.
@skiwi The code I have for Sudoku is not 'playable'. Code for playing it could easily be added, but I didn't see the need to. I just wanted to solve sudokus.
i would probably have like 2-3 of them installed but not running and then pick a day of the week where I run them one after the other after updating them or something like that.
@skiwi Looping over each rule is unnecessary as one tile can be within any number of rules. By only looping over the 2D array I only perform it on each tile once.
so today after few years of not programming in php I decided to go back, but to do so I need to change all mysql connections. So I want to check if I am using it good.
So I used to write something like this:
$user = clean($_COOKIE["Logged"]);
$GameReg = mysql_fetch_array(mysql_query("SELECT * F...
@skiwi Readable, but I'm not sure that forEachTile method would be used in other places? I actually used a good old for-loop at first but wanted to do it Java 8 style :)
@SimonAndréForsberg If you insist on Java 8 style I'd take the Consumers out of Java 8 instead of double forEach with Arrays.stream(), and to really warrant this approach it needs to be used on at least 2 places
@Nobody An existing room owner can change the list of room owners, and if all previous owners are absent for a long while the system automatically chooses new owners. @Mat'sMug got promoted by the system a while ago and he added some regulars to the list
If a reasonably active room has no owner, or none of the owners have been in the room for a certain time, a new owner may be automatically appointed, to ensure that there's somebody who can administrate.
The system will pick the room's most active user in this case and make them owner; this is announced via an automatic message. If the user does not want to be room owner, they can revoke ownership from themselves by going to the access tab on the room info page and setting their status back to “no special access”. Before they do this, they should find …
@JerryCoffin - bein a curmudgoen myself, I will point out I said this in my answer:
> A for-loop is the right thing for this construct (if it was not for the parallelism). If you include the parallelism, then a fork-join process is right. Not a stream.
@rolfl I refuse to settle for merely "old" -- "ancient" or bust...
@rolfl What you didn't point out though is that in this case, the parallelism almost certainly loses more than it gains. The time to spawn threads, or even dispatch to threads in a pool, almost certainly exceeds anything you could hope to gain from running such trivial computation in parallel.
I guess I didn't point that out explicitly either though. I should probably edit.
I read the Wikipedia article on /dev/null and was playing around by moving files to /dev/null.
For this I created a test_file and put some contents in it:
$ touch test_file
$ echo "This is written by Aditya" > test_file
$ cat test_file
This is written by Aditya
Thereafter I tried to move the ...
@skiwi: I wonder if there is something like a /dev/null measure to categorize your program's resilience against such unlikely things as reading some values from /dev/null
Basically, you need to replace the DLL that Windows uses to implement its random number generation. Windows tries to prevent its known DLLs from being overwritten, but with a little persistence (and administrator rights) it can be done.
guys the issue is my solution involves sorting of arrays and that increases the complexity,any workarounds such that sorting can be avoided to solve that problem. — arunkrishnamurthy0140 mins ago
So I posted an answer which tried to address that.
We're current close to double the volume of Ask Different, so my guess is that sustaining the current level (with reasonable growth in new users and such) may well be sufficient.
A secret santa gift exchange is a game where each player is randomly assigned a person to whom they anonymously give a gift. The algorithm is referred to as Derangement.
For example, given the following players:
Mohamad, Carolina, Sami, Tania, Ikram, José
An game may be:
Mohamad gets Sami
Ca...
@Jamal I was thinking about cr-challenge, assuming that CR is a well known enough abbreviation for Code Review, but commuinity-challenge would work also. Perhaps bring it to a meta vote (which will boost our meta activity even further)
It seems that users are still using the code-challenge tag for challenge-oriented questions that do not correspond to the site's occasional voted-upon challenges. We already have the programming-challenge tag for off-site challenge programs, but it's understandable that the two tags sound simila...
It seems that users are still using the code-challenge tag for challenge-oriented questions that do not correspond to the site's occasional voted-upon challenges. We already have the programming-challenge tag for off-site challenge programs, but it's understandable that the two tags sound simila...
For class we were to make a MapReduce program in python to find low value hashes of our name. I have completed the assignment but want to try and speed it up. Currently the program takes about 45s to complete. I would like to see if there are any suggestions to speed it up some.
The requirements...
When I'm not working nor with my family, I have rehearsals with my band, I compose, play and listen to music, I party with friends (like 3 to 4 times a week), I watch porn, I read books or mangas and I do some other things from time to time.
It's probably one of the only physically-fit things I've done willingly, and it did help me make many friends. Unfortunately, I haven't played my trumpet since graduation, which was four years ago.
I am working on a chess game in Python. I've finished, so far, the functions that return possible moves for pawns, rooks, and bishops. When I try to move a bishop, however, I get this error:
File "F:\Python\Chess.py", line 562, in getBMoves1
if getList(NC(NC(NC(NC(NC(c))))))[m-5]==' ':
IndexE...
I'm writing a virtual machine in Python using RPython and the PyPy toolchain. The RPython will still work in the ordinary Python 2 interpreter, it's just a bit slow unless it's compiled to C code with PyPy.
The virtual machine has 4 instructions:
EOP - End of Program
EOI - End of Instruction
P...
I have to write a program that counts the uniques characters in a String given by the user. For example "abc" returns 3 and "aabbccd" returns 4. I am not allow to use advanced Java classes like Map, Set, etc. I can only use arrays, Strings, for loops, while loops, if statements. I am trying to u...
I'm writing a virtual machine in Python using RPython and the PyPy toolchain. The RPython will still work in the ordinary Python 2 interpreter, it's just a bit slow unless it's compiled to C code with PyPy.
The virtual machine has 4 instructions:
EOP - End of Program
EOI - End of Instruction
P...
> Status Update, 2014-03-23: It's no use! The percentages are barely budging. Although we have nearly doubled the number of ≥4k users since mid-Janurary, we're also gaining a lot of new avid users. The increased upvote activity has undoubtedly been beneficial, but I'm not convinced that this query is a useful metric of the vitality of the community.
@Mat'sMug If the number of avid uses is constantly growing, it's hard to ensure everyone is endlessly promoted; yet apparently that's their definition of a healthy site.
Using a third-party library which utilize boost::shared_ptr for memory management. Problem is that I need to allocate very many objects and I have detected that the allocation and deallocation is rather resource demanding. So I thought I should utilize a smart-pointer memory pool to reduce the ov...
I'm working on a little game where you press a button and a new image appears. There's a glitch every time you ask a new image to display and it occurred to me that I should preload the necessary images. However, I'm not sure how to do this efficiently as I'm not using a variable to display the i...
I finally found how to convert geomagnetic coordinate back to geographic coordinate
I'm so close to the correct answer but slightly off
This is my function, but the result are off by several degrees and I'm not sure if its due to rounding and such when I'm propagating values from function to fun...
I have created my monopoly board using PHP,MySQL,HTML, CSS here is a previous question of mine. Also I would like to share a visual image of what the board looks like in the browser.
I no longer want to use MySql or PHP to generate the board, instead I want to do it with Jquery. Also I am intere...
I'm not sure about the Monopoly question. The Op says he's looking for an approach review, not a code review. There are also some off-topic requests in there.
I'm trying to create a basic triangle with modern OpenGL (3.0+) on Mac OS X Mavericks. Actually, I'm quite new to modern OpenGL, so any feedback is welcome!
Now, this code compiles, runs, doesn't throw any error, and creates a nice black-backgrounded window, but nothing more. However, when I ask...