« first day (323 days earlier)      last day (3692 days later) » 
00:00 - 16:0016:00 - 00:00

12:44 AM
0
Q: Ten thousand and first prime checker takes a very long time

user2405469I am attempting problem 7 on project euler, I have come up with this solution which works fine for finding smaller nth prime numbers, but really lags when it comes to higher nth prime numbers, I am not quite sure where to start to make it more efficient, here it is: public class TenThousandFirst...

 
@OP -> NoTag : @ChrisW -> C# @rolfl -> Java @Jamal -> Jamalized
 
lol
2
 
And, no answer from me just yet 'cuz I am off to dinner
 
And this is what I was afraid of: people may confuse and . But then again, no one ever reads the wikis.
 
And I did not fix it when I was there ;-)
didn't notice
 
12:51 AM
With so many edits, nearly everything sticks out to me. @_@
 
1:09 AM
0
Q: First time BDD: Testing the same things in both acceptance and unit tests

FabianI just tried BDD for the first time and implemented a simple Semantic Versioning Bumper in Python. The class takes a version string in the format of major.minor.patch (i.e. 3.2.2, where major=3, minor=2, patch=2). Then you can bump a level, say patch, and you'd get 3.2.3. If you bump minor, you'...

 
I <3 JAVA 8
2
But I am very tired, so good night!
 
Goodnight!
 
2:07 AM
26,256 - just beat 2048 again! Gotta uninstall that game from my phone, it's a life-eater!
 
Off-topic:
0
Q: infix to postfix using a overloaded istream operator in C++

ldicus34My teacher has given my class a program that converts an infix expression like A+B*C into postfix. I have finished the other pieces of code but the overloaded istream operator is giving me some problem. This is the error I'm getting: error: there are no arguments to 'convertToPostfix' that depen...

 
Welcome to CR! Sorry to be the "close police", but per our help center this question appears to be off-topic because it is about debugging non-working code. Have you tried getting help on Stack Overflow? — Mat's Mug 8 secs ago
^^ not taking chances anymore - "close police" at work...
 
Which is still what we need to help account for all the off-topic questions that keep getting asked here.
 
yeah.. I guess that frustrated user somewhat got to me yesterday
"look, I'll delete the post just to make you & the close police happy"
 
You're not alone in that. It irritates me that people won't read before using the site for the first time. We must keep quality content on this site.
 
2:16 AM
-1
Q: Infix to postfix using a overloaded istream operator in C++

ldicus34My teacher has given my class a program that converts an infix expression like A+B*C into postfix. I have finished the other pieces of code but the overloaded istream operator is giving me some problem. This is the error I'm getting: error: there are no arguments to 'convertToPostfix' that d...

 
Yet another Java answer. ;-)
1
A: Ten thousand and first prime checker takes a very long time

JamalThe square root calculation could just be done before the loop. Since this value does not change within the function, it doesn't need to be recalculated each time through the loop. public static boolean isPrime(int num) { if (num % 2 == 0) return false; int squareRoot = Math.floor(Math...

 
@Jamal I'll drink to that!
 
ChrisW's comment did sort of make me nervous.
 
he's saying your answer is correct!
 
Yeah, I know. I was referring to the JVM thing.
 
2:21 AM
I guess that's how C++ mostly differs from C# and Java - the runtime is doing a great part of the work in the latter two. C++ is compiled to native code right?
 
I guess so. I haven't heard of C++ compilers optimizing that part.
 
I think I'm going to start coding the object-oriented fish tank / ocean.
 
Darn, I was about to make a joke. :-P
 
How dare you mug me of my upcoming joke!
2
 
2:27 AM
I meant about editing the vampire part out...
 
At least I was able to fit in a pun. ;-)
 
(drags The 2nd Monitor to.. the 2nd monitor)
 
I kinda wish I had a second monitor. I've always used just one. Though, I'm not sure how well my laptop will render graphics on both, especially with games.
 
Get one. Your life will change forever ;)
 
Maybe when I find a really good deal on Amazon. I'm mostly saving my giftcard money in case my laptop stops working.
 
3:24 AM
@Mat'sMug Better still, get two more.
 
two laptops?
 
@Mat'sMug Two more monitors (three total). With three, the center monitor remains the clear "primary" monitor; with two, both often end up at enough angle that neither is entirely comfortable.
 
Perhaps we can change the room's name to The 3rd Monitor after graduation.
 
3:46 AM
Allright TTGTB - 'night @all!
 
4:40 AM
Badge run complete
 
I should've spent more votes on the query prior to the reload. Not much activity today.
 
You only have one badge candidate on the list, and it already had my +1
 
Ah, right. That's for my assembly answer. I'll take another look at the query now.
 
@Jamal set the UserID to -2 so that it uses the new data
 
Code Review is awesome!
 
4:46 AM
Well, thats not really news to us now,, but, you're welcome .... ?
Your clock-widget is cool
 
@rolfl Thanks
 
I checked out the fiddle that Elias had put together, I assume the code is mostly yours though
Welcome to the 2nd monitor, by the way.
Now you have found the secret ingredient for earning SE Reputation
aannnddd TTGTB for me
I have not been voting like I should
Real life happened
 
5:53 AM
@rolfl You let life get in the way of chatting and voting? Your priorities need serious examination... :-)
 
6:04 AM
0
Q: Who can help me understand this confusing programming project that needs to be used in the C++ environment of Virtual Studio?

Carolyn PerkinsAs I am trying to understand the concepts of Friend Functions, Overloaded Operators, and Inheritance in C++. I am very confused on the specifics used for coding, since I am fairly new in programming, and working in the Virtual Studio C++ environment in writing code. The following is the project...

 
6:25 AM
@JerryCoffin: Nailed it. :-) I was a little hesitant as there were so many common things to point out.
 
6:51 AM
@Jamal Yeah, it happens...
 
I had to focus on some computer security homework anyway.
 
7:29 AM
0
Q: I am getting Aborted (core dumped) in below code

fSazyHi in my below code for testing realloc() I am getting the error Aborted (Core dumped). The output of the code is below $ ./realloc My Name // <<-- This works Aborted (core dumped) // <<-- why this error occur? The code is below #include <stdio.h> #include <string.h> #include <stdlib.h> ch...

 
 
1 hour later…
8:42 AM
0
Q: Twitter Bootstrap collapsing ONLY "phone view" navbar menu on click

CamouThis is a hard question for me to ask, because I don't really know how to explain it. So, please, bare with me. Bootstrap menu, as I know, has 2 modes: "desktop" mode "phone/tablet" mode. The desktop mode is anything above 767px width, and the later is anything bellow or equal (to 767px). Easy,...

 
 
1 hour later…
9:56 AM
@rolfl Thanks for the review. Probably one of the most positive reviews I've gotten from you, especially when compared to the time I used a whole lot of PrintStreams... :)
 
10:49 AM
@skiwi I might need a bit of Java 8 help
 
11:02 AM
@monkey (@rolfl) and @skiwi, what say you about this?
28
Q: Java 8 Iterable.forEach() vs foreach loop

nebkatWhich of the following is better practice in Java 8? Java8: joins.forEach((join) -> mIrc.join(mSession, join)); Java7: for (String join : joins) { mIrc.join(mSession, join); } I have lots of for loops that could be "simplified" with lambdas, but is there really any advantage of using t...

 
11:18 AM
Morning
And hey @SimonAndréForsberg
 
Hey @skiwi
 
You want my opinion about the foreach?
 
Use the new .forEach if it is possible without making things unnecessarily complicated
So you need to be using oneliners
 
And I was wondering what the easiest way to iterate over a Stream<T> is? It's strange that Stream<T> doesn't implement Iterable<T> but it has an iterator() method.
 
11:21 AM
It cannot involve variable modification
And putting operations that throw Exceptions, usually means it will be a mess
Erm can you show what you mean by iterating a Stream<T>, the context of your question
 
Just have to find where I wanted to use it...
 
ok
 
Let's take an IntStream as an example instead... it'd be nice to iterate over IntStream.range(0, 10) for example, instead of for (int i = 0; i < 10; i++) .... Something like for (int i : IntStream.range(0, 10))
or perhaps there's a good reason for why that doesn't seem to be possible that easily? (performance perhaps?)
 
I don't see what you are exactly trying to do... What do you want to do with it in the end?
For printing you can for example:
IntStream.range(0, 10).forEach(System.out::println);
That is a form of iterating, but intentionally does not allow you to modify any effective non-final variables
 
I want to create Sudoku Rules. I'm converting my C# Sudoku code to Java 8
16
Q: SudokuSharp Solver with advanced features

Simon André ForsbergEven 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...

Here's an example:
		for (int x = 0; x < board.getWidth(); x++) {
			final int posSetI = x;
			board.createRule("Column Upper " + x, box(1, DEFAULT_SIZE).stream().map(pos -> board.Tile(posSetI, pos.getY())));
			board.createRule("Column Lower " + x, box(1, DEFAULT_SIZE).stream().map(pos -> board.Tile(posSetI, pos.getY() + DEFAULT_SIZE + BOX_SIZE)));

			board.createRule("Row Left "  + x, box(DEFAULT_SIZE, 1).stream().map(pos -> board.Tile(pos.getX(), posSetI)));
			board.createRule("Row Right " + x, box(DEFAULT_SIZE, 1).stream().map(pos -> board.Tile(pos.getX() + DEFAULT_SIZE + BOX_SIZE, posSetI)));
 
11:30 AM
This is Java, right?
 
(that's Samurai Sudoku btw)
yup, Java 8
 
I don't know the differences between C#, except that I'd except PascalCase, and I think lambdas are with => rather than ->
Which must be very fun for you to type everytime and remember ;P
But back to the question...
 
haha, I've gotten used to the differences already. I don't use C# much anyways.
 
I don't like what you are doing here :P
The problem is that you are passing Stream<T>s around
Is there any way I can see the full code? I don't know if you have it up on a repo yet
 
What's the problem with that?
I can put it up on GitHub right now
 
11:32 AM
Streams aren't meant to be passed around in my opinion
But for that I need to see what you do with them ^^
 
In this case I do:
	public void createRule(String description, Stream<SudokuTile> tiles) {
		createRule(description, tiles.collect(Collectors.toList()));
	}
 
Hang on
For that image
Our email addresses had sneaked in
instead of a stream, you should be passing on a List or a Predicate I would say without looking too much at the code
 
Hey Simon, you're welcome
And, about Streams.... In my opinion (and my opinion is still forming about these things), Streams should onl be used when you have a streaming problem
 
Hey @rolfl
 
Morning @rolfl
Or is it... afternoon?
 
11:40 AM
And when do I have a strewaming problem?
 
hey there
When you have an item of data that needs to be transformed in various phases through a 'process'
Like items on a conveyor belt
In some languages, streams are optimized in a different way.... but, in Java, the optimization is not as great
 
Hmm.... but how can I use filter and map and stuff without using streams?
 
filter takes items off the con veyor belt.
map takes the data and converts it to something else
 
c:\Users\Zomis\Desktop\Dropbox\Projects\Zomis\SudokuEight>git pull
      0 [main] us 0 init_cheap: VirtualAlloc pointer is null, Win32 error 487
AllocationBase 0x0, BaseAddress 0x68560000, RegionSize 0x340000, State 0x10000
C:\Program Files (x86)\Git\bin\sh.exe: *** Couldn't reserve space for cygwin's heap, Win32 error 0
¤"()/¤@@@€
 
That looks... not good
I'm trying to trigger the merge tab on my repo, no success yet either
 
11:44 AM
If you have a problem where data needs to be injected, or re-directed from the stream, then your system is not ideally suited to the stream API
 
@rolfl You might have some stuff to say about that on my first Java 8 question which will be about my Sudoku code. I'll try to make things as I think they should be and then we'll see what you think.
I have to try a reboot to fix this git problem
 
I need to figure out why I'm not being able ot commit to my own repo
Heh it just appeared and blatantly overwrot simon's message... That is not good
Has anyone ever used GIT with Netbeans?
 
yes, but not me :=0
 
I'm trying to figure out how to trigger a merge stream, maybe google knows
Ah, I may have been doing things in the wrong order
This is driving me crazy, somehow I keep overwriting Simon's message, if I edit the same line
Would a question about it be fit for SO or for SU?
 
12:06 PM
SO
There's a lot of git questions on SO
I'm trying to solve a merge conflict here... hmm...
 
Well, you atleast have a merge conflict... I am not receiving them
 
@rolfl I've writed new comment your answer. codereview.stackexchange.com/questions/44289/…
 
Hi @sallamaniaa
 
Hi @sallamaniaa
There could be so many reasons for delays like that.
Sure, the code may be one of them.... I nave not seen the latest version of your code, and even if I did, I would probably need to run it myself to see where the issues are.
There has been the suggestion to disable Nagle's algorithm (TCP_NODELAY) which is a good suggestion.
 
12:13 PM
Same without tcp_nodelay
 
Now I've gitted my Java 8 code to GitHub
 
@SimonAndréForsberg - one of the things I did not mention is the dependencies you are missing in your github repos.... net.zomis.fight.*, etc.
 
@rolfl net.zomis.fight and net.zomis.scores is also available on Github. github.com/Zomis/Fighting and github.com/Zomis/AIScorers
 
Do I need them aswell to make the code compile?
 
I haven't yet learned exactly how to handle the Git-way of dealing with dependencies...
 
12:15 PM
should I edit my codes?
 
@skiwi For SudokuEight you don't need them
 
Ah ok
can you add me as a collabarator then on the SudokoEight?
 
That I can do, if I just find the button...
 
@sallamaniaa not your question, but you may want to post another follow-on question
 
Meanwhile I will avoid comitting anything until I figure out why netbeans is not triggering conflict messages
 
12:17 PM
ok. It'll follow-on
 
@skiwi You're added. I still have some cleaning up to do though, especially with using Java coding conventions instead of C# conventions :)
 
No problem
Now I'm the one who needs to figure out how to link it with the repo
 
@SimonAndréForsberg - good use of streams:
 	public boolean checkComplete() {
 		return _tiles.stream().allMatch(tile -> tile.hasValue())
 				&& checkValid();
 	}
 
@rolfl Thank you :)
 
Bad use of streams : ;-)
 
12:22 PM
Why do I suspect there'll be a "bad use of streams" incoming also?
 
    SudokuProgress removePossibles() {
        // Tiles that has a number already
        Stream<SudokuTile> withNumber = _tiles.stream().filter(
                tile -> tile.hasValue());

        // Tiles without a number
        Stream<SudokuTile> withoutNumber = _tiles.stream().filter(
                tile -> !tile.hasValue());
 
0
Q: How can i make this code more OOP and standard compliant?

user3452076i am not a very experienced php developer and i just started my first open source project. Since i have to cooperate with other people i think i should review my way of coding, since i know it's not really object oriented. Also it would be helpful if anyone can link me a guide a good guide to oop...

 
Why is that bad use of streams?
 
So it seems like I was creating a NB project, then a Git project, and then yet another NB project... Doesn't seem to be the way I should be using it
 
because you could have done both at the same time in one simple foreach
 
12:23 PM
Wait a minute.... should I create a copy of the collection and use removeIf?
A stream foreach or a good old foreach? :)
Let me try an alternative...
 
In order to get with and without Number you are streaming the data twice.
 
Yes, I realized that
 
Actually, it is a bad example of a bad stream.
 
@SimonAndréForsberg Your code compiles just fine... right?
 
You have to check all the data that way anyway.
@skiwi the sudoku solver compiles fine for me
 
12:27 PM
illegal character: '\ufeff', on the package net.zomis.sudoku lines
 
I blame NetBeans :)
 
Only SudokuProgress is a happy file
 
feff is the UTF-8 Byte-mark.
 
ImmutablePoint is also happy
 
Tell netbeans the source files are UTF-8 not ascii
 
12:28 PM
Yup, indeed it's the good old package net.zomis.sudoku;
 
Gotta see how I can tell it
Encoding: UTF-8
It already thinks it is in UTF-8
 
There is an easy fox for this
 
Of course, all the issues I encounter today have like no hits on Google.
 
 
12:31 PM
lol, gotta star that @rolfl ^^
What do you think about this approach then... doesn't feel like it's the best way but I think it's an improvement:
Map<Boolean, List<SudokuTile>> hasValue = _tiles.stream().collect(Collectors.groupingBy(tile -> tile.hasValue()));
List<SudokuTile> withNumber = hasValue.get(Boolean.TRUE);
 
I'll eat some lunch, then I'll take a look at it aswell, despite the errors for now
Rewreiting every package statement seems to work
 
@SimonAndréForsberg You know, scanning your code I can't see horrible usage of things
 
I take that as a good sign...
 
The snippet above shoud rather be a filter with the predicate v->hasValue()
 
It was pretty straight-forward to just "translate" the old LINQ usage to Java 8
 
12:37 PM
(unless you are also using the Boolean.FALSE results as well)
 
@rolfl And how to do that filter for both withNumber and withoutNumber at the same time?
Yes, exactly...
		Map<Boolean, List<SudokuTile>> hasValue = tiles.stream().collect(Collectors.groupingBy(tile -> tile.hasValue()));
		List<SudokuTile> withNumber = hasValue.get(Boolean.TRUE);
		List<SudokuTile> withoutNumber = hasValue.get(Boolean.FALSE);
 
OK, so then it is good.
 
Looking at your code is interesting to me.
 
feels a bit overkill to make a map of it... but that's the way it's done :)
 
12:38 PM
My 'issue' is that I have a legacy of baggage I have learned, and I need to unlearn some stuff for Java8
 
In what way is it interesting?
 
Your Java8 usage is more 'real-life' than @skiwi 's
 
Ah... well, it'll take a while for me too I think to get used to Java 8, especially since I will still have to use Java 6 every now and then...
 
@skiwi has been doing artificial problems, and other Java8 reviews have been for artiicial stuff
In most cases I have seen, the streams are being shoe-horned in to places they don't belong
 
I think my code benefits from the fact that I have used LINQ, even for just a little bit
It seems to me like the Streams in Java 8 is a lot like IEnumerable in C#.
 
@rolfl That's a tag and not a question...
Should I consider all 1892 of them?
 
That is stupid.
Let me try that again.
9
Q: Java 8 Effective Use of Multiple Streams

MonkeyWithDartsI am experimenting with streams and lambdas in Java 8. This is my first serious foray using functional programming concepts; I'd like a critique on this code. This code finds the Cartesian product of three sets of ints. My questions/complaints about this snippet are: Are nest flatMaps really t...

 
Hmmm.... I see what you mean...
And I see that Santa just gave you [badge:nice-answer]
 
Ahh, nice-Santa!
 
Is that code.... actually.... iterating over all the 1000 combinations?
 
12:46 PM
It is forcing a 'nested stream structure' and using the values on the outer streams as tokens in a loop.....
Then, the inner-most stream pulls references from the scope of the system a, and b, and merges it with c to become the Product
Note that in the inner stream, the a and b are not taken from the stream itself.
 
Hmm... I'll take a closer look at it later, I'm going to eat lunch at my parents' place now. Be back later this afternoon (European afternoon, that is)
 
And breakfast for me.
@skiwi - you know, I look at that multi-stream and think, hey, maybe it is not so bad.
 
I'm back now
I saw a few pings :p
@rolfl What part do you mean?
 
with a little bit of editing, I can see a way to make it readable
That's all
 
ok
 
12:53 PM
And, I will play with it after BFast.
 
0
Q: How can the efficiency of this code be better?

shshThis game is similar to a Dungeons and Dragons game. How could I improve the efficiency of the program. For example where can I add functions , records etc. This is for a school Controlled Assessment so any help would really be appreciated. Thanks. import random play1 = True str1 = int(input("...

 
My Netbeans is so mad at @SimonAndréForsberg's code... Violates a load of style constraints :P
@SimonAndréForsberg After reviewing it a little bit, I think too much magic happens in your code, I can comment on it later
It bothers me a lot for example that your SudokuRule takes in a Collection<SudokuTile> as argument, I would expect it to take a Predicate<SudokuTile> by intuition
 
0
Q: error rectification

user39255import json import sys from csv import writer with open(sys.argv[1]) as in_file, \ open(sys.argv[2], 'w') as out_file: print >> out_file, 'tweet_id, tweet_time, tweet_author, tweet_author_id, tweet_language, tweet_geo, tweet_text' csv = writer(out_file) tweet_count = 0 for l...

 
1:30 PM
0
Q: Latency problem for keyboard remoting from Android phone - follow on

sallamaniaaI'm writing a simple remote PC app (mouse-keyboard). Android is the client and is connected with WiFi to Java PC Server. I'm using TCP but When I've test it where a bit far of my Wi-Fi modem then I see some latency sometime. I see all time normal latency (3-5 ms) but sometimes I see 1000-2000 ms,...

 
1:49 PM
Got me laughing for a minute
84
Q: How can a Java variable be different from itself?

MagicanoI am wondering if this question can be solved in Java (I'm new to the language). This is the code: class Condition { // you can change in the main public static void main(String[] args) { int x = 0; if (x == x) { System.out.println("Ok"); } else { ...

My GIT question for NB has gotten a whole 3 views in an hour on SO
 
@skiwi - if I am not mistaken the OldCurmudgeon answer was subsequently posted here for review or something... let me check.
Nope, I was wrong, but I have seen that somewhere before.
 
2:07 PM
@skiwi I tried to answer it.
I'm not sure that the TCP latency problem is on-topic: because it's closer to asking for debugging/explanation than to asking for a code review.
 
@ChrisW - there is, unfortunately, some history....
 
More lenient with follow-on questions.
 
Actually, it is not unfortunate, but.... the issue is that the issue is a performance problem, and it's not related to the code.
Previous versions of the code were functional, but very, very, very slow.
This version is functional, and fast, but, occasionally slow.
It is actually on-topic for code-review, but the wi-fi part is the problem
 
Sending keystrokes is the canonical use-case for TCP_NODELAY (which I suggested previously). I posted a comment to ask whether the TCP connection is being reset/re-established. I'm wondering whether to suggest UDP instead.
 
Both those suggestions have been suggested multople times
Scroll up a bit here... hang on:
 
2:16 PM
@ChrisW That could make sense what you just posted
So I could only generate a merge conflict if I hadn't pulled the changes? (Which I canot reproduce now I think)
 
2 hours ago, by sallamaniaa
@rolfl I've writed new comment your answer. http://codereview.stackexchange.com/questions/44289/latency-problem-for-keyboard‌​-remoting-from-android-phone-follow-up
 
@skiwi Otherwise you can't edit someone else's code.
 
I see
 
@ChrisW the original (first version) had both a UDP and a TCP implementation
 
So I was worried about nothing?
 
2:18 PM
Editing someone else changes is normal; if you know what you're editing. If the edit only exists on the remote repo (and you're editing an old version) that's a potential merge conflict.
@rolfl Why was UDP discarded as a potential solution?
 
Mar 13 at 17:31, by sallamaniaa
@rolfl I will going to use TCP. I beleive TCP will be fast. But I can use also UDP which user want.. sorry for your wait.
@sallamaniaa - you seeing any of this?
 
2:34 PM
hi
 
@sallamaniaa Is the checkSocket function creating a new TCP connection when that happens? Or is the slow-down happening within one TCP connection?
And why did you decide to discard the UDP-based solution and use TCP instead?
@Jamal "ChrisW's comment did sort of make me nervous." -- The reason I made that comment was because the same answer had occurred to me, but I didn't dare post it (not knowing Java well): because it's something which a compiler could, IMO, theoretically, optimize away. After you posted it, I wanted to +1 it; but I don't want to fan-boyishly +1 anything that's incorrect (because votes are supposed to be peer reviews of the answers), so I went looking for evidence that it's true.
 
I thought may UDP will be lost data where a far of my modem. But actually I didn't test it.
 
@sallamaniaa UDP may lose data. With UDP you can implement your own "resend until acknowledged" by the sender, and "send acknowledgement after receiving" by the server, complete with choosing your own retransmission delay (e.g. resend every 50 msec) instead of using the functionaliy that's built-in to TCP.
 
2:50 PM
So, UDP inside of TCP for could'nt send data?
 
@sallamaniaa - ChrisW is suggesting that you implement a light-weight protocol on top of UDP (i.e. no TCP), so that you can get the server to acknowledge the receipt of the key-stroke.
 
If the delay is happening within the same TCP connection (and if there's no problem with the way in which you're using TCP: I haven't reviewed your code again, except to see that you are using 'no delay') then IMO you can't control that delay (except conceivably with an Android-specific API or configuration which I don't know about).
 
It is my opinion though, that the TCP solution you have is fine, and, if there is a problem, move closer.
Other solutions/apps are probably using UDP with some custom protocol.
It is probably a better solution, but it is much harder to implementn right.
 
Because you can't control the TCP delay/retransmission I was suggesting you implement your own protocol using UDP instead of TCP, because you can control when you retransmit using UDP (using TCP you don't need to retransmit: because the TCP connection will retrnsmit if necessary; except you may need to retransmit if the TCP connection fails).
 
You appear to be new to network programming, so you should probably do a lot more research before you go in to those areas where experience is more useful.
What is clear from your main question, though, is that your system is working well enough when the devices have string signal.
 
2:59 PM
If you use UDP, UDP is unreliable. If you need "guaranteed delivery" on top of UDP then you need to implement your own "send and wait for acknowledgement and if no acknowledgement then resend until you do receive an acknowledgement or until you give up". On the server side you need to send acknowledgements, and detect-and-discard possible duplicates.
 
figuring out why it is slow when the signal is weak is not something that you are likely to solve here (on CodeReview, unless you get lucky), and additionally, for someone to diagnose/troubleshoot the problem, it would help for them to be on your exact network in your weak-signal areas. Obviously, that would be a challenge too.
 
This resend/acknowledge/detect duplicates functionality is built-in to TCP and is (part of) the reason why people usually prefer TCP instead of UDP. The one benefit of UDP is that you can implement more aggressive retries (e.g. every 50 msec instead of slower than that).
"aggressive" meaning "more frequent, with less delay".
 
I'll read your comments. My English is slow like my app. Thanks.
 
Yes. Ask another question if we said something which you don't understand.
 
3:25 PM
meanwhile . I'm tested UDP. I see any latench(1-2) and tested a far of my modem there is not any problem. Sometimes be data lost.
 
@sallamaniaa something simple like sending an incrementing number plus the key, for example 'hello' would be sending 1h 2e 3l 4l 5o, then only sending the next character when the server sends a reply like 1ok 2ok 3ok, etc. If the server takes more than a few milliseconds to send the ok response, then send it agian.
The server may be sending multiple responses to your character, but that is OK too if they get lost, because it will still send the OK message even if it has sent that character's OK message before, because the OK may not have gotten through.
If this fails, say 5 times in a row, then you have a bad connection
 
The server may receive multiple/duplicate copies of a keystroke. It must acknowledge all of them but detect/discard duplicates (using the 'incrementing number' to detect duplicates).
This works best on a LAN.
 
@skiwi I think there's still some C# style left in the code. I'm working on it :)
@skiwi I am not that familiar with a Predicate yet... A SudokuRule doesn't know about all the fields, doesn't a Predicate act like a filter? How would accepting only a predicate return a collection?
@skiwi Link your question here and it will get some more views
@rolfl Would you say that there is conceptually something wrong with taking variables from a previous stream scope without taking them from the stream itself? I think I have done this somewhere in my code.
I can understand why it's not a good idea in the cartesian product question, but is it "always" bad?
 
3:54 PM
@SimonAndréForsberg Well, can you tell me what your sudoku rule is?
 
@SimonAndréForsberg honestly, I am not sure any more, and I am not sure the scope is exactly 'wrong'.
Remember, I am learning this too.
 
@skiwi It's a restriction for a group of tiles that must be unique. For example, one row is a SudokuRule because all tiles in the row must be unique for the puzzle to be solved.
 
Let me take a moment, and re-structure the OP's code in a way that makes sense (a different idea). give me 5min
 
0
Q: how to reduce the complexity of the given code?

arunkrishnamurthy01below is my solution for a problem set in coding contest by a popular judge,The solution in Java manages to solve the problem but iam regularly getting the Time Limit Exceeded issue,Can anyone advice how to reduce the complexity of this code??,Thanks in Advance :) import java.util.*; import ja...

 
3:56 PM
So SudokuRule is (in normal form) either one row, or one column, or a 3x3
 
@skiwi Yes, exactly.
@rolfl In my code I make use of the 'variables from other stream scopes thing' here:
	public static Collection<ImmutablePoint> box(int sizeX, int sizeY) {
		Collection<ImmutablePoint> points = new ArrayList<>(sizeX * sizeY);
		IntStream.range(0, sizeX).forEach(x -> IntStream.range(0, sizeY)
				.forEach(y -> points.add(new ImmutablePoint(x, y))));
		return points;
	}
 
And what do you want to save?
 
@skiwi Each rule needs to have a Set of the tiles that belong to that rule.
 
Also, I do not think you want to really use that code with streams with double int streams
I had it as an answer because the OP insisted on streams
 
3:58 PM
I'd say it is too vague
Also, you may want to restructure your code a bit (I know you are still working on it), but some of those chained stream operators are barely readable for outsiders who don't know every detail :D
 
00:00 - 16:0016:00 - 00:00

« first day (323 days earlier)      last day (3692 days later) »