Open Side Menu Go to the Top
Register
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

09-30-2015 , 04:53 PM
this.

dave, there are lots of legitimate gripes about the js language -- the "concat" method name isn't one of them.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-30-2015 , 06:11 PM
Quote:
Originally Posted by Jeff W
Java Newb Question: How can I render or ignore HTML in my IDE (IntelliJ IDEA)?

I just started Sedgewick's Algorithms course at Coursera and the downloadable .java files have unintelligible comments because they're riddled with HTML tags. Ex: http://algs4.cs.princeton.edu/code/e...ckUnionUF.java
Those are standard JavaDoc comments. Probably easiest if you generate the documentation and browse the rendered JavaDoc HTML? (Idk how well that is supported within IntelliJ though.)

The generated documentation looks like this:
http://docs.oracle.com/javase/8/docs...ng/String.html
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-30-2015 , 07:14 PM
Quote:
Originally Posted by daveT


A wooden table is a tree, actually, but we don't go around carving "me and her 4ever" on every table we see.
char CharArray0[] = "String to Concat To";

char CharArray1[] = "String to Concat With";

char * String = (char *)malloc( sizeof(CharArray0) + sizeof(CharArray1) + 1 );

if (String) {
strcpy( String, CharArray0 );

strcat( String, CharArray1 );
}

Does that work not sure off the top of my head. A string is an array of chars. There isn't really that much difference with an array of integers, array of objects, well an array of anything really.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-30-2015 , 07:52 PM
Quote:
char * String = (char *)malloc( sizeof(CharArray0) + sizeof(CharArray1) + 1 );
char CharArray1[] = "String to Concat With";

does char[] not add the null byte? but strcat does or something?

edit: nm I guess you just assumed the memory there is already \0

Last edited by e i pi; 09-30-2015 at 07:58 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-30-2015 , 08:12 PM
"concatenate" and "join" are synonyms. There is no string-specific connotation to the former.

If it makes logical sense to join something, then it makes sense to concatenate it, and vice-versa.

http://rosettacode.org/wiki/Array_concatenation

Last edited by Wolfram; 09-30-2015 at 08:20 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-30-2015 , 11:45 PM
Re: physical books & searching

The lack of being able to search by typing into a search box is the thing that I miss the most when I read a physical book. I much prefer that than flipping through a book and scanning for landmarks or remembering chapters, etc.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-30-2015 , 11:52 PM
Quote:
Originally Posted by Roonil Wazlib
I'm terribly disappoint with the lack of OOP challenges available online. Hackerrank has like a tiny section for Java OOP principles, and it's all super easy stuff, like inheritance or *gasp* overriding a method and changing one word of the output.

I'm sure you're a bit limited what you can do without the ability to easily make packages with lots of interconnected classes and interfaces, but there's got to be some sort of good challenges online somewhere.

Or maybe that's an area with unmet supply.
from what I've seen so far, small scale computing problems are all pretty much the same. did you go through codingbat yet? Their problem sets are kind of challenging towards the end, especially the string stuff (for me anyway). the logic challenges can be tricky too. I like this one:


We want to make a row of bricks that is goal inches long. We have a number of small bricks (1 inch each) and big bricks (5 inches each). Return true if it is possible to make the goal by choosing from the given bricks. This is a little harder than it looks and can be done without any loops.

Code:
 
public boolean makeBricks(int small, int big, int goal) {
    
}
I gave up on that one a while ago, didn't wanna spoil it by looking up a solution.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-30-2015 , 11:53 PM
Quote:
Originally Posted by Benholio
Re: physical books & searching

The lack of being able to search by typing into a search box is the thing that I miss the most when I read a physical book. I much prefer that than flipping through a book and scanning for landmarks or remembering chapters, etc.
The ideal situation is to have the physical book and the electronic copy. Ebooks are pretty solid for reference purposes, but if you're reading cover to cover, physical books are superior imo.

P.S. Anyone who is reading pdfs on phone/tablet should check out BRISS. BRISS crops the margins of pdfs so they're easier to read on narrow screens.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-01-2015 , 12:26 AM
Quote:
Originally Posted by jmakin
from what I've seen so far, small scale computing problems are all pretty much the same. did you go through codingbat yet? Their problem sets are kind of challenging towards the end, especially the string stuff (for me anyway). the logic challenges can be tricky too. I like this one:


We want to make a row of bricks that is goal inches long. We have a number of small bricks (1 inch each) and big bricks (5 inches each). Return true if it is possible to make the goal by choosing from the given bricks. This is a little harder than it looks and can be done without any loops.

Code:
 
public boolean makeBricks(int small, int big, int goal) {
    
}
I gave up on that one a while ago, didn't wanna spoil it by looking up a solution.
Divide goal by big * 5 and see if the amount of small is greater than or equal to the remainder?

Quote:
Originally Posted by Jeff W
P.S. Anyone who is reading pdfs on phone/tablet should check out BRISS. BRISS crops the margins of pdfs so they're easier to read on narrow screens.
Nice product name.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-01-2015 , 12:35 AM
Quote:
Originally Posted by adios
char CharArray0[] = "String to Concat To";

char CharArray1[] = "String to Concat With";

char * String = (char *)malloc( sizeof(CharArray0) + sizeof(CharArray1) + 1 );

if (String) {
strcpy( String, CharArray0 );

strcat( String, CharArray1 );
}

Does that work not sure off the top of my head. A string is an array of chars. There isn't really that much difference with an array of integers, array of objects, well an array of anything really.
My C is too unused to know if that is good or not. I'll take your word for it.

I get that string is an array to the machine. I don't think I've ever heard concatenate used in the context of arrays a'la higher level languages. I personally think it would be confusing if people said "concatenate 'n' and 'm' to get a new value" when that could mean either array, string, set, tuple, list, or whatever else, but I guess it depends on what language you are talking about. I don't have much room to talk about using strange names for common operations.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-01-2015 , 01:26 AM
dave, like the problem says, not that simple. For instance, say you have 3 large bricks, 1 small brick goal is 11. That will return false because 3 * 5 is 15 mod 11 is 4 which is greater than 1.

But you could simply use 2 bricks and then the small brick to make 11. It's trickier than it looks. I did it recursively once but it was really ugly. basically there's like 3 cases.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-01-2015 , 02:51 AM
Quote:
Originally Posted by jmakin
from what I've seen so far, small scale computing problems are all pretty much the same. did you go through codingbat yet? Their problem sets are kind of challenging towards the end, especially the string stuff (for me anyway). the logic challenges can be tricky too. I like this one:


We want to make a row of bricks that is goal inches long. We have a number of small bricks (1 inch each) and big bricks (5 inches each). Return true if it is possible to make the goal by choosing from the given bricks. This is a little harder than it looks and can be done without any loops.

Code:
 
public boolean makeBricks(int small, int big, int goal) {
    
}
I gave up on that one a while ago, didn't wanna spoil it by looking up a solution.
Spoiler:
Code:
public boolean makeBricks(int small, int big, int goal) {
    return (small >= goal % 5) && (big * 5 + small >= goal);
}


What do I win?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-01-2015 , 06:34 AM
Quote:
Originally Posted by daveT
My C is too unused to know if that is good or not. I'll take your word for it.

I get that string is an array to the machine.
Not just an array on the machine. You are being too literal.

Conceptually, an array is an ordered list of items. A string is an ordered list of characters, and therefore logically a string is an array.

The words "concatenate" and "join" are synonyms. Some languages choose to implement concat exclusively for strings but that is an arbitrary choice by the language designer and not due to the word itself being string-specific. And it is far from universal in programming languages.

Quote:
I don't think I've ever heard concatenate used in the context of arrays a'la higher level languages.
A quick googling will show you many uses of 'concatenate' in a non-string context.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-01-2015 , 07:57 AM
Quote:
Originally Posted by jmakin
from what I've seen so far, small scale computing problems are all pretty much the same. did you go through codingbat yet? Their problem sets are kind of challenging towards the end, especially the string stuff (for me anyway). the logic challenges can be tricky too. I like this one:


We want to make a row of bricks that is goal inches long. We have a number of small bricks (1 inch each) and big bricks (5 inches each). Return true if it is possible to make the goal by choosing from the given bricks. This is a little harder than it looks and can be done without any loops.

Code:
 
public boolean makeBricks(int small, int big, int goal) {
    
}
I gave up on that one a while ago, didn't wanna spoil it by looking up a solution.
Assuming integers for all variables you can set this up as a Diophantine equation and the existence of solutions is easy to solve.

https://en.m.wikipedia.org/wiki/Diophantine_equation

Big length = B
Small length = S
Goal length = G

B*X + S*Y = G

If G is a multiple of the greatest common divisor of B and S then the equation has solutions.

To find the greatest common factor I think Euclid Method on this page should be work:

https://en.m.wikipedia.org/wiki/Greatest_common_divisor

Edit: Oh forgot 1 is a special case and should probably be ignored as a solution as B and S are coprime.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-01-2015 , 08:08 AM
Quote:
Originally Posted by jmakin
dave, like the problem says, not that simple. For instance, say you have 3 large bricks, 1 small brick goal is 11. That will return false because 3 * 5 is 15 mod 11 is 4 which is greater than 1.

But you could simply use 2 bricks and then the small brick to make 11. It's trickier than it looks. I did it recursively once but it was really ugly. basically there's like 3 cases.
If Large = 0 and goal > small false
If goal > large * 5 + small it's false
If goal is greater than small and less than 5 then false (if we a goal of 4 and 3 small blocks it's false)

If goal mod 5 > small false (if we have a goal of 9 and 3 small blocks it's false, assumes >0 large)

I think that covers everything.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-01-2015 , 08:12 AM
See, there's tons of logic, one method solution programming challenges out there. I'm more interested in something that has well-defined classes interacting in a way you might find in the real world.

Maybe that's just something you'll only get by doing projects on your own or something.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-01-2015 , 08:33 AM
Quote:
Originally Posted by just_grindin
Assuming integers for all variables you can set this up as a Diophantine equation and the existence of solutions is easy to solve.

https://en.m.wikipedia.org/wiki/Diophantine_equation

Big length = B
Small length = S
Goal length = G

B*X + S*Y = G

If G is a multiple of the greatest common divisor of B and S then the equation has solutions.

To find the greatest common factor I think Euclid Method on this page should be work:

https://en.m.wikipedia.org/wiki/Greatest_common_divisor

Edit: Oh forgot 1 is a special case and should probably be ignored as a solution as B and S are coprime.
Should have kept reading there is an easier method called the Binary Method that seems better suited.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-01-2015 , 09:01 AM
Quote:
Originally Posted by Roonil Wazlib
See, there's tons of logic, one method solution programming challenges out there. I'm more interested in something that has well-defined classes interacting in a way you might find in the real world.

Maybe that's just something you'll only get by doing projects on your own or something.
Make something that you take for granted in your every day life. Maybe a cash register or a computerized drink dispensing machine, for example. I know you like gaming, so you can make a text based video game store or possibly some WoW character admin that tracks your progress by integrating their API. Here are a couple other ideas: https://github.com/karan/Projects#classes
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-01-2015 , 09:09 AM
i'll have to figure out how to work with APIs in java, don't think i've covered that yet. But the git link looks good. ty fredd!
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-01-2015 , 10:14 AM
Quote:
Originally Posted by jmakin
from what I've seen so far, small scale computing problems are all pretty much the same. did you go through codingbat yet? Their problem sets are kind of challenging towards the end, especially the string stuff (for me anyway). the logic challenges can be tricky too. I like this one:


We want to make a row of bricks that is goal inches long. We have a number of small bricks (1 inch each) and big bricks (5 inches each). Return true if it is possible to make the goal by choosing from the given bricks. This is a little harder than it looks and can be done without any loops.

Code:
 
public boolean makeBricks(int small, int big, int goal) {
    
}
I gave up on that one a while ago, didn't wanna spoil it by looking up a solution.
Haven't tested it, and just thought of it on the way to school, but:
Spoiler:
If big*5 + small >= goal
Return goal%5 - small <= 0
Else
Return false

?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-01-2015 , 10:32 AM
Quote:
Originally Posted by ChrisV
Spoiler:
Code:
public boolean makeBricks(int small, int big, int goal) {
    return (small >= goal % 5) && (big * 5 + small >= goal);
}


What do I win?
a little from me
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-01-2015 , 10:52 AM
Just for the trolz, that should be:

Spoiler:

Code:
public boolean makeBricks(int small, int big, int goal) {
    return (   (small >= goal % 5)
            && (big * 5 + small >= goal));
}
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-01-2015 , 01:05 PM
Lol ^
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-01-2015 , 07:14 PM
Quote:
Originally Posted by jmakin
dave, like the problem says, not that simple. For instance, say you have 3 large bricks, 1 small brick goal is 11. That will return false because 3 * 5 is 15 mod 11 is 4 which is greater than 1.

But you could simply use 2 bricks and then the small brick to make 11. It's trickier than it looks. I did it recursively once but it was really ugly. basically there's like 3 cases.
I don't think it has to be so many cases. You can count down the ones until you get a goal mod 5 = 0 and ones are less than 5, then if the big bricks * 5 >= the the goal, you have a true. It isn't absolutely perfect, but I'd probably just ignore the big regardless if you have big * 5 > the goal or not.

Last edited by daveT; 10-01-2015 at 07:32 PM. Reason: blah blah blah
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-01-2015 , 08:53 PM
Damnit I didn't frame the problem properly. I missed the lengths of the small is 1.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote

      
m