Recent

Author Topic: Help me Please from Turkey  (Read 13574 times)

Bart

  • Hero Member
  • *****
  • Posts: 5677
    • Bart en Mariska's Webstek
Re: Help me Please from Turkey
« Reply #15 on: December 23, 2014, 10:54:14 am »
STOP

We will NOT do your assignment for you (unless you pay obscene amounts of money).
The object of the assignment is that you should actually learn something from it.

I can give you code, but I promise you, your teacher will know that you did not ever write that yourself  >:D

If you do not show us any of your efforts at all, I will ask the moderator of this forum to lock this topic.

Bart

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Help me Please from Turkey
« Reply #16 on: December 23, 2014, 06:33:34 pm »
My solution (without sorting):

Code: [Select]
  LargeValue := Max(FirstValue, SecondValue);
  LargeValue := Max(LargeValue, ThirdValue);

  SmallValue := Min(FirstValue, SecondValue);
  SmallValue := Min(SmallValue, ThirdValue);

  for i := 0 to 2 do
    if (a[i] <> SmallValue) and (a[i] <> LargeValue) then
      IntermediateValue := a[i];
« Last Edit: December 23, 2014, 06:36:25 pm by typo »

stocki

  • Full Member
  • ***
  • Posts: 144
Re: Help me Please from Turkey
« Reply #17 on: December 23, 2014, 06:38:01 pm »
Stupid task! Please close!

kmalpha

  • New Member
  • *
  • Posts: 27
Re: Help me Please from Turkey
« Reply #18 on: December 23, 2014, 06:42:21 pm »
The program was completed
Thanks to everyone :)

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Help me Please from Turkey
« Reply #19 on: December 23, 2014, 08:03:26 pm »
The largest number can be found by starting with the larger digit, followed by the second larger one (intermediate), and terminating with the smallest one.

The smallest number can be found by starting with the smallest digit, followed by the second smaller one (the same intermediate), and terminating with the largest one.

So the intermadiate digit is always the same and you simply switch between the largest and  the smallest ones in order to find LargeNumber and SmallNumber.
« Last Edit: December 24, 2014, 01:39:05 am by typo »

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Help me Please from Turkey
« Reply #20 on: December 24, 2014, 01:39:21 am »
For example, if you have the digits 1,2,3,4,5,6,7,8,9, the largest number will be 987654321 and the smallest one will be 123456789.

No need to sort.
« Last Edit: December 24, 2014, 01:56:39 am by typo »

rvk

  • Hero Member
  • *****
  • Posts: 6944
Re: Help me Please from Turkey
« Reply #21 on: December 24, 2014, 10:01:42 am »
The largest number can be found by starting with the larger digit, followed by the second larger one (intermediate), and terminating with the smallest one.
No need to sort.
Hahaha  :D What do you call "first determining the largest number, then the second largest number etc. etc..." ???
I call that sorting :D

CM630

  • Hero Member
  • *****
  • Posts: 1616
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Help me Please from Turkey
« Reply #22 on: December 24, 2014, 12:57:15 pm »
 Sorting 3 numbers is not a classical sort case, indeed.
Actually if all numbers are a single digit long (or even more than a digit), then one could loop down to find the biggest one, then loop up to find the smallest one. The one which is left is the middle value, since the total number of numbers is 3.

Лазар 4,4 32 bit (sometimes 64 bit); FPC3,2,2

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Help me Please from Turkey
« Reply #23 on: December 24, 2014, 02:11:31 pm »
Hahaha  :D What do you call "first determining the largest number, then the second largest number etc. etc..." ???
I call that sorting :D

No need to use standard computational sorting algorithms (QuickSort, BubbleSort, etc) or, worse, generate all possible numbers to sort.

For instance, for 3 digits (factorial 3, which is 6):

123
132
213
231
312
321
« Last Edit: December 24, 2014, 02:29:46 pm by typo »

wildfire

  • Full Member
  • ***
  • Posts: 110
Re: Help me Please from Turkey
« Reply #24 on: December 24, 2014, 02:32:21 pm »
typo,

I see both your and rvk's point.

rvk, typo used brute force, not an algorithm.

typo, technically you are sorting the figures in order.

Let's just call it a draw  ;)
A halo is a mere circle, when does it end?

Bart

  • Hero Member
  • *****
  • Posts: 5677
    • Bart en Mariska's Webstek
Re: Help me Please from Turkey
« Reply #25 on: December 24, 2014, 05:31:01 pm »
There is even no need to know the highest, middle, lowest digit at all.
You can bruteforce calculate all permutations of the three digits.
Save it if it is either higher than highest so far, or lower than lowest so far.
You end up with 2 3-digit numbers and subtract them. Answer found.

You could even write a lookuptable for any given three inputs.
It'll take some time to write that, but it may be weel worth the effort is this task has to be done trillions of time. Generally lookuptables are faster...

Still, no-one has seen any code from topic-starter, so it may very well be that him saying he finished the program is merely a tactic to see our solutions  >:D >:D

Bart

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Help me Please from Turkey
« Reply #26 on: December 24, 2014, 05:32:49 pm »
Still, no-one has seen any code from topic-starter, so it may very well be that him saying he finished the program is merely a tactic to see our solutions  >:D >:D
Obviously the code was private-messaged to kmalpha.
check out this thread


typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Help me Please from Turkey
« Reply #27 on: December 24, 2014, 09:56:00 pm »
I agree with Leledumbo that people just want to get their homework done and the compromise with the community is very small. So I agree with payment.
« Last Edit: December 24, 2014, 09:58:40 pm by typo »

 

TinyPortal © 2005-2018