Jump to content
BrainDen.com - Brain Teasers
  • 0

Coding Challenge


superprismatic
 Share

Question

Here's a puzzle inspired by a

Walter Penney puzzle which probably

requires programming. If anyone can

do it by hand, I will tip my hat to

him/her/it!

A string of letters is produced as

follows. The 26 letters are split

into some number of disjoint subsets.

The elements in each subset are

arranged in some order and each has

a pointer to its first element.

One of the subsets is chosen with

probability proportional to its size.

When a subset is chosen, the element

under its pointer is picked to be the

next element of the letter string

then its pointer is moved to the next

element of the subset. The pointers

advance circularly, so a pointer goes

from the end of its subset to the

beginning of it. This continues

until a letter string of the desired

length is obtained. The result is:


VFXCUMYSQTJWDKOHRZIFUVXTSKOABJ
VHCRYXNELFUSWJDQZGTKOBVHCXANRP
FUSJYWVQXSDMZTBAIELCYKONHRGPFJ
UWTQMZIKEBDOHVRLCGXPFUYANMSIEL
GWPDQZJATNVKMBIWXOHRFCUETDLGKP
YQOZMHANISREFUJTBKLCVXOSHGJWVY
XRDPAFUNMQTKOZIELHBSRGWFJVUPDX
MTSKAICJEYQLGPZBMOHRIELNFVXCUT
[/code]

What are the ordered subsets?

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

How I did it

I opened it up in Notepad and made it all one line. Then starting with V I added a return before each one. I ended up with several lines all starting with V. Ignoring the last line, because the code could have ended before the subset that started with V cycled thur, I picked the shortest line. Then i took the next letter after the V and checked if it was in every line, if it was I added it to the V subset and deleted it from all the lines. I continuted thur the line until the last letter. Then I deleted all the V's and the returns so i had one line again the repeated the prosess untill I used all the letters.

Link to comment
Share on other sites

  • 0

Only using Notepad I got

FUTKOHR, MIELGP, CYQZB, WDAN, VXSJ, Z

There's the trivial answer, and then there's the previous answer

The trivial answer is 26 sets of single letters. The more serious answer is stewdeker's answer. This challenge doesn't require much programming, since for any letter, we can identify groups of letters that can not possibly be in the same group as our original letter by looking at the frequency between repeated occurances. For instance, if "A" does not appear between two occurances of "V", then "A" can not belong to the same group as "V". That said, there are multiple solutions, which can be found by combining the trivial answer with the official answer.

Edited by bushindo
Link to comment
Share on other sites

  • 0

There's the trivial answer, and then there's the previous answer

The trivial answer is 26 sets of single letters. The more serious answer is stewdeker's answer. This challenge doesn't require much programming, since for any letter, we can identify groups of letters that can not possibly be in the same group as our original letter by looking at the frequency between repeated occurances. For instance, if "A" does not appear between two occurances of "V", then "A" can not belong to the same group as "V". That said, there are multiple solutions, which can be found by combining the trivial answer with the official answer.

My answer would be the smallest number of subsets possible. I assumed that that was what the OP vaguely stated. Or maybe should have.

:)
Link to comment
Share on other sites

  • 0

Wow! You guys are good! Not only did you solve the problem, but you pointed out flaws in my statement. I should have constrained the problem some more. Bushindo's comment never occured to me even though it seems obvious now. Stewdecker got the 5 subsets I used to make the puzzle (the lone Z was already used in another subset). It goes to show you that a little thought is often better than a brute force programming solution. I tip my hat to Stewdecker!

Edit: fixed a typo

Edited by superprismatic
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...