5 kyu

Coding 3min : Count animals

73 of 103myjinxin2015

Description:

This is the simple version of Fastest Code series. If you need some challenges, please try the Performance version

Task:

Give you some chars, and they can combine many animal names.

Return the maximum number of animal names that can be combined by chars.

Animal names have been preload by variable names

One char cannot use twice, for example:

    chars="goatcode"
    When you got a "dog" first time, chars left "atcoe", 
    second time you can got a "cat".
    result=2
    
    When you got a "goat" first time, chars left "code", 
    no animals will be found at next time.
    result=1
    
    So we should return the maximum number, sc("goatcode")=2

Examples:

    names=["dog","cat","bat","cock","cow","pig","fox",
           "ant","bird","lion","wolf","deer","bear","frog",
           "hen","mole","duck","goat"]
    
    sc("dogcat")=2("dog" and "cat")    
    sc("bcaatt")=2("bat" and "cat")    
    sc("dogdog")=2("dog" and "dog")    
    sc("dopig")=1(only contains one of "dog" or "pig")
    
    some corner case:
    
    sc("goatcode")=2  should return 2("dog","cat"), not 1("goat")    
    sc("cockdogwdufrbir")=4 
    should return 4("cow","duck","frog","bird") not 2("cock" and "dog")
                                    

Series:

Puzzles
Games

Stats:

CreatedApr 16, 2016
PublishedApr 16, 2016
Warriors Trained385
Total Skips29
Total Code Submissions769
Total Times Completed103
JavaScript Completions73
Haskell Completions32
Total Stars27
% of votes with a positive feedback rating94% of 39
Total "Very Satisfied" Votes34
Total "Somewhat Satisfied" Votes5
Total "Not Satisfied" Votes0
Total Rank Assessments6
Average Assessed Rank
5 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • myjinxin2015 Avatar
  • St3f4n Avatar
  • JohanWiltink Avatar
  • Voile Avatar
  • ejini战神 Avatar
Ad