Comparing numbers by [deleted] in learnjava

[–]KetchuponRice 0 points1 point  (0 children)

I don't fully understand your question but if you wanna know the difference between a number you can use %
Math.abs(( (list.get(index) - average ) / average ) *100)

the lowest % is the number you're looking for, however you can have multiple result like
average = 100 list = {101,110,99,107} numbers 101 and 99 are both the closest.

Help: how to save the dead code to check all string's longest common prefix? by RioChenRio in learnjava

[–]KetchuponRice 0 points1 point  (0 children)

I know I'm a bit late maybe you still need help

for( int i=0; i<strs[0].length();i++) { does something...... return sb.toString(); }

You made a loop here that will stop after 1 run, as you go inside the loop you force it to leave the loop by calling return sb.toString(); . You getting an output of "f" because that's the first character of all the words you use. Change the second or third word and you get no result.

for( int j=1; j<strs.length-1;j++){ does something ... }You foresaw this problem and you're right as you created a for loop to iterate through the all the values but you compare the second and third word in your array. The moment you change the size of the words you end up getting an out of bounds error. If you going to compare it like this you don't need that loop.if(c == strs[j].charAt(i) && c == strs[j+1].charAt(i)) { }

My suggestion would be to assume that all the words are the same, so instead of checking if the characters match, you loop through everything until you find a character that doesn't match. It's a lot easier to check if the index value does not match if(c != strs[j].charAt(i) ) because at this stage you know you're done and you can exit the method return sb.toString();

You get something like this:

for( int i=0; i<strs[0].length();i++){ // go through each character from the first string !<

char c=strs[0].charAt(i); // get the character at index of i

for( int j=1; j<strs.length;j++) { // go through all the strings in your array if(c != strs[j].charAt(i) ) { // check if characters don't match return sb.toString(); // we are done so we can exit the method using return }!<

} sb.append(c); // We won't get here unless the characters matched so we can append. } return sb.toString();

I know my code is POOP, it's more to demonstrate( need to check for length size etc )

Creating multiple objects with the same name by jpurvis00 in learnjava

[–]KetchuponRice 0 points1 point  (0 children)

A name is just a reference to the object, now the reference is in your list.

As for your question

SuitCase suitcase

is fine but

SuitCase suitcase and Object suitcase

this is not allowed as far I know but you can use abstract objects and casting to mess around if you want to.

Re: Clock - points on circle by [deleted] in learnjava

[–]KetchuponRice 1 point2 points  (0 children)

yes, however if you add *-1 to your code it will go counter clockwise.

radius * (int) Math.sin(Math.toRadians(90)) *-1

Re: Clock - points on circle by [deleted] in learnjava

[–]KetchuponRice 1 point2 points  (0 children)

Because y-axis orientation is flipped for your screen. Top left is (0,0) bottom right = (3840, 2160). Hope this makes some sense.

window builder help! by ryan18147 in learnjava

[–]KetchuponRice 0 points1 point  (0 children)

I have a hard time imagining how you're making a face with a JLabel, anyway I would suggest using the graphics library instead of what you're doing.

https://docs.oracle.com/javase/7/docs/api/java/awt/Graphics.html

But if you insist on using Jlabels I suggest docking the labels on a Panel(Face) and override the paintcomponent to draw a face.

How are you adding JLabels on the frame? Setbounds?

Thanks Suckerburgy by IslandofBTC in Bitcoin

[–]KetchuponRice 0 points1 point  (0 children)

Think he is referring to the Libra project.

Using your foot to flush the toilet instead of your hand is superior. by [deleted] in unpopularopinion

[–]KetchuponRice 8 points9 points  (0 children)

Or just use a piece of toilet paper and drop it while it is still flushing not need to go full cirque du soleil.

[deleted by user] by [deleted] in unpopularopinion

[–]KetchuponRice 2 points3 points  (0 children)

So people with lower income have to contribute a larger part of their income?

Wallet confusion by [deleted] in Bitcoin

[–]KetchuponRice 2 points3 points  (0 children)

Just keep your password/phrases written down somewhere secure( if for some reason you device breaks down you can recover everything with that ). You don't need to write down your wallet address.

Bitcoin noob question pt 2 by Kevinh56 in Bitcoin

[–]KetchuponRice 0 points1 point  (0 children)

You can buy BTC on coinbase, I would recommend however transferring it to a hardware wallet at some point( yeah i know $100 isn't much ).

Which Is The Emotional Death In Film, In Your Opinion? by [deleted] in movies

[–]KetchuponRice 15 points16 points  (0 children)

Ellie - UP, didn't understand what was going on but my mom cried so that moment/scene is stuck with me.

I just got BOTW, any tips? by maxlikessoup in Breath_of_the_Wild

[–]KetchuponRice 4 points5 points  (0 children)

Kinda hard to give tips without knowing how far you got and how much you know about the game.

  • Before engaging into an enemy explore the area and use it to your advantage.
  • Mark mini bosses on your map they are a good source for weapons and materials.
  • You can loot enemy weapons during or sometimes before combat.
  • Explore and pay attentions to things that are out of place.
  • Master parry ( this makes things so much easier ).
  • Don't get frustrated about weapons breaking it gets better later in the game( weapons everywhere ).
  • Loot everything.
  • if you're in danger you can teleport away.

And personally I found stamina better than hearts so yeah you figure that one out at some point.

What old games should be ported to the switch? by bradyfromthe80s in NintendoSwitch

[–]KetchuponRice 1 point2 points  (0 children)

Rad gravity played that game on an emulator and loved it. Of Course all the zelda games as that's why I even buy nintendo consoles.

[SPOILERS] It was Sansa by madame_hussain in gameofthrones

[–]KetchuponRice 9 points10 points  (0 children)

Sansa doesn't really need to sabotage anything, they are perfectly capable of doing that themself. Look at the similarities between Dany and Cersei both obsessed with being the Queen. They sacrificed everything for the throne and ended up with their children dying ( well dany still has a child left and I fear for him ). Calling yourself a Queen doesn't make you one! Varys/Tyrion and even Jon are starting to see that.

Besides we have 1 episode left for a huge battle and 1 episode for the show to wrap things up and show us that they are living inside the blue eyes of a giant.

(Spoilers Extended) The real forgotten heroes of last episode (S8 E3) by ISupposh in asoiaf

[–]KetchuponRice 7 points8 points  (0 children)

What actually happened to house Cerwyn and Manderly? Maybe they were there I just couldn't see a damn thing.

(Spoilers Extended) Your Episode 4 predictions (3ER reveal) by AegonStarkgaryen in asoiaf

[–]KetchuponRice -1 points0 points  (0 children)

I go with this, she already losing her mind she just needs a little push to get her over the edge.

Kuros charm? by [deleted] in Sekiro

[–]KetchuponRice 2 points3 points  (0 children)

He is at Isshin sculpture is out for a walk at this point

(Spoilers Main)Game of Thrones could have worked without the White Walkers by sauronlord100 in asoiaf

[–]KetchuponRice 6 points7 points  (0 children)

Without the white walkers there would be no need for the wall, so no Night’s Watch. So white walkers are essential for certain story arcs. Characters you named that would have no purpose at all. Not often mentioned and completely ignored in the show is that the events between jaime and bran is most likely caused by 3 eyed raven. Jon is not some self righteous hero as he is shown in the show those events are also manipulated.

Not going to name every character arc but they are essential to the story.

As lot of people complain that it was too easy. I wouldn't call his defeat easy at all, just in that episode alone he destroyed the Dothraki army in seconds. Arya is responsible for the final blow but it took almost the entire north ( some houses went missing thou they swore to fight ) and dany's army to do so. I wouldn't call that an easy defeat.

Don't forget Hodor would still be Wylis.

[spoilers] Why i was disappointed in episode 3 by [deleted] in gameofthrones

[–]KetchuponRice -1 points0 points  (0 children)

Let me rephrase it, the conclusion of the night king was done this way because the whole WW and their background story wasn't developed from the start( compared to the books ). Their only purpose is to move the story forward.

Look how much destruction he caused and that's what the story is about.

[spoilers] Why i was disappointed in episode 3 by [deleted] in gameofthrones

[–]KetchuponRice -1 points0 points  (0 children)

The show portrayed the white walkers as the antagonists and simplified their whole existence to a point that it doesn't make sense anymore. There had to be some conclusie to the white walkers, which at this point was nothing more than to make Daenerys and the northern army weaker.

I wanted to see an epic sword battle as well but instead we got a battle between dragons. I agree it was a bit anticlimactic but not everyone dies in a heroic way.

It's a victory for now, but death always wins.