« first day (2019 days earlier)      last day (2924 days later) » 
00:00 - 18:0018:00 - 20:00

12:00 AM
oh you mean if I have tried puzzles that are impossible to solve?
is that it?
 
fge
Actually no
 
oh wait never mind.
 
fge
But anyway
 
Just to let you know, I have two sudoku algorithm.
 
fge
If you want to parallelize, at some point you will have points of contentions; points which you cannot solve unless some other computation task has solved it for you
And the danger here is that no two threads should be waiting for one another
That is called lock inversion
A waits for B, B waits for A
And that is why parallel algorithms are hard :p
Well, that is one reason why parallel algorithms are hard
There are others
 
12:02 AM
Well let me at least try to explain how I'm going parallelizing this algorithm.
So let us say we have 4 * 4 board. So you would agree that we have 4 rows correct?
What I'm trying to do is assigning a row for each thread to work on.
At least this way, no other thread can insert a value in an array they are not working on but there definitely could be inconsistencies.
At this point, I would like to show you my code and the part I'm trying to parallelize.
 
fge
OK, go on
 
ok hold on.
 
fge
(in a pastebin, please)
 
I know :)
I'm going to post two links. Each link has a class ok.
SudokuBoard Class. paste.ofcode.org
 
fge
12:20 AM
That's a link to the site
 
Damn it
Lets try that again SudokuBoard class paste.ofcode.org/7wGRUNWNtcBMs2Pce2cufk
 
guys what do you call a king's chair?
I think it starts with th-
 
MultiThreadedNaiveSolver Class paste.ofcode.org/88tgTxhWiM37PZb3RxFz6D
 
it's on the tip of my tongue...
 
The only interesting part in SudokuBoard class is the solveSudoku method.
@Unihedron Well what is the joke?
 
12:27 AM
It's not a joke. I'm looking for the word.
 
Strange I don't know why I read it as a joke.
 
... Don't worry about that and help me.
 
Probably because that is usually how you introduce a joke.
What about a throne?
 
Thank you!
 
12:29 AM
I needed it for the caption of the illustration here: game-of-dice.wikia.com/wiki/Incomplete_Controller
 
Well glad I could help.
Throw me another word.
 
Sure.
 
fge
1:16 AM
@LuisAverhoff in this, line 33: since you return line 31, the else is unnecessary
Well, all along the source
If you return, no need for else
 
Yes you have a point but I think it clearly explains that we either skip or try all possibilites.
Basically I like it because of readability sake
 
fge
Have you ever considered a class for each cell of the board instead of a plain array of integers?
Well, to me, it makes the code less readable :p
If I see an else, I take it to mean that the previous code path did not return
 
Regardless you still understand what it does :)
 
fge
Yes, but I find it painful to read
:p
 
Alright I will consider it.
 
fge
1:21 AM
Also, consider this, line 25 and line 58
 
gotcha
 
fge
Why not just write, to begin with: if (index >= board.getGrideSize()) [on new line] return true;
That reduces indentation level by one all of a sudden :p
Adorn all that with a comment too :p
 
wouldn't it be equal.
 
fge
That would be the same, yes
 
not >=
 
fge
1:23 AM
Your initial condition is index < board.getGridSize()
We want the opposite of it
Therefore, index >= board.getGridSize()
 
I know but the intention is that we want to visit every cell.
So why would we visit more than the required cells?
 
fge
Sure, but then you only do so if the index is strictly less than the grid size
No, wait
 
hence I dont understand why the >= is needed.
 
fge
I'm talking about naiveSolver()
 
should be ==
me too.
 
fge
1:25 AM
OK, well, == if you want
That is the same
 
This is my point.
If I have 16 cells and I want to visit every cell, why would visit more than 16?
 
fge
But the point is, avoid doing if (condition) { /* loads of code */ } else { return somethingElse }
Rather, do if (!condition) { return somethingElse } /* load of code here */
 
Yes I agree on that.
 
fge
That makes the code not only easier to read, but also easier to comment
 
But all of that can be easily change so dont worry about that too much. I will editing this later. The main thing is that it works.
Remember first you make it work, then each time you make it a little bit better. It's like worrying about efficiency when you haven't even coded anything.
 
fge
1:28 AM
OK, but making the code more legible is "free" :)
 
True I do appreciate that.
Have I explained the problem that I'm having with the multithreaded sudoku solver class yet?
 
fge
No, but your code seems to suffer a "responsibility problem" if I may say
 
Well simply put, any puzzle I give it returns false even though the single threaded solver version of this solves it.
Look at the solveSudoku method
in SudokuBoard class.
 
fge
The problem is in .setValue()
It is not thread safe
 
Is that really the only problem?
From what you see.
 
fge
1:34 AM
It is one gaping problem at least
 
Ok but do you see a problem in the solveSudoku method?
That is the method that is doing the multithreading
or at least trying
 
fge
What about line 82?
You seem to return false if only ever one thread fails to return true
Is this really your intent?
 
Here is my reason
 
fge
83, I meant
 
I'm assigning each thread to work on a particular row
Their task is done once they reach the end of that row.
At the end, they will either return true or false.
To me false means that they could not solve that portion of the board.
For every thread to return true, the board must have been solvable.
 
fge
1:39 AM
You lost me there
How does the single threaded version work then?
 
Ok here we go.
We start at 0,0 ok
row 0 column 0
if the value is not zero skip it.
if it is, test that cell with a value. This value can be from 1 to N.
N being the size of the grid.
So in a 4 * 4 board
it is from 1 to 4.
These are our possibilities or our values to test
If a value doesn't work
we erase that value and try another one.
If we try all possibilities and none of them work, we backtrack to the previous cell.
 
fge
Ow
That is HUGELY expensive
 
ow or oh
Yes this is why it's called naivesolver.
hahah :)
imagine a 25 * 25 board. Stackoverflow here I come.
 
fge
And I don't see how bactracking to the previous cell can even make you go forward
I'm missing something
You don't even inspect other cells on the same row or column?
 
yes there is a method called isBoardValid that inspects the row, the column and the subgrid.
before insertion
Trust me the single threaded one works perfectly.
Ok how about I show the single threaded class.
See it's pretty much identical with some minor differences.
 
user5293625
1:55 AM
anybody help me with likely blindingly obvious problem?
 
user5293625
I want to loop this... until a boolean "left room" = true
 
Well when is left room true?
in which case?
 
user5293625
But whenever I put a while loop around it requiring that "leftroom" = false, it stops accepting input.
 
user5293625
1:58 AM
When you move forward, input e, it becomes true.
 
user5293625
Clarification: it accepts input, but ceases to use input. Tried with "f".
 
So you want it to continually loop until the user presses 'e' correct?
 
user5293625
Yes.
 
user5293625
But...
 
user5293625
Oh.
 
user5293625
2:00 AM
I guess it was blindingly obvious.
 
why not just while(!leftroom)
or a do while loop
 
user5293625
That's when it stops working.
 
fge
@LuisAverhoff one other possibility of things going wrong is your isBoardValid() method
 
How? if leftroom is false and you ! it, it becomes true.
it should work caleb.
 
user5293625
! it?
 
2:02 AM
The not operator
the logical not operator
 
user5293625
while (leftRoom = false){
?
 
No while(!leftroom) in english translates to while you have not entered the leftroom.
 
user5293625
Not entered?
 
user5293625
gwah! Infinite loop!
 
You only have one boolean variable. You know if they have not pressed e than you have not entered the left room.
 
user5293625
2:04 AM
ok
 
Just try while(!leftroom)
 
user5293625
Now I have this, which is better:
 
@fge How is isBoardValid not working if it worked for my single threaded class?
Exactly
 
user5293625
But how to re-accept inputs...
 
user5293625
2:07 AM
I can break, but it stops the loop.
 
user5293625
Else... Output loops infinitely
 
I'm assuming that you're working on some kind of game. If so, please define at what stage does the game end.
 
user5293625
If I put it into the else if, it requires a double input.
 
user5293625
Uh... Probably won't get there for weeks.
 
user5293625
When you die. Or achieve final objective.
 
user5293625
2:09 AM
Then your score is printed.
 
user5293625
This is just the intro, and it's really shoddy so far :(
 
user5293625
I thought about using enum, but it isn't much less code and it doesn't enjoy looping.
 
Ok then why dont you have a main game loop that says while game is not over, continue asking for input. Then you can have a method that constantly asks for input.
 
user5293625
This is like that but smaller. For intro room.
 
user5293625
Somebody run this code and tell me what the hey is wrong with it please. :(
 
why break?
just set leftroom equal to true when they type e.
 
user5293625
Seems legit.
 
user5293625
But how do I now keep looping until 'e'?
 
user5293625
Where do i put the line for accepting another input in the loop?
 
user5293625
I'm excruciatingly bad at this. :(
 
2:24 AM
You already have it setup. This loop will keep on executing until leftroom equals true.
 
user5293625
yeah. Infinitely.
 
user5293625
Wait. Nope.
 
Well not for me. Is there more code that you are not showing me?
 
user5293625
Mine somehow requires like 3 inputs before it works.
 
2:25 AM
What did you type exactly?
There is no need to do that
 
user5293625
"f". No answer. "f" again. Answered. Now "e". No answer. E again 3 times, 3rd gets answered.
 
Did you type f without those quotation marks?
 
user5293625
well, yes.
 
Just making sure because that would actually make a difference.
 
fge
@LuisAverhoff you walk the board several times in different threads; without counting for the fact that in fact the board may have changed behind your last inspection of previous values
 
user5293625
2:28 AM
Yeah. It would.
 
@fge So we agree that there is no problem with isBoardValid correct?
 
fge
It is correct in the single threaded case, yes
Not in a multithreaded case
 
ok good
So lets recap so far
You said that the setvalue is not thread safe correct
and that the isBoardValid method is traversing through cells that were previously changed correct?
@fge These are the main problems we have found so far right?
 
fge
Yes; and in fact the .isBoardValid() is probably your main problem here
 
user5293625
What is going wrong here?
 
user5293625
2:36 AM
Woah. How does this work? Still accepting input from outside the loop. What?
 
@fge So what would be a good way to rectify this problem? Maybe make the setvalue method as a synchronized method.
@fge Then how can we deal with the isBoardValid method?
 
fge
That's the problem, isn't it? One interferes with the other
And you hit Amdahl's law in the worst possible way -- no parallelism will save you currently :p
You need to redesign your algorithm; and I'd start with redesigning the cells in the board
"show me your data, I'll show you the code"
 
user5293625
@Luis, got it going so "f" works fine each time, but why does "e" still require two inputs?
 
@caleb because if you press 'e', it sets it to true but it has not gotten out of the loop so it asks you again.
@fge Well that sucks
@fge I remember you saying that I should make a class for each cell. Am I remembering correctly?
 
user5293625
2:46 AM
How to fix that?
 
@caleb How about you convert the while to a do while
do{......}while(!leftroom)
 
user5293625
Hm.
 
user5293625
Still requires doubled input
 
You probably have a two nextlines. Get rid of the bottom nextline.
Not magic
 
user5293625
Yay magic it works!
 
user5293625
2:51 AM
Thanks fam!
 
user5293625
CW out.
 
You just have to structure your code correctly.
@fge Well looks like I'm screwed because I only have three days to finish this project.
 
fge
3:13 AM
@LuisAverhoff revise your cells first; instead of trying all different values in them, record what values they cannot have
 
@fge Here is the funny part I already have a sudoku algorithm that has that.
 
fge
And then lock rows; then columns and, why not, squares
 
@fge want me to show you?
 
fge
That would be a multipass algorithm of course
 
The other sudoku algorithm that I have works on the principle of the most constrained heursitic.
In other words, instead of trying every single possibility, it only tries ones that might work.
Like if it knows 3 and 4 dont work, it will only try 1 and 2.
That is how my other sudoku algorithm works.
@fge The problem is that I want to use multi-threading on both of them because I want to make a comparison between the single thread version and the multi-threaded version.
@fge In total, I will have 2 single threaded sudoku solvers and 2 multithreaded sudoku solvers.
 
fge
3:21 AM
Well, even with your naive algorithm, you can... But given the way the algorithm work you'd have to synchronize over the whole process
Therefore multithreading buys you nothing
 
@fge That is fine
@fge At least I will have something to present lol.
 
fge
Well, that is a very good illustration of Amdahl's law
 
@fge Exactly you have think positively
@fge So if we have to synchronize, what do we exactly synchronize?
@fge would each method have to be synchronized.
 
fge
Well, your .solveSudoku method, basically :p
You have no choice
 
@fge why? Wouldn't it be that I synchronize isBoardValid and the naiveSolver method?
@fge Actually wouldn't it just be naiveSolver?
 
fge
3:29 AM
Yes, the naiveSolver method, I meant
 
@fge naiveSolver is the one that is doing the insertion while isBoardValid is just reading
 
fge
Yes, but the problem is that your reading method runs while your writing is in progress
You may end up reading a cell at time t which state would change later on, but is being written afterwards
 
@fge So pretty much synchronize isBoardValid and naiveSolver correct?
This is really going to be such a great presentation.
I will be like "hey guys dont use multi threading in a sudoku solver" // End of presentation lol
At least not on this algorithm.
 
fge
Exactly
Hence the importance of why it is important for algorithms to take parallelism into account to begin with :)
That is an excellent example of what not to do, even if you didn't do it on purpose to begin with :p
 
@fge Hey when I first started this project, I thought it had potential.
 
fge
3:37 AM
You didn't pick an easy subject to be honest
 
@fge Well there are some abstract where people have actually created a multithreaded sudoku solver.
@fge One of them were using locks I think
 
fge
You can't do a lockless sudoku solver, to be honest
But depending on the algorithm, your locks will be more or less fine grained
 
@fge So would adding the keyword synchronized to both the naiveSolver and isBoardValid method really work? Because I just did and it still does not solve it.
 
fge
Hmm
 
@fge Should I also synchronized the helper method runNaiveSolver as well?
 
user4196492
3:45 AM
There is a contest coming up on Game Jolt soon and I am trying to determine whether it would be better to develop a game using Java or Javascript. If I do it in Java, it will be a JFrame game. If I do it in Javascript, I will have it in an html file working with a Canvas. What would be a better move for me?
 
@pebble225 I would go with the language that I'm more experienced and comfortable with. So whether if it is java or javascript, which ever one it is would be the better move for you in my opinion.
@fge oops made a Colossal mistake.
 
user4196492
I reached this level with Java and JavaScript where I am able to make 2d graphics, physics, and decent gameplay. I don't know what I would call it.
 
@fge I used synchronized in the wrong class, went to the right class, synchronized them and it still did not work.
 
user4196492
I'll play it safe and stick with Java, I just want to expand my borders.
 
user4196492
The contest starts this friday
 
fge
3:54 AM
@pebble225 progress
 
user4196492
@fge Yea, but I mean this point where I am comfortable enough with the language to make an entertaining game.
 
4:07 AM
morning Java!
can anyone tell me, what is this mark as merged while synchronizing files in repository?
 
@fge Maybe we should use the wait method?
 
fge
No, that won't help
Quite the opposite in fact
 
I was running it through my debugger and it was close to solving it.
@fge I see the problem now.
@fge So once a thread has reach the end of the row, it has finished its task but what if the task was not completely correctly? If it was not done correctly, then other threads would not be able to proceed since the numbers that thread X inserted did not work.
 
4:33 AM
Hello Java
Anyone still in here?
 
@fge It seems to me that the only way to go about it is that each thread will wait until one thread is done. So thread 1 starts, 2 waits for 1, 3 waits for 2 etc.
 
fge
Yep, hence the synchronized I proposed
And you need to synchronize at the class level
Oops :p
 
@fge wait so I need to synchronize the naiveSolver class?
 
fge
Yes, you have no choice
 
@fge not the methods?
 
fge
4:39 AM
When you put synchronized on a method it's no different than synchronizing on the instance of the object where the method is
In your case, unfortunately...
 
@fge so it would look like public class synchronized MultithreadedNaiveSolver{}
@fge correct?
@fge I dont think you can explicitly make a synchronized class by just typing public class synchronized className{}. it is either a method or a synchronized block.
 
5:01 AM
Hey all, I have a question regarding array and linked implementations of List, Stack, and Queue ADT. I understand that array are a contiguous block of memory and linked is many non-contiguous blocks of memory. So my question is is this the main difference between the two regarding List, Stack, and Queue ADT?
 
5:29 AM
@fge I put more hints into my sudoku solver puzzle file and it was able to solve without any problem. The problem is hardly any sudoku game is like that where each cell has only one value. The problem is once a thread is finish, it can not go back and redo its mistake. It does not in advance what values would cause it to back.
 
 
3 hours later…
8:28 AM
morn
 
zjk
9:28 AM
I asked this question hoping someone could walk me through the code snippet. But the question is marked as a dup. Here is the question: stackoverflow.com/questions/37000255/…
 
 
1 hour later…
10:44 AM
please help me my question is there stackoverflow.com/questions/36997510/… someone has already answered the question but there are on going problems read the comments of the answer for greater information on the problem
 
 
3 hours later…
1:25 PM
good morning Java
 
Mornin danger
 
1:59 PM
@ballBreaker How're you doing?
 
eh, doin' alright man - still gotta figure my life out a bit though, but otherwise good haha
how about you?
 
Doing okay- working on a project
And it's behaving oddly
I have a class of objects we'll call "Items"
And each Item has a level-1 sub item
and each level-1 sub item has a level-2 sub item
and each level-2 sub item has an ArrayList of level-3 sub items
I have a window with a text box that shows info from levels 1, 2, and 3
which item is displayed depends on a selection from a JTree
and selecting one node on the JTree
and then another
and then the original
empties the ArrayList of level-3 sub items in the original node
without affecting the data at the other levels
 
2:52 PM
hmm
interesting haha sounds kind of like a headache
 
feels kind of like a headache
 
haha
 
3:41 PM
bye guys
o/
 
@ballBreaker Figured it out!!
I have a function that deletes all the level 3 items
without checking for which items were added and which were already there
I feel stupid for making that mistake, but slightly less stupid for discovering and correcting it
and somewhere between stupid and not stupid for thinking, "I should create a property for these level 3 items that says whether or not they're new." and then not remembering to use that property at the time when it was needed
 
4:15 PM
Afternoon, Java!
 
5:04 PM
Hi, can someone tell me how to do this?
i have a json response from server and it follows this style: {"success":true, "resources":[{"id":1, "resource":"string"},{"id":2, "resource":"string"}]}
i created an APIResponse and it has these variables:
Boolean success, List<Context> resources;
i would like to use Context because then i hope to use this as a main response and inject other model classes as List<Model> for the resource variable
my problem is how i inject this context?
 
5:19 PM
@JanakaRRajapaksha What is Context? And what do you mean inject other model classes? Are those classes children of Context?
 
hi guys
do you know of any open-source full website created with spring?
I would like to have a look at the source code of a real website
especially with SpringBoot
 
no. i want to have the APIResponse class as the main class because json style is common for every call
so i need to inject models into APIResponse when calling
 
@nbro Full website for what?
 
error received is: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 24 path $.object
 
5:37 PM
@JanakaRRajapaksha Because your JSON response is an array. It should be List (object) where as it's array.
"resources":[{"id":1,"category":"YeeNhmNaIH"},{"id":2,"category":"eH7lFMg3y4"},{"id":3,"category":"ZLh04O3W8M"},{"id":4,"category":"2OGHRF33Pq"},{"id":5,"category":"9TCIREDZL3"},{"id":6,"category":"rPQxwIFfE7"},{"id":7,"category":"YncJjTglXe"},{"id":8,"category":"vCV3P2KNGo"},{"id":9,"category":"KhyRwEECR1"},{"id":10,"category":"fPuZPxKqx7"}]
 
yes i have:
@SerializedName("resources")
@Expose
private List<Context> resources = new ArrayList<Context>();
even when i am using:
private List<category> resources = new ArrayList<Category>();
it doesnt work. it passes as an object even when i have a list
@java8.being
 
@JanakaRRajapaksha What is the type of resources in your json?
 
i think it is String. generated in Laravel. sorry if i am wrong
 
@JanakaRRajapaksha It's an array.
Now look at the exception: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 24 path $.object
 
yes, how do i pass it as an Array so that java will look for an array instead of expecting object.
I dont have json file in local
array is the second value of the original object. it's first value is an object("success":true)
i am confused, i am trying this for 2 days :(
 
5:49 PM
    @SerializedName("resources")
    @Expose
    private Context[] resources;
 
oh, let me try it
 
@java8.being as I said, I would like to have a look at the source code. it doesn't matter what the website is about...
 
@java8.being as long as the website is minimally serious
not samples
 
@nbro ^^^
Oh
 
5:53 PM
@java8.being it's so strange the Spring is so famous but there are no websites around
 
@java8.being still the same error :(
 
@JanakaRRajapaksha Weird
 
@java8.being Ok, I must be honest with you
 
Are you sure, you have properly build and deployed your project?
 
5:55 PM
@java8.being yeah, this is the second day, i am too fed up
i rebuild the project too
 
http://www.commitstrip.com/en/2016/05/03/must-have/
CommitStrip
Must-have
CommitStrip
1462298139
 
I don't understand exactly how to secure parts of a website created with Spring(Boot)... I've had a look at Spring Security, but it seems only protects for the whole website. What about if I'm using Spring repositories as ORM? What about when a user has logged to the website and I want to control his access to the various parts of the website?
@java8.being ...All examples of Spring security only show you how to protect access to unlogged users (and they check the credentials not using any ORM), but I would like to control the access also when a user has logged in to the website...\
 
@PreAuthorize ("isAuthenticated() and hasPermission('', '','" +
                   PermissionConstants.IS_PRODUCT + "," +
                   PermissionConstants.IS_PRODUCT_ADD + "')")
Something like this? ^^^
 
00:00 - 18:0018:00 - 20:00

« first day (2019 days earlier)      last day (2924 days later) »