Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 754939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:04:19+00:00 2026-05-14T15:04:19+00:00

EDIT : See Solving "Who owns the Zebra" programmatically? for a similar class of

  • 0

EDIT: See Solving "Who owns the Zebra" programmatically? for a similar class of problem

There’s a category of logic problem on the LSAT that goes like this:

Seven consecutive time slots for a broadcast, numbered in chronological order I through 7, will be filled by six song tapes-G, H, L, O, P, S-and exactly one news tape. Each tape is to be assigned to a different time slot, and no tape is longer than any other tape. The broadcast is subject to the following restrictions:
L must be played immediately before O.
The news tape must be played at some time after L.
There must be exactly two time slots between G and
P, regardless of whether G comes before P or whether G comes after P.

I’m interested in generating a list of permutations that satisfy the conditions as a way of studying for the test and as a programming challenge. However, I’m not sure what class of permutation problem this is. I’ve generalized the type problem as follows:

Given an n-length array A:

  1. How many ways can a set of n unique items be arranged within A? Eg. How many ways are there to rearrange ABCDEFG?
  2. If the length of the set of unique items is less than the length of A, how many ways can the set be arranged within A if items in the set may occur more than once? Eg. ABCDEF => AABCDEF; ABBCDEF, etc.
  3. How many ways can a set of unique items be arranged within A if the items of the set are subject to “blocking conditions”?

My thought is to encode the restrictions and then use something like Python’s itertools to generate the permutations. Thoughts and suggestions are welcome.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T15:04:19+00:00Added an answer on May 14, 2026 at 3:04 pm

    Okay, so the way I see it, there are two ways to approach this problem:

    1. Go about writing a program that will approach this problem head first. This is going to be difficult.

    2. But combinatorics teaches us that the easier way to do this is to count all permutations and subtract the ones that don’t satisfy your constraints.

    I would go with number 2.

    You can find all permutations of a given string or list by using this algorithm. Using this algorithm, you can get a list of all permutations. You can now apply a number of filters on this list by checking for the various constraints of the problem.

    def L_before_O(s):
        return (s.index('L') - s.index('O') == 1)
    
    def N_after_L(s):
        return (s.index('L') < s.index('N'))
    
    def G_and_P(s):
        return (abs(s.index('G') - s.index('P')) == 2)
    
    def all_perms(s):    #this is from the link
        if len(s) <=1:
            yield s
        else:
            for perm in all_perms(s[1:]):
                for i in range(len(perm)+1):
                    yield perm[:i] + s[0:1] + perm[i:]
    
    def get_the_answer():
        permutations = [i for i in all_perms('GHLOPSN')] #N is the news tape
        a = [i for i in permutations if L_before_O(i)]
        b = [i for i in a if N_after_L(i)]
        c = [i for i in b if G_and_P(i)]
        return c
    

    I haven’t tested this, but this is general idea of how I would go about coding such a question.

    Hope this helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

*Edit: Please see my answer below for the solution. Is there any danger in
EDIT: See my working code in the answers below. In brief: I have a
EDIT: I would really like to see some general discussion about the formats, their
Edit: I have solved this by myself. See my answer below I have set
I receive this message (see image below) when I try to edit in debugging.
Preserved question - see Edit at the bottom I'm working on a small functional
Edit: This question was written in 2008, which was like 3 internet ages ago.
Edit: From another question I provided an answer that has links to a lot
EDIT: This was formerly more explicitly titled: - Best solution to stop Kontiki's KHOST.EXE
EDIT: Learned that Webmethods actually uses NLST, not LIST, if that matters Our business

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.