Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!

Jiyoung Kim

+ Follow
since Oct 31, 2016
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jiyoung Kim

Mark Spencers wrote:Remove if statement out of second for loop. Before this loop create variable When condition if (key.contains(query)) gives true you have to print key value pair,
make found true and use keyword break to exit loop.

It works correctly.
I set boolean = found as a false outside of second for loop, but it doesn't seem to be used properly.

I just declared new variables for key and value, and checked if the query value equals to it.
It works, so I guess that boolean value is not necessary to use. However, if I set boolean outside of main method with static, it might be used, but I'm not sure if I still need it.
3 years ago
I try to print the result if the value I entered is containing in the HashMap.

For example,
3         <- case
uncle sam <- input
uncle sam <- queries
tom tom

uncle sam=111222 <- output
Not found

The output looks like above.

However, a message, not found, is not printed when I entered the value that is not containing in HashMap.
How can I modify the code?

If I use else statement in the second for statement then the message is printed by the number of loop.
3 years ago
I'm trying to get the biggest number in a string that is contained in numbers and operators randomly.
For example, -123456789 will be (98765432-1), 1234567890 will be (9876543210), 123*456+7 will be (765*432 + 1), and so on.
However, I have no idea how to split the operators and the numbers and find the operation that makes the biggest numbers.

This is a method to find and calculate the number.
And, what I'm trying to do is to make separated between operators and numbers using ArrayList above.
But, is it available to make the operations in this approach? I guess that I need to find the operations in a string without a split.
I know how to organize the numbers from the highest to the lowest in a string like below.

The quetsion is kind of messy, but could you provide some instructions how to approach?


987665432-1 = ?
(765*432)+1 = ?
3 years ago

Campbell Ritchie wrote:Well done Please show us your solution.

Nothing special. Carlos was right.
I missed something to store the value;
I changed to sum = sum.add(temp); and it worked.
3 years ago
I solved it.. Thanks all!
3 years ago
I'm trying to find the sum of digits such a big number like 148148148148.
So, the result should be 52.
I'm using BigInteger to find the number using while loop, but the the result was 0.
I don't have an idea what I'm wrong.

This is the method that I have created. When I try to find the small number, not using BigInteger, it is working.
However, this method is not working properly.

Please let me know how to fix it.
3 years ago
I've tried to add the numbers from the starting point to the end point what I want.

The end point is the pow of 10, so the number will be so huge if I enter the big number.
So, I guessed that I need to use BigInteger to handle it. However, I'm wondering that there is a way to reduce the time to calculate the summation.
Even I entered 9 or 10, the calculation is slow. I researched some documents of BigInteger, but I didn't have an idea how to modify.

Please let me know some better ways to calculate the sum a little bit faster.
3 years ago
I turned on the mock location after I activated in the developer option on my android device.
When developing the application, I have usually seen the people that they allow mock locations for testing purposes.
However in my thought, I don't figure out what the difference between turning it off and turning it on.
As I understood, turning on the mock location, I provide the fake information about the location.
Also, I heard that location information is related to the emulator on the software.
If the emulators are not supported by GPS functions, then mock locations are required to allow it.
Is it right? Please give me the answers.

3 years ago

Piet Souris wrote:@Jiyoung

if sum1 = a + b
and sum2 = a - b,

then sum1 - sum2 = 2b, and therefore even.

Now, if we have S5 = 1 + 2 + 3 + 4 + 5, and we change the sign of one digit in this series, the difference is an even number. So it is impossible to obtain 12 by changing zero or more signs in S5, since the difference 3 is an odd number.

I understood the concept now. The difference between two sum and two difference of the combination of even/odd, even/even, odd/odd, odd/even should be the even.
So, that's the reason why I need to check if the difference between two numbers is even. I got it..

Thanks for your reply.
3 years ago

Campbell Ritchie wrote:Actually, I think that you will find the solution will get easier and easier once you start thinking about triangular numbers

Yes, it's not the algorithm as you said. It's math.
I will try to find the solution based on your replies.
3 years ago

Campbell Ritchie wrote:

Henry Wong wrote:. . . now you have two topics that are discussing the same thing. . . . Henry

In which case we can join the two topics back together.

I'm totally ok with that.
Yes, the topic is the same but I'm confused with the concept.
I don't fully understand why even numbers are only satisfied with this algorithm.
I figured out what if the result value is even or odd, the differences between two numbers should be even to be satisfied with. That is why i asked for the concept of this algorithm to make clear.
3 years ago
I have a question about one algorithm to find the maximum number using + or - at minimal times.
For example, I have a value of 12, then the number counts from 1 to n. 1 2 3 4 5 ... n
The operator can be + or -, but I need to find the number that is satisfied with.

In this case, the operators are something like that. -1+2+3+4+5+6-7 = 12.
This equation is satisfied with 12 and 7 is the maximum number. I think that it doesn't matter whatever operators comes on.
However, I don't understand clearly why the algorithm below is working properly to find the number.

Add the numbers from 1 until its sum is bigger than 12. In other words, 1+2+3+4+5=15
15 is bigger than 12, and get the difference between these two numbers. 15-12=3 3 is odd, so it keeps going.
1+2+3+4+5+6=21 and 21-12=9. 9 is still odd, so add the next number. 1+2+3+4+5+6+7=28 and 28-12=16
16 is even, so calculation is done. So, the result will be 7.

I programmed by following this concept, and I got the answer I want.
So, the algorithm is correct, but I don't have an idea how to know the even number of differences between two numbers will be the answer.

Do I just need to memorize the algorithm approach?? Please give some hints to how to figure it out.
3 years ago

Piet Souris wrote:Well, if you think about it, it is not that hard.

First of all, one needs to know the formula for the sum of 1, 2, 3, ..., N by heart, but we all do, don't we?  

Then if you change the sign of any number in that series, the total sum decreases by an even number (why?).
Lets denote the sum 1 + 2 + ... + n with Sn.

Let's take the outcome of 12 as an example. We know thar S4 = 10, too low, so the next candidate is S5. But that sum is 15, and the difference with 12 is uneven. So S5 is impossible. Next xomes S6, being 21. The difference with 12 is again uneven, so S6 is also out of the question. S7? Well, the delta is 28 - 12 = 16, even and that can be formed by changing the signs of 1 and 7, or 2 and 6, or 3 and 5. Check: 1 - 2 + 3 + 4 + 5 - 6 + 7 = 12. So we have 7.

See the pattern? We only have to derive the general algorithm out of it. What if -12 is given?

Thanks for your answer. I coded by following your instruction, and I got the correct answers. I understood the pattern, but I still don't figure out how to prove clearly like you're saying.
I got that I need to add the numbers until sum is bigger than 12. But, I'm confused why it should be even. The operators don't matter, but I don't have an idea why the even number between two differences is satisfied with this condition.
Please give me some explanations to make me understanding more clearly.
3 years ago
I explained a little bit more what I want to do.

The implementation I want to do is like below.

Enter the number: 12

Then, there is a method for checking the operation.

checkOperations(int number) {
   // something

check from 1 to n to get 12 with the operator, '+' or '-'

So as I mentioned,

-1 + 2 + 3 + 4 + 5 + 6 - 7 = 12

This is a minimum operation to get 12. So the result returns 7 without an operator.

In another example, enter the number, 15. Then,

1 + 2 + 3 + 4 + 5 = 15

This is the minimum operation to get 15, so returns 5.

I tried to find the last number of the operation to get my input number.
I thought that I need to calculate the operation with random operators, but the issue is that the result value is different because of the random operator.
Sometimes, it takes '+' or '-'. So, it can be 7 or 20 and so on.

I'm not sure how to figure out the operator if I don't use random keyword.
3 years ago
I'm trying to find the last number with random operators of '+' or '-'.
The number starts from 1 to n and I cannot enter which operator I need.

For example, the result value is 15 and counts from 1.

1+2+3+4+5 = 15

From 1 to 5, they make 15 when I add all. So, I need to print 5.

However, the operator can be minus, as well.

For example, the result value is 12.

Then, -1+2+3+4+5+6-7 = 12

There are two minuses, but I need to get 7.

I need to implement like above, but I'm confused which algorithm I need.

I tried like this, but the result depends on which numbers are taken. So, I got different numbers everytime.
3 years ago