Javarella 1.0: Dealing numbers into three lists. Here are the rules: Javarella receives a list of 20 numbers. You need to check which of them is divisible by 3, which by 2, and which are divisible by neither. Then the program needs to save them to separate lists. Numbers divisible by both 3 and 2 (for example 6) go into both lists. Let's dive in!
You must be signed in to leave a comment
Usman Full Stack Developer at QA
5 July 2021, 16:31
really good task, past secod time
20 November 2020, 04:50
TBH, the hard questions are only "hard" because the website can't handle solutions other than their default ones As long as my code runs and result meet their described requirement, i don't even care if they turn out with a big red "didn't meet condition" any more, a waste of time
24 November 2020, 14:10
Consider it as an extra challenge for yourself. As long as you can implement more than only one solution, it's good for you, isn't it?
16 February 2021, 19:52
I hope you don't bring that attitude to your professional career. "I don't care if its not what you asked for, as long as it works"
29 May 2021, 12:35
The point is that they often *fail* to state requirements that are nevertheless checked by the test code (e.g. that you have to declare and initialise an array with new int instead of allowing it to be the result of new int[<some expression>] or even Arrays.copyOfRange()). A secondary point is that some supplementary requirements are simply stupid and force the writing of inefficient, inelegant, needlessly bloated code instead of allowing us to solve the problem at hand in the simplest, clearest and most elegant way possible. The focus should be on the problem and its solution, not the creation and filling of completely superfluous intermediate structures (arrays etc.).
29 May 2021, 15:17
@Darth Most the tasks are very clearly explained, the problem is people already know how to solve it before they even read the actual requirements. Believe it or not, when you are employed your employer will care not if you know more "elegant" ways to program. They are not going to change their source code, potentially costing them millions, just to satisfy you. It is actually quite the opposite, they will require you to write it the way they want with the libraries that they specify. If you decide that you can do it better then you wont be doing it better for that company. Anyways, I hope your attitude changes if you plan on doing this professionally.
29 May 2021, 19:12
@Guadalupe: the majority of tasks are explained well enough, if you develop a knack for reading between the lines - i.e. inferring the unstated requirements from particular word choices combined with the context. However, there are enough tasks with uninferrable unstated requirements that I get a few of them every day, and they tend to be extremely frustrating. I've started to post caveat notes to give those who come after us a chance to avoid that frustration. As regards my professional plans: I do not plan to do this professionally for much longer. After almost four decades in the business, I have no more than a decade left until retirement. The fact that I'm new to Java doesn't mean I'm new to the business - it simply means that I have been very lucky so far. But that luck has run out, and so here I am. The task texter and test coders are not the equivalent of the client or the client's business experts, they are the equivalent of the client's tech people. And those I will call to task (pun intended) early and hard if they mess up, in order to limit the ramifications of their mistakes. As regards your disdain of striving for elegance: the art of professional programming consists mainly of writing simple code that is clear and to the point. When learning a new language one must always strive to find the way in which that language lends itself to writing simple, clean and clear code. Every language has different strengths and weaknesses, so we have to find myriads of little ways of leaning on the former while avoiding the latter. Writing clean, clear and simple code that is self-explanatory is a skill that takes a long to develop, especially in the first couple of languages. But in any language it requires to strive for excellence 100% of the time, beginning with the exercises we do here. Excellent code tends to look simple and boring, and most people would think 'easy, I could have done that'. 99% of those people are mistaken in that regard.
1 June 2021, 14:08
Here is a little programming humor: I won't lie and say it was a breeze for me moving through this course, I personally failed many tasks the first time (and more) I tried them. It was very frustrating at times, but, there were only 2 tasks I wasn't able to complete and had to get an answer for. I did go back and finally write some really great code that passes one of those. I have suggested to Codegym staff that a way to improve this site is to add multiple example inputs with the correct outputs for every single task, maybe a minimum of 5. I use codesignal.com, which is just a site with 1000's of tasks for challenge, not a learning site. Many of those tasks are just as confusingly explained, it really is just hard to describe programming tasks, however I can infer the meaning from the examples.
11 November 2021, 23:13
I agree. I was stuck on this one for a while. I then changed the order of how I initialize the lists and then it passed verification. I will read it more carfully next time :D
24 September 2020, 18:49
Make sure you read description carefully and understand what needs to be done. Last Arraylist stores values NOT divisible by 2 and 3 1. Declare 4 empty Arraylist<Integer> (Sequence: main, x%3 , x%2 , none) 2. Read in numbers using for loop and add to first (main) list 3. As mentioned by somebody, same loop can be used to add 'int' to corresponding list, ( sequence: x%3 , x%2 , none) 4. Use printList to display lists. (sequence: x%3 , x%2 , none) (each number on new line)
12 September 2020, 22:24
Eurgh. Stuck on using the printList method thing which is irritating because it's totally pointless when you can just use (nameofarray).forEach(System.out::println)
31 July 2020, 20:44
That feel when your code doesn't give any output, you look over it again and again for an hour until you see that you writtenhaha T.T Still nailed it on first verification thou ;)
7 July 2020, 13:05
The printList method should display each element of the passed list on a new line. The above states that , you will have to display individual element from the list in a different line. for eg [1, 2, 3 ,4 ,5 ] is the array stored . expected answer 1 2 3 4 5 hope this helps
31 May 2020, 02:09
This exercise is okay. It wasn't that hard so long as you built on top of your learning with the lesser exercises. Personally, I would have preferred we had to additionally remove the numbers from the main list and then add them to the new list. This would have made for an extra challenge. But then again, it could still be solved if you figured out the previous exercises.
30 March 2020, 15:15
The printList method instruction is seriously ambiguous. However, I think this kind of carelessly crafted and poorly written instruction is valueable because it teach us how to deal with awful and meaningless real life software specifications.
21 January 2020, 21:18
I should have read the instructions better "The order in which the lists are declared is very important."
18 November 2019, 05:52
If you are certain your code is correct, but it still won't pass testing for adding to the correct lists, ensure you have EXACTLY the order they have mentioned above. I had to reorganize my ArrayList declarations, my foreach loop that tested and assigned number locations, and my print statement order and it passed. Even if it has no bearing on the outcome of your testing, ensure you have the correct order.