Liutauras Vilda

Sheriff
+ Follow
since Nov 12, 2014
Merit badge: grant badges
Forum Moderator
Liutauras Vilda currently moderates these forums:
For More
London, United Kingdom
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Liutauras Vilda

Mike Simmons wrote:Well, I wouldn't say it's a CodeRanch post editor problem.  It's user error. :p


Absolutely, that's why I edited my post earlier to acknowledge that. But what I learned, I don't know even how to copy a single method from IDEA and have it well formatted. If you copy method heading with leading spaces, then the whole thing gets shifted to the right, so one or another way, need to do some pre-formatting before putting code into CodeRanch editor.
1 month ago
Copy/Paste result of above

1 month ago

Mike Simmons wrote:Given Bruno's code example


It's a known CodeRanch post editor behaviour, erm... yep.

If you'd go to IntelliJ, copy some method (single method within the class) and paste it to post editor and click view, you'd see that braces get shifted slightly to the right, like Bruno showed, while actually what you copied is indented in a bit more habitual way, i.e. like in screenshot.

[Edit] CodeRanch post editor behaviour. Myself looking to screenshot more, I think it is just the way stuff gets copied within IntelliJ. As seen, method heading gets copied without leading spaces, while the body of the method with leading spaces and this is what you get in the post here...
1 month ago
Sorry, I misread Tim's post. Actually he explained all that already.
1 month ago
This is where the picture probably speaks most. But let me try also to navigate you in textual way.

Settings > Editor > Code Style > Java > Wrapping and Braces (tab) > Braces placement > click on "End of line" and choose "Next line", I think.

But anyway, regardless that a lot of people use one or another way, I'd think (not proven scientifically), a default way is preferred in professional environment.
1 month ago
After over a year's lapse, we decided to re-invent the Journal.  It is now an "editor's picks" format brought to you by the staff of JavaRanch.  Read what your favorite moderators think is hot!

2025
  • todo


  • 2024
  • December 2024 Journal
  • November 2024 Journal
  • May 2024 Journal
  • February 2024 Journal
  • January 2024 Journal


  • 2023
  • January 2023 Journal


  • 2022
  • December 2022 Journal
  • November 2022 Journal
  • October 2022 Journal
  • September 2022 Journal
  • August 2022 Journal
  • May 2022 Journal
  • April 2022 Journal
  • February 2022 Journal
  • January 2022 Journal


  • 2021
  • December 2021 Journal
  • November 2021 Journal
  • August 2021 Journal
  • July 2021 Journal
  • June 2021 Journal
  • May 2021 Journal
  • April 2021 Journal
  • February 2021 Journal
  • January 2021 Journal


  • 2020
  • December 2020 Journal
  • November 2020 Journal
  • October 2020 Journal
  • September 2020 Journal
  • August 2020 Journal
  • July 2020 Journal
  • June 2020 Journal
  • April 2020 Journal
  • March 2020 Journal
  • February 2020 Journal


  • 2019
  • November 2019 Journal
  • October 2019 Journal
  • September 2019 Journal
  • August 2019 Journal
  • July 2019 Journal
  • June 2019 Journal
  • May 2019 Journal
  • April 2019 Journal
  • March 2019 Journal
  • February 2019 Journal
  • January 2019 Journal


  • 2018
  • December 2018 Journal
  • November 2018 Journal
  • October 2018 Journal
  • September 2018 Journal
  • August 2018 Journal
  • July 2018 Journal
  • June 2018 Journal
  • April 2018 Journal
  • March 2018 Journal
  • February 2018 Journal


  • 2017
  • December 2017 Journal
  • November 2017 Journal
  • October 2017 Journal
  • September 2017 Journal
  • August 2017 Journal
  • July 2017 Journal
  • June 2017 Journal
  • May 2017 Journal
  • April 2017 Journal
  • March 2017 Journal
  • February 2017 Journal
  • January 2017 Journal


  • 2016
  • November 2016 Journal
  • October 2016 Journal
  • September 2016 Journal
  • August 2016 Journal
  • July 2016 Journal
  • May 2016 Journal
  • April 2016 Journal
  • March 2016 Journal
  • February 2016 Journal
  • January 2016 Journal


  • 2015
  • October 2015 Journal
  • July 2015 Journal
  • May 2015 Journal
  • April 2015 Journal
  • February 2015 Journal
  • January 2015 Journal


  • 2014
  • December 2014 Journal
  • October 2014 Journal
  • July 2014 Journal
  • June 2014 Journal
  • May 2014 Journal
  • April 2014 Journal
  • March 2014 Journal
  • February 2014 Journal
  • January 2014 Journal


  • 2013
  • December 2013 Journal
  • October 2013 Journal
  • September 2013 Journal
  • August 2013 Journal
  • July 2013 Journal
  • January 2013 Journal


  • 2012
  • September 2012 Journal
  • August 2012 Journal
  • July 2012 Journal
  • June 2012 Journal
  • March 2012 Journal
  • February 2012 Journal
  • January 2012 Journal


  • 2011
  • October 2011 Journal
  • August 2011 Journal
  • July 2011 Journal
  • June 2011 Journal
  • May 2011 Journal
  • April 2011 Journal
  • March 2011 Journal
  • February 2011 Journal
  • January 2011 Journal


  • 2010
  • December 2010 Journal
  • November 2010 Journal
  • October 2010 Journal
  • September 2010 Journal
  • August 2010 Journal
  • July 2010 Journal
  • June 2010 Journal


  • 2009 and earlier Journals
    1 month ago
    T h e . C o d e R a n c h . J o u r n a l
    ----
    December 2024 Edition
    Howdy from all the CodeRanch staff, and welcome to the December edition of the Journal.

    Like every year, Jeanne is working on a Jumpin JForum Day feature that will be announced soon, so don't miss out!

    ...and from all of the CodeRanch staff – Happy New Year!

    Pop by and say hi to us, like an old time rancher did here https://coderanch.com/t/785635/nice-site-active


    I n t e r e s t i n g . C o d e R a n c h . T o p i c s
    ----
    Given that this is the last journal of the year, we’ve chosen interesting topics from throughout the year
  • What is Natural Ordering - https://coderanch.com/t/781280/java/explains-natural-ordering-Java
  • Advantages of Stream#mapMulti - https://coderanch.com/t/779720/java/Advantages-Stream-mapMulti
  • Nicer body for ifPresentOrElse - https://coderanch.com/t/782641/java/nicer-body-ifPresentOrElse
  • There are no Coincidences - https://coderanch.com/t/784317/java/Coincidences


  • B o o k . P r o m o t i o n s . & . W i n n e r s
    ----
    There's a book (or software) promotion just about every week at CodeRanch.
    Just ask a question in the appropriate forum and you're eligible to win a copy of the book.

    We've got some promotions coming up. Check the Book Promotions Schedule.

    Some upcoming ones are:
  • We have a New Year's break with promotions

  • Recent promotions winners:
  • OCP Oracle Certified Professional Java SE 21 Developer Study Guide - Majid Hameed, Raghavendra Desoju, Alex Khvatov, Chirayu Gangadkar

  • More Book Promotions Winners


    C o d e R a n c h . S t a f f
    ----
    Thanks to all staff that volunteer their time and share their knowledge to make this site the friendliest place on the web to learn.  

    A special thanks this month to the following members...
  • Marshals: Campbell Ritchie ::  Tim Cooke :: Liutauras Vilda :: Jeanne Boyarsky :: paul wheaton
  • Sheriffs: Ron McLeod :: Devaka Cooray :: Henry Wong
  • Saloon Keepers: Tim Holloway :: Stephan van Hulst :: Carey Brown :: Tim Moores :: Mikalai Zaikin
  • Bartenders: Frits Walraven


  • T h i s . M o n t h ' s . E d i t o r
    ----
    Liutauras Vilda - a sheriff, who's wandering around here for 10 years now.
    Haven't crafted my 10K posts yet, but getting there, rest assured - I'll let you know when it happens, and then we see if I get off-by-one error.


    C o d e R a n c h . N e i g h b o r s
    ----
    Richsoil - Permaculture articles n stuff by Paul Wheaton
    Permies - Permaculture and homesteading goofballs


    T h e . M o o s e . o n . S o c i a l
    ----
    The CodeRanch announces latest news/developments frequently on our social media outlets. You can find us at:
  • X
  • Facebook


  • S u g g e s t i o n s / F e e d b a c k
    ----
    If you have any feedback on this month's journal then feel free to create a topic in our Ranch Office.


    J o u r n a l . A r c h i v e
    ----
    Our previously published journals you can find here.
    1 month ago
    Also today I spent a bit of time generalising some of the classes that I tend to use over and over again.  Previously I used to start each exercise from 0.

    So at the moment I found the use of such classes on my end:
  • Coordinate - involves x and y axis
  • Direction - directions that may turn clockwise/anti-clockwise
  • Location - involves rows and columns, neighbouring locations (excluding those that are out of boundaries), move to direction
  • Robot - tracks its movement (location, direction), visited locations, tracks its turns, identifies cycles

  • Coordinate and Location may look duplicative, but they are not.
    Resolved part 1, but part 2 looks nasty at this point.

    I may do some other days first and then come back to it. I'd need to rework my part 1 quite a bit to be of any use in part 2.

    Junilu Lacar wrote:Yeah, I was tempted to do it this way, to just brute force the answer out with a couple of nested loops. But then I finally saw that it was two equations, two unknowns and it could be solved without iteration.


    Well, yes, equations I see, they are spelt out in explanation, not exactly with ink on paper, but almost, i.e. for first claw machine a two of those are:
    94x + 22y = 8400
    34x + 67y = 5400

    I'm just working out how to derive at what I need to using them. Will do a bit of reading. I'll have to go to sleep now as tomorrow is an office day, but will continue tomorrow.
    I find my part1 quite fluent too. Will see how it will look after part2, which I don't know how to solve it yet.

    It just doesn't scale of course what the part 2 requires.
    Day13 Part 1 done. There were no surprises.

    I love  Java records succinctness. Really useful in setting up the stage.

    Part 2 is a different story. Need to look for optimisations. Attempted couple of ideas (more of a blind shots), but it didn't get me anywhere.

    Earlier, I wrote:understood how I can solve conceptually, but was struggling to express in code. But now it's done too.


    Now that I thinking, perhaps that's not exactly. Concept was a bit lacking too to cover 1 particular scenario, because it worked on 2 test datasets (interestingly, what I thought more complicated ones), but not the other.
    2 months ago
    Part 1 was almost identical to Day 10 for me, hence solved it on the first attempt and fairly quickly.

    Part 2 was struggling since late night yesterday, understood how I can solve conceptually, but was struggling to express in code. But now it's done too.
    2 months ago
    Day 11 part 2 done.

    Went a bit to an Overthinking Land.

    My initial strategy was to build a map of all recurring stones (during 75 blinks) that map to a list of their derivatives. In the test dataset there were 76 unique keys after 36 blinks that did not increase anymore till 75th blink. So I had a hope there without actually knowing exactly what I'm going to do with them yet, but was thinking along the lines, that will traverse the map like a tree later, going to key, then each of its children (derivatives), back to key, its children again... and as you imagine, that didn't get me anywhere.

    Then had a dinner, took the dog (Beagle) out for a walk, re-read instructions once again, and thought, hang on, instructions say: "No matter how the stones change, their order is preserved...", and thought, what's the story about the order being preserved, that's an unnecessary restriction - that doesn't matter at all! OKEY, that's a typical divide-and-conquer problem from now onwards. So started thinking how to run through subsets of stones 75 blinks each and later just add their counts. Now, don't tell anyone, but one moment was considering to write a Spark job crunching stuff in parallel and persisting intermediate results to a disk so don't occupy memory when don't need to. Then in the case of success of course was thinking, how I'm gonna tell you guys this brain fart

    After thinking more, did no more than what you'd expect a Day 11 actually could bring given we are not even half way through - a simple Map with counts of each stone at a given moment, so it doesn't grow as a list would. FACEPALM

    2 months ago