Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > sci.math > #501582 > unrolled thread
| Started by | Graham Cooper <grahamcooper7@gmail.com> |
|---|---|
| First post | 2020-10-12 05:26 -0700 |
| Last post | 2020-10-12 14:33 -0700 |
| Articles | 12 on this page of 52 — 8 participants |
Back to article view | Back to sci.math
$500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! Graham Cooper <grahamcooper7@gmail.com> - 2020-10-12 05:26 -0700
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! Basil Jet <basil@spamspamspam.com> - 2020-10-12 14:50 +0100
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! Graham Cooper <grahamcooper7@gmail.com> - 2020-10-12 12:07 -0700
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2020-10-12 15:30 -0700
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2020-10-12 15:31 -0700
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! Graham Cooper <grahamcooper7@gmail.com> - 2020-10-12 15:41 -0700
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2020-10-12 16:22 -0700
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! Graham Cooper <grahamcooper7@gmail.com> - 2020-10-12 16:27 -0700
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2020-10-12 16:36 -0700
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2020-10-12 16:37 -0700
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! Graham Cooper <grahamcooper7@gmail.com> - 2020-10-12 16:46 -0700
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2020-10-12 17:49 -0700
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2020-10-12 17:50 -0700
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2020-10-12 17:52 -0700
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2020-10-12 17:53 -0700
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2020-10-12 18:02 -0700
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2020-10-12 18:05 -0700
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! Sergio <invalid@invalid.com> - 2020-10-12 20:05 -0500
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2020-10-12 18:20 -0700
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! Graham Cooper <grahamcooper7@gmail.com> - 2020-10-12 18:22 -0700
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2020-10-12 18:24 -0700
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2020-10-12 18:29 -0700
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2020-10-12 18:49 -0700
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! Sergio <invalid@invalid.com> - 2020-10-12 22:50 -0500
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2020-10-12 21:25 -0700
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2020-10-12 16:26 -0700
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! Graham Cooper <grahamcooper7@gmail.com> - 2020-10-12 16:38 -0700
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! Peter <peterxpercival@hotmail.com> - 2020-10-13 01:47 +0100
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-10-12 21:01 +0100
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! Graham Cooper <grahamcooper7@gmail.com> - 2020-10-12 13:12 -0700
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! Basil Jet <basil@spamspamspam.com> - 2020-10-12 21:24 +0100
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! Peter <peterxpercival@hotmail.com> - 2020-10-12 21:48 +0100
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! Graham Cooper <grahamcooper7@gmail.com> - 2020-10-12 13:57 -0700
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-10-12 22:49 +0100
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! Sergio <invalid@invalid.com> - 2020-10-12 15:25 -0500
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-10-12 22:30 +0100
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! Basil Jet <basil@spamspamspam.com> - 2020-10-12 22:42 +0100
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-10-12 23:08 +0100
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! Dario Alpern <darioalpern@gmail.com> - 2020-10-12 15:23 -0700
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-10-13 00:06 +0100
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! Graham Cooper <grahamcooper7@gmail.com> - 2020-10-12 16:25 -0700
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-10-13 01:24 +0100
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2020-10-12 17:54 -0700
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! Dario Alpern <darioalpern@gmail.com> - 2020-10-12 17:29 -0700
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! Basil Jet <basil@spamspamspam.com> - 2020-10-12 23:42 +0100
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-10-13 00:04 +0100
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! Basil Jet <basil@spamspamspam.com> - 2020-10-13 00:33 +0100
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! Graham Cooper <grahamcooper7@gmail.com> - 2020-10-12 16:40 -0700
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-10-13 01:06 +0100
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-10-13 01:26 +0100
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! Archimedes Plutonium <plutonium.archimedes@gmail.com> - 2020-10-12 13:58 -0700
Re: $500 MATHS CHALLENGE ..... just solve this TOWERS OF HANOI ! Dario Alpern <darioalpern@gmail.com> - 2020-10-12 14:33 -0700
Page 3 of 3 — ← Prev page 1 2 [3]
| From | Graham Cooper <grahamcooper7@gmail.com> |
|---|---|
| Date | 2020-10-12 16:25 -0700 |
| Message-ID | <0c16e58e-51e2-4247-9977-3c6b7e889ba5n@googlegroups.com> |
| In reply to | #501638 |
On Tuesday, October 13, 2020 at 9:06:11 AM UTC+10, Ben Bacarisse wrote: > Dario Alpern <dario...@gmail.com> writes: > > > Mi solution is not optimal in number of moves, but its description is > > very short and can be used for any arrangement of disks. > Yes, I think it's the same as mine. Sounds like it from the description > you gave. > Congrats to the Winner! You've sent $500.00 USD to BENJAMIN BACARISSE
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2020-10-13 01:24 +0100 |
| Message-ID | <87a6wr55xw.fsf@bsb.me.uk> |
| In reply to | #501641 |
Graham Cooper <grahamcooper7@gmail.com> writes: > On Tuesday, October 13, 2020 at 9:06:11 AM UTC+10, Ben Bacarisse wrote: >> Dario Alpern <dario...@gmail.com> writes: >> >> > Mi solution is not optimal in number of moves, but its description is >> > very short and can be used for any arrangement of disks. >> Yes, I think it's the same as mine. Sounds like it from the description >> you gave. >> > > Congrats to the Winner! > > You've sent $500.00 USD to BENJAMIN BACARISSE Thanks. You did indeed send me the money. It does not feel like I earned it. I think I'll have to donate it to a charity. -- Ben.
[toc] | [prev] | [next] | [standalone]
| From | "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> |
|---|---|
| Date | 2020-10-12 17:54 -0700 |
| Message-ID | <rm2tsc$1let$5@gioia.aioe.org> |
| In reply to | #501652 |
On 10/12/2020 5:24 PM, Ben Bacarisse wrote: > Graham Cooper <grahamcooper7@gmail.com> writes: > >> On Tuesday, October 13, 2020 at 9:06:11 AM UTC+10, Ben Bacarisse wrote: >>> Dario Alpern <dario...@gmail.com> writes: >>> >>>> Mi solution is not optimal in number of moves, but its description is >>>> very short and can be used for any arrangement of disks. >>> Yes, I think it's the same as mine. Sounds like it from the description >>> you gave. >>> >> >> Congrats to the Winner! >> >> You've sent $500.00 USD to BENJAMIN BACARISSE > > Thanks. You did indeed send me the money. It does not feel like I > earned it. I think I'll have to donate it to a charity. > REALLY!?
[toc] | [prev] | [next] | [standalone]
| From | Dario Alpern <darioalpern@gmail.com> |
|---|---|
| Date | 2020-10-12 17:29 -0700 |
| Message-ID | <991db1e5-34b5-446e-9bb9-96f30c03521fn@googlegroups.com> |
| In reply to | #501641 |
On Monday, October 12, 2020 at 8:25:16 PM UTC-3, Graham Cooper wrote: > On Tuesday, October 13, 2020 at 9:06:11 AM UTC+10, Ben Bacarisse wrote: > > Dario Alpern <dario...@gmail.com> writes: > > > > > Mi solution is not optimal in number of moves, but its description is > > > very short and can be used for any arrangement of disks. > > Yes, I think it's the same as mine. Sounds like it from the description > > you gave. > > > Congrats to the Winner! > > You've sent $500.00 USD to BENJAMIN BACARISSE Graham, What can be learned of this thread, is that it is better to think about the problem instead of trying to attack it using brute force. Given the information about Tower of Hanoi in Wikipedia, it is trivial to adapt the solution to the original problem to the one you posed. Best regards, Dario Alpern
[toc] | [prev] | [next] | [standalone]
| From | Basil Jet <basil@spamspamspam.com> |
|---|---|
| Date | 2020-10-12 23:42 +0100 |
| Message-ID | <rm2m4r$g20$1@dont-email.me> |
| In reply to | #501628 |
On 12/10/2020 23:08, Ben Bacarisse wrote: > Basil Jet <basil@spamspamspam.com> writes: > >> On 12/10/2020 22:30, Ben Bacarisse wrote: >>> Graham Cooper <grahamcooper7@gmail.com> writes: >>> >>>> On Tuesday, October 13, 2020 at 6:01:34 AM UTC+10, Ben Bacarisse wrote: >>>>> Graham Cooper <graham...@gmail.com> writes: >>>>> >>>>>> The TOWERS OF HANOI algorithm starts from a FULL STACK and 2 empty stacks. >>>>>> >>>>>> Can you solve a game that someone has already started? >>>>>> >>>>>> STACK1 20 18 15 12 11 9 5 4 2 >>>>>> STACK2 17 14 13 10 3 >>>>>> STACK3 19 16 8 7 6 1 >>>>> Since I've told you I have an algorithm for this (and it's not a hard >>>>> one to come up with) you are presumably just blowing hot air. >>>> >>>> >>>> you cant win $500 for saying "I CAN DO IT" >>>> >>>> >>>> Lets see your solution! >>> >>> http://bsb.me.uk/tmp/toh.txt >>> >>> It's only just over 2 million moves, and you can check them by computer >>> of course. (To keep the size down, each move is just two letters -- the >>> source and destination pin using A, B and C for the pins.) >>> >> >> Your first two moves are CA AC. Clearly that has no effect. > > That does not stop it being a solution though! The code generates > redundant moves because I was going for the simplest code. > > I look forward to seeing your solution. I'll be upset if it is as > simple as mine since, it clearly generates shorter solutions. There is a 4 line function that moves a disc and prints it, and a 12 line recursive function which does nothing but call itself, call the other function and perform various "if.. else" statements. -- Basil Jet recently enjoyed listening to Care - Diamonds And Emeralds
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2020-10-13 00:04 +0100 |
| Message-ID | <87d01n6o7o.fsf@bsb.me.uk> |
| In reply to | #501635 |
Basil Jet <basil@spamspamspam.com> writes: > On 12/10/2020 23:08, Ben Bacarisse wrote: <cut> >> I look forward to seeing your solution. I'll be upset if it is as >> simple as mine since, it clearly generates shorter solutions. > > There is a 4 line function that moves a disc and prints it, and a 12 > line recursive function which does nothing but call itself, call the > other function and perform various "if.. else" statements. Sounds very neat. I look forward to seeing it. Mine does not actually move anything. All it does is print the moves required. -- Ben.
[toc] | [prev] | [next] | [standalone]
| From | Basil Jet <basil@spamspamspam.com> |
|---|---|
| Date | 2020-10-13 00:33 +0100 |
| Message-ID | <rm2p3q$vso$1@dont-email.me> |
| In reply to | #501637 |
On 13/10/2020 00:04, Ben Bacarisse wrote:
> Basil Jet <basil@spamspamspam.com> writes:
>
>> On 12/10/2020 23:08, Ben Bacarisse wrote:
> <cut>
>>> I look forward to seeing your solution. I'll be upset if it is as
>>> simple as mine since, it clearly generates shorter solutions.
>>
>> There is a 4 line function that moves a disc and prints it, and a 12
>> line recursive function which does nothing but call itself, call the
>> other function and perform various "if.. else" statements.
>
> Sounds very neat. I look forward to seeing it. Mine does not actually
> move anything. All it does is print the moves required.
>
It's in Swift, but there's nothing non-standard in it, apart form the
explanation marks and underscores, which can be ignored. The towers are
numbered from 0 to 2, instead of 1 to 3.
//solve partial Tower Of Hanoi.
var towers = [[20, 18, 15, 12, 11, 9, 5, 4, 2],
[17, 14, 13, 10, 3],
[19, 16, 8, 7, 6, 1]]
var moveCount = 0
func moveOne( _ source:Int, _ target:Int)
{
let mover = towers[source].removeLast()
//debug test
if towers[target].count > 0 && mover >= towers[target].last!
{
print("panic")
}
towers[target].append(mover)
moveCount += 1
print (" \(mover) from \(source) to \(target) : count = \(moveCount)")
}
func recursively(_ base:Int, _ source:Int, _ target:Int)
{
if base == 1
{
if source != target
{
moveOne(source, target)
}
return
}
let childTower = towers[1].contains(base - 1) ? 1 :
(towers[2].contains(base - 1) ? 2 : 0)
if source == target
{
recursively(base - 1, childTower, target)
}
else
{
let intermediateTower = 3 - (source + target)
recursively(base - 1, childTower, intermediateTower)
moveOne(source, target)
recursively(base - 1, intermediateTower, target)
}
}
recursively(20, 0, 2)
--
Basil Jet recently enjoyed listening to
Care - Diamonds And Emeralds
[toc] | [prev] | [next] | [standalone]
| From | Graham Cooper <grahamcooper7@gmail.com> |
|---|---|
| Date | 2020-10-12 16:40 -0700 |
| Message-ID | <a55201d4-9e07-49af-9622-600d9e378aa5n@googlegroups.com> |
| In reply to | #501644 |
On Tuesday, October 13, 2020 at 9:33:25 AM UTC+10, Basil Jet wrote:
> On 13/10/2020 00:04, Ben Bacarisse wrote:
> > Basil Jet <ba...@spamspamspam.com> writes:
> >
> >> On 12/10/2020 23:08, Ben Bacarisse wrote:
> > <cut>
> >>> I look forward to seeing your solution. I'll be upset if it is as
> >>> simple as mine since, it clearly generates shorter solutions.
> >>
> >> There is a 4 line function that moves a disc and prints it, and a 12
> >> line recursive function which does nothing but call itself, call the
> >> other function and perform various "if.. else" statements.
> >
> > Sounds very neat. I look forward to seeing it. Mine does not actually
> > move anything. All it does is print the moves required.
> >
> It's in Swift, but there's nothing non-standard in it, apart form the
> explanation marks and underscores, which can be ignored. The towers are
> numbered from 0 to 2, instead of 1 to 3.
>
> //solve partial Tower Of Hanoi.
> var towers = [[20, 18, 15, 12, 11, 9, 5, 4, 2],
> [17, 14, 13, 10, 3],
> [19, 16, 8, 7, 6, 1]]
>
> var moveCount = 0
>
> func moveOne( _ source:Int, _ target:Int)
> {
> let mover = towers[source].removeLast()
>
> //debug test
> if towers[target].count > 0 && mover >= towers[target].last!
> {
> print("panic")
> }
>
> towers[target].append(mover)
> moveCount += 1
> print (" \(mover) from \(source) to \(target) : count = \(moveCount)")
> }
>
> func recursively(_ base:Int, _ source:Int, _ target:Int)
> {
> if base == 1
> {
> if source != target
> {
> moveOne(source, target)
> }
> return
> }
>
> let childTower = towers[1].contains(base - 1) ? 1 :
> (towers[2].contains(base - 1) ? 2 : 0)
>
> if source == target
> {
> recursively(base - 1, childTower, target)
> }
> else
> {
> let intermediateTower = 3 - (source + target)
> recursively(base - 1, childTower, intermediateTower)
> moveOne(source, target)
> recursively(base - 1, intermediateTower, target)
> }
> }
>
>
>
>
> recursively(20, 0, 2)
I used my own SCRIPT LANGUAGE ... no way it would handle 1,000,000 calls though
hanoi 4 1 2 3 ......... [?]
0 4 3 2 1
0
0
move 4 disks from 1 to 2
move 3 disks from 1 to 3
move 2 disks from 1 to 2
move 1 disks from 1 to 3
0 4 3 2
0
0 1
--------------------- miniBASE CODE (similar to PROLOG ) ------------------
haninit
-remove stack
-assert stack 1 0
-assert stack 1 4
-assert stack 1 3
-assert stack 1 2
-assert stack 1 1
-assert stack 2 0
-assert stack 3 0
hantop1 N
-let M 0
-hantop2 N
-global M
hantop2 N
-stack N K
-let M K
-clear K
-next
-hantop2 N
hanprnt
-hanstak 1
-echo newline
-hanstak 2
-echo newline
-hanstak 3
hanstak J
-stack J K
-print K
-clear K
-next
-hanstak J
hanoi1 D A B C
-echo move
-print D
-echo disks from
-print A
-echo to
-print B
-echo newline
-echo newline
-if
-eq D 1
-move1 A B
-hanprnt
-echo newline
-echo newline
-endif
-if
-bigger D 1
-sub NN D 1
-hanoi1 NN A C B
-sub NNN D 2
-hanoi1 NNN C B A
-endif
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2020-10-13 01:06 +0100 |
| Message-ID | <87ft6j56ql.fsf@bsb.me.uk> |
| In reply to | #501644 |
Basil Jet <basil@spamspamspam.com> writes:
> On 13/10/2020 00:04, Ben Bacarisse wrote:
>> Basil Jet <basil@spamspamspam.com> writes:
>>
>>> On 12/10/2020 23:08, Ben Bacarisse wrote:
>> <cut>
>>>> I look forward to seeing your solution. I'll be upset if it is as
>>>> simple as mine since, it clearly generates shorter solutions.
>>>
>>> There is a 4 line function that moves a disc and prints it, and a 12
>>> line recursive function which does nothing but call itself, call the
>>> other function and perform various "if.. else" statements.
>>
>> Sounds very neat. I look forward to seeing it. Mine does not actually
>> move anything. All it does is print the moves required.
>>
>
> It's in Swift, but there's nothing non-standard in it, apart form the
> explanation marks and underscores, which can be ignored. The towers
> are numbered from 0 to 2, instead of 1 to 3.
<snip code>
Thanks. I'll take a look later (getting late here now). Mine is in C.
It is just a plan ToH solver with a loop that gathers the rings
together. To get the rings on pin 1 (rather than 0) I just added the
call move(max_d, find_ring(1, pins), 1); at the end. All but the last
two lines of main are just collecting and checking the configuration
since that's given on the command line.
#include <stdio.h>
#include <stdlib.h>
int find_ring(int n, const unsigned pins[])
{
for (int p = 0; p < 3; p++)
if (pins[p] & (1u << n))
return p;
return -1;
}
void move(int n_rings, int from, int to)
{
if (from != to && n_rings > 0) {
int free_pin = 3 - from - to;
move(n_rings-1, from, free_pin);
printf("%c%c\n", 'A' + from, 'A' + to);
move(n_rings-1, free_pin, to);
}
}
int main(int argc, char **argv)
{
unsigned pins[3] = {0};
int pin = 0, max_d = 0;
for (int a = 1; a < argc; a++)
if (*argv[a] >= 'A' && *argv[a] < 'A' + 3 && !argv[a][1])
pin = *argv[a] - 'A';
else {
int d = atoi(argv[a]);
if (d > max_d)
max_d = d;
pins[pin] |= 1u << d;
}
for (int p = 1; p < 3; p++)
for (int r = 0; r < p; r++)
if (pins[p] & pins[r]) {
fprintf(stderr, "Duplicate rings.\n");
return EXIT_FAILURE;
}
if ((pins[0] | pins[1] | pins[2]) != (1u << max_d+1) - 2) {
fprintf(stderr, "Rings do not form a contiguous range from 1.\n");
return EXIT_FAILURE;
}
for (int n = 1; n < max_d; n++)
move(n, find_ring(n, pins), find_ring(n + 1, pins));
}
--
Ben.
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2020-10-13 01:26 +0100 |
| Message-ID | <874kmz55u4.fsf@bsb.me.uk> |
| In reply to | #501651 |
Ben Bacarisse <ben.usenet@bsb.me.uk> writes: > ... To get the rings on pin 1 (rather than 0) I just added the > call move(max_d, find_ring(1, pins), 1); at the end. Correction: it was an explicit move(max_d, 0, 1); -- Ben.
[toc] | [prev] | [next] | [standalone]
| From | Archimedes Plutonium <plutonium.archimedes@gmail.com> |
|---|---|
| Date | 2020-10-12 13:58 -0700 |
| Message-ID | <4a9e7931-8165-4bf6-9224-f7ea9e08fbdcn@googlegroups.com> |
| In reply to | #501582 |
I don't know about you but I am tired of Australian "Hollering shit faced Posts" much like their crass and ribald TV drama like The Heart Guy. Australia-------- you do not have to impress. Your intrinsic worth and value shows itself, without needing to HOLLER. SOUTH KOREA, MOON BEARS Boycott Samsung, Hyundai until South Korea stops torturing Moon Bears. Moon Bears of South Korea need the world's helping hand from primitive evil// SCIENCE COUNCIL RULING EARTH Archimedes Plutonium Jul 22, 2020, 3:05 PM to sci.physics, sci.math, plutonium-atom-universe newsgroups Utterly horrible story last night from BBC: Quoting BBC-- Moon bears: Korean campaigners call for farm closures Animal rights campaigners are asking the South Korean president for help to save hundreds of the country’s caged moon bears. More than 400 bears are being kept on farms across the country. They’re waiting to be killed for their parts which some people use as medicine. --- end quote --- The news showed the living conditions-- more apt-- the dying conditions of 400 Moon Bears trapped in large cages, and routinely slaughtered for their body parts. This is a story one can expect of primitive and evil people, not modern society of 2020. The BBC said animal rights groups were pleading with the president of South Korea to stop this farm-killing and put the bears into a sanctuary. One of the major concerns is that this is how we have Viruses jump from one species into another species like our present day covid-19 corona virus that jumped from some wild animal into our species. BBC-- I beg you please, have a weekly news update on these Moon Bears. DW News -- I beg you please, cover this story also, and shame the South Koreans for this evil behavior. Please cover it weekly until the president of South Korea puts those poor bears into a sanctuary and stop this utter foolish and nonscientific behavior of animal torture for idiot humans who think body parts cure anything. USA news outlets-- please, I beg you to cover this story, for animal torture on this scale and on this scale of idiocy has no place in modern Human society. President Donald Trump-- please, I beg of you, stop military practice with South Korea, until they straighten out this Moon Bear farming torture. USA Trump administration-- I beg you, think of some trade sanctions on South Korea until they fix this Moon Bear evil. EU government-- please, I beg you, apply trade sanctions on South Korea until they fix the Moon Bear evilness. AP Archimedes Plutonium Jul 22, 2020, 2:49 AM to sci.physics, sci.math, plutonium-atom-universe newsgroup Quoting the web— Wild Fauna and Flora in the most critical category of endangerment. This means that no international trade in either live Moon Bears or any of their parts is allowed. Unfortunately, for thousands of years Moon Bears have been hunted and killed for their gall bladders to be used as medicine. As a matter of fact, it has been proven in the field of medical science that bear gall bladder can be easily replaced by herb medicine or synthetic alternatives which are cheaper, more effective and more readily available. However, up to today thousands of bears still endure tortures on bear farms in many countries across Asia. Archimedes Plutonium<plutonium.archimedes@gmail.com> Jul 23, 2020, 1:42:32 AM to Plutonium Atom Universe Those poor Moon Bears, BBC has the film clip showing their animal cruelty. Reminds me of the torture of geese and goose in that idiocy of what was the French word ?? Fra gras, where they stuff a poor bird full of food, not because the goose is hungry, no, but stuff the goose so its internal organs get inflamed and enlarged, and think of all that misery and pain to the animal, just so some worthless idiot human being can eat what he thinks is a delicacy. Were the French the first to stop this evil? Or was it the EU government that put an end to this animal torture evil? EU, please, I beg you, help get those South Korean Moon Bears into a sanctuary. Animal torture on this scale of 2020 is abhorrent. AP Archimedes Plutonium Jul 23, 2020, 2:45:50 AM to sci.physics Quoting the web— Wild Fauna and Flora in the most critical category of endangerment. This means that no international trade in either live Moon Bears or any of their parts is allowed. Unfortunately, for thousands of years Moon Bears have been hunted and killed for their gall bladders to be used as medicine. As a matter of fact, it has been proven in the field of medical science that bear gall bladder can be easily replaced by herb medicine or synthetic alternatives which are cheaper, more effective and more readily available. However, up to today thousands of bears still endure tortures on bear farms in many countries across Asia. Archimedes Plutonium Jul 25, 2020, 9:30:24 PM to sci.physics, sci.math, plutonium-atom-universe Quoting BBC— Moon bears: Korean campaigners call for farm closures Animal rights campaigners are asking the South Korean president for help to save hundreds of the country’s caged moon bears. More than 400 bears are being kept on farms across the country. They’re waiting to be killed for their parts which some people use as medicine. It’s legal in South Korea to slaughter the bears for their bile. The only other country which allows this is China. The demand almost wiped out Korea’s native bear population and now campaigners believe the coronavirus pandemic has shown the potential risks of using wild animal parts as medicine. Archimedes Plutonium<plutonium.archimedes@gmail.com> Jul 26, 2020, 4:31 AM to Plutonium Atom Universe Quoting Wikipedia— South Korea remains one of two countries to allow bear bile farming to continue legally. As reported in 2009, approximately 1,374 Asian black bears reside in an estimated 74 bear farms, where they are kept for slaughter to fuel the demands of traditional Asian medicine. In sharp contrast, fewer than 20 Asian black bears can be found at Jirisan Restoration Center, located in Korea's Jirisan National Park. Archimedes Plutonium Aug 6, 2020, 2:20 AM to sci.physics On NATURE tv show, showed brown bears in Turkey, living happily, why not South Korea, instead of torturing them Saw a NATURE tv program where they put cameras on wildlife to observe them more better. One segment showed brown bears in the mountains of Turkey of a forest, a small area, and plenty plenty of bears. Thank You _Turkey_ for taking care of wildlife. They had some problems, but all manageable. I do not know if South Korea has a place where it can relocate all those tortured Moon Bears, caged to extract their bile and gall bladder. AP
[toc] | [prev] | [next] | [standalone]
| From | Dario Alpern <darioalpern@gmail.com> |
|---|---|
| Date | 2020-10-12 14:33 -0700 |
| Message-ID | <a715f92c-6bbd-466b-b800-ac36a1283712n@googlegroups.com> |
| In reply to | #501582 |
On Monday, October 12, 2020 at 9:26:20 AM UTC-3, Graham Cooper wrote: > The TOWERS OF HANOI algorithm starts from a FULL STACK and 2 empty stacks. > > Can you solve a game that someone has already started? > > > STACK1 20 18 15 12 11 9 5 4 2 > STACK2 17 14 13 10 3 > STACK3 19 16 8 7 6 1 > > > www.miniBASE.com Graham, The answer is very simple: first move the disk 1 over disk 2. Then move disks 1 and 2 over disk 3 using the standard algorithm to solve the puzzle in 3 moves. Then move the disks 1, 2, 3 over 4 using the algorithm in 7 moves and so on. You will end with the 20 disks ordered. Finally you can move all disks to the final rod in 2^20-1 moves. Best regards, Dario Alpern
[toc] | [prev] | [standalone]
Page 3 of 3 — ← Prev page 1 2 [3]
Back to top | Article view | sci.math
csiph-web