#Lockdown Coding Challenge - Day 01

Last week Saraswathi celebrated her 3rd birthday. She received a xylophone as a birthday gift. This xylophone has 8 keys(A,B,C,D,E,F,G,H). Saraswathi started liking the tunes she could produce with that. She does not like certain sequences that make her cry. A tune is unpleasant when it contains a sequence that make her cry. All other tunes are pleasant tunes. Ram her brother who is studying combinatorics in school, wants to find out for a given tune how many distinct non-empty sub tunes exist that are pleasant. Can you help Ram by writing a program that answers his question?

T - Given tune

S - sub tune of the given tune

T - any combination of keys (A,B,C,D,E,F,G,H)

S - where every key used is present in T. If a particular key is present in T K times then you can use that key in S upto K times.

Example 1

T - ABC

S - A, B, C, AB, BA, AC, CA, BC, CB, ABC, ACB, BAC, BCA, CBA, CAB.

Example 2

T - AAB

S - A, B, AA, AB, BA, AAB, ABA, BAA

Input Format

Given Tune

N - (number of tunes that saraswathi dislikes)

N-lines each containing one such tune.

Constraints

Length of the Tune is <= 8

Output Format

Number of pleasant subtunes of the given tune.

Sample Input 0

  1. AB
  2. 1
  3. AB

Sample Output 0

  1. 3

are you issuing a challenge? asking for help?

I don’t understand

I am looking for a best solution with time and space complexity. Good Luck

Firstly, welcome to the forums.

While we are primarily here to help people with their Free Code Camp progress, we are open to people on other paths, too. Some of what you are asking is pretty trivial in the Free Code Camp context, so you might find that if you’re not getting the instruction and material you need in your current studies, the FCC curriculum will really help you get started. At a modest guess I’d say investing a 4-5 hours working through the curriculum here will really pay off. You can find the curriculum at https://www.freecodecamp.org/learn.

With your current questions, we don’t have enough context to know what you already know or don’t know, so it is impossible to guide you without just telling you the answer (which we won’t do).

It is pretty typical on here for people to share a codepen / repl.it / jsfiddle example of what they have tried so that anyone helping has more of an idea of what help is actually helpful.

Please provide some example of what you’ve tried and I’m sure you’ll get more help.

Happy coding :slight_smile:

My own interpentation of what is going on

1 I want to give you all a challenge
2 This forum is for if you have questions not to ask them