CodeChef is a non-commercial competitive programming community
Login
Username (New User? Signup) Password (Forgot Password?)
Signup
Login or
Signup with
Connect
Note
  • Publicize your achievements on your Facebook Wall.
  • Challenge your friends or ask them for help.

Site Navigation

  • PRACTICE
    • Easy
    • Medium
    • Hard
    • Challenge
    • Peer
  • COMPETE
    • All Contests
    • June Long 2012
    • May Cook-Off
    • May Long 2012
  • DISCUSS
    • Forums
    • Blog
    • Wiki
    • Facebook
    • Twitter
  • COMMUNITY
    • CodeChef Meetups
    • Campus Chapters
    • Host your Contest
    • User Groups
    • CodeChef TechTalks
    • All Educational Initiatives
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Tutorials
    • Long Contest Ranks
    • Short Contest Ranks
    • Event Calendar
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
Home » Compete » Knight Coders Round 2 » The Legend Lives On!

The Legend Lives On!

Problem code: KC204

  • All Submissions

All submissions for this problem are available.

Points:10

Your college teacher was highly impressed by your previous achievement. So now he has given you a new project to work on. If you can make this one into a success, you could be on your way to Rio de Janeiro in Brazil to participate in the global finale of this international technical extravaganza sponsored by Bromhood Brothers, a leading software developer( Now why does it look familiar ?!?). You are given set of letters, and the challenge is to find how many different words can be made from these letters. This problem is designed to take all the fun out of it by automating the process.

Input:

Input will be in two parts. The first part will be a dictionary of less than 1000 lines, containing words to be searched for. Each line will contain one word of up to 7 characters. Each word will be in lower case. The words will be in alphabetical order. The end of the dictionary will be indicated by a line consisting of a single #' character.
After the dictionary there will be data for several word puzzles, each on a separate line. Each puzzle line will have from one to 7 lower case letters, separated by one or more spaces. Your task is to arrange some or all of these letters to form words in the dictionary. The list of puzzles will be terminated by a line consisting of a single #'.

Output:

For each puzzle line in the input, a single line of output should be produced, containing the number of different words in the dictionary that can be formed using the letters in the puzzle line.
Note that each letter may be used only as many times as it appears in the puzzle line. For instance, the puzzle line u l l' may produce the word lul' but not the word lull'.

Example:

Input:
ant
bee
cat
dog
ewe
fly
gnu
#
b e w
b b e e w w
t a n c u g d
#
Output:
0
2
3


Author: ankitbabbar
Date Added: 16-10-2009
Time Limit: 5 sec
Source Limit: 50000 Bytes
Languages: ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TEXT, WSPC


  • Submit

Comments

  • Login or Register to post a comment.

Could you please check the

rahulakaneo @ 24 Oct 2009 10:22 PM

Could you please check the input / output . I have checked my algorithm a number of times and don't see a bug in it .

The input and output cases

ankitbabbar @ 24 Oct 2009 11:45 PM

The input and output cases are correct and there are no capital letters..

there seems to be some wrong

ankul_iiita @ 25 Oct 2009 12:24 AM

there seems to be some wrong case in this problem, am sure of it!!!

The i/o cases are

ankitbabbar @ 25 Oct 2009 12:25 AM

The i/o cases are correct...and there are correct submissions too..

What is the number of word

insomniacs @ 25 Oct 2009 12:40 AM

What is the number of word puzzles that will be given at max?

The max no of word puzzles

ankitbabbar @ 25 Oct 2009 12:46 AM

The max no of word puzzles can be 50

Based on a number of

insomniacs @ 25 Oct 2009 01:38 AM

Based on a number of observations I can guarantee that there is something wrong with your input format. Taking input via 2 different formats - one of them causes a TLE, the other causes a wrong answer to be produced in 0.0 seconds. As the core algo is the same, this is inconsistent. Please re-check your input format. The values might be correct but the format might not.

my code is running perfectly

anshulluhsna @ 25 Oct 2009 01:42 AM

my code is running perfectly in my machine...it is giving (run time error)seg fault in online judge, cant understand y.

plz help

@ Bharat: The input format

ankitbabbar @ 25 Oct 2009 01:50 AM

@ Bharat: The input format and the test cases ate both correct..and there are already correct submissions for the same...

@ anshul: Segmentation fault

ankitbabbar @ 25 Oct 2009 01:51 AM

@ anshul: Segmentation fault error occurs when there are some wrong memory access procedures in your program

Can u tell me all the cases

anshulluhsna @ 25 Oct 2009 02:10 AM

Can u tell me all the cases wen your compiler shows a run time error

and can i use string functions, do while loops

I do not find any reason why it is showing no error in my machine, but your compiler says "RUN TIME ERROR", even though I have checked for more than 1000 word lines (as specified in the problem)

 

@anshul: You can check the

ankitbabbar @ 25 Oct 2009 02:21 AM

@anshul: You can check the details at www.codechef.com/wiki

can you give some other test

mohitkuldeep @ 25 Oct 2009 06:51 PM

can you give some other test case.

@mohit: The test cases

ankitbabbar @ 25 Oct 2009 06:57 PM

@mohit: The test cases provided  are enough...

SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:

Programming Competition Fetching successful submissions
Directi Go for Gold
CodeChef is a global programming communityCodeChef hosts online programming competitions
CodeChef is a non-commercial competitive programming community
  • About CodeChef
  • About Directi
  • CEO's Corner
  • C-Programming
  • Programming Languages
  • Contact Us
© 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
In order to report copyright violations of any kind, send in an email to copyright@codechef.com
CodeChef a product of Directi
The time now is:
CodeChef - A Platform for Aspiring Programmers

CodeChef was created as a platform to help programmers make it big in the world of algorithms, computer programming and programming contests. At CodeChef we work hard to revive the geek in you by hosting a programming contest at the start of the month and another smaller programming challenge in the middle of the month. We also aim to have training sessions and discussions related to algorithms, binary search, technicalities like array size and the likes. Apart from providing a platform for programming competitions, CodeChef also has various algorithm tutorials and forum discussions to help those who are new to the world of computer programming.

Practice Section - A Place to hone your 'Computer Programming Skills'

Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our programming contest judge accepts solutions in over 35+ programming languages. Preparing for coding contests were never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple programming challenges that take place through-out the month on CodeChef.

Compete - Monthly Programming Contests and Cook-offs

Here is where you can show off your computer programming skills. Take part in our 10 day long monthly coding contest and the shorter format Cook-off coding contest. Put yourself up for recognition and win great prizes. Our programming contests have prizes worth up to Rs.20,000 and $700lots more CodeChef goodies up for grabs.

Discuss

Are you new to computer programming? Do you need help with algorithms? Then be a part of CodeChef's Forums and interact with all our programmers - they love helping out other programmers and sharing their ideas. Have discussions around binary search, array size, branch-and-bound, Dijkstra's algorithm, Encryption algorithm and more by visiting the CodeChef Forums and Wiki section.

CodeChef Community

As part of our Educational initiative, we give institutes the opportunity to associate with CodeChef in the form of Campus Chapters. Hosting online programming competitions is not the only feature on CodeChef. You can also host a coding contest for your institute on CodeChef, organize an algorithm event and be a guest author on our blog.

Go For Gold

The Go for Gold Initiative was launched about a year after CodeChef was incepted, to help prepare Indian students for the ACM ICPC World Finals competition. In the run up to the ACM ICPC competition, the Go for Gold initiative uses CodeChef as a platform to train students for the ACM ICPC competition via multiple warm up contests. As an added incentive the Go for Gold initiative is also offering over Rs.8 lacs to the Indian team that beats the 29th position at the ACM ICPC world finals. Find out more about the Go for Gold and the ACM ICPC competition here.

Domain Name Registration, Web hosting, and Website Design provided by BigRock.com