程序练习---1(MatchMaker)
来源:互联网 发布:sql server修改默认值 编辑:程序博客网 时间:2024/05/16 17:15
/*
*
Problem Statement
THIS PROBLEM WAS TAKEN FROM THE SEMIFINALS OF THE TOPCODER INVITATIONAL
TOURNAMENT
DEFINITION
Class Name: MatchMaker
Method Name: getBestMatches
Paramaters: String[], String, int
Returns: String[]
Method signature (be sure your method is public): String[]
getBestMatches(String[] members, String currentUser, int sf);
PROBLEM STATEMENT
A new online match making company needs some software to help find the "perfect
couples". People who sign up answer a series of multiple-choice questions.
Then, when a member makes a "Get Best Mates" request, the software returns a
list of users whose gender matches the requested gender and whose answers to
the questions were equal to or greater than a similarity factor when compared
to the user's answers.
Implement a class MatchMaker, which contains a method getBestMatches. The
method takes as parameters a String[] members, String currentUser, and an int
sf:
- members contains information about all the members. Elements of members are
of the form "NAME G D X X X X X X X X X X"
* NAME represents the member's name
* G represents the gender of the current user.
* D represents the requested gender of the potential mate.
* Each X indicates the member's answer to one of the multiple-choice
questions. The first X is the answer to the first question, the second is the
answer to the second question, et cetera.
- currentUser is the name of the user who made the "Get Best Mates" request.
- sf is an integer representing the similarity factor.
The method returns a String[] consisting of members' names who have at least sf
identical answers to currentUser and are of the requested gender. The names
should be returned in order from most identical answers to least. If two
members have the same number of identical answers as the currentUser, the names
should be returned in the same relative order they were inputted.
TopCoder will ensure the validity of the inputs. Inputs are valid if all of
the following criteria are met:
- members will have between 1 and 50 elements, inclusive.
- Each element of members will have a length between 7 and 44, inclusive.
- NAME will have a length between 1 and 20, inclusive, and only contain
uppercase letters A-Z.
- G can be either an uppercase M or an uppercase F.
- D can be either an uppercase M or an uppercase F.
- Each X is a capital letter (A-D).
- The number of Xs in each element of the members is equal. The number of Xs
will be between 1 and 10, inclusive.
- No two elements will have the same NAME.
- Names are case sensitive.
- currentUser consists of between 1 and 20, inclusive, uppercase letters, A-Z,
and must be a member.
- sf is an int between 1 and 10, inclusive.
- sf must be less than or equal to the number of answers (Xs) of the members.
NOTES
The currentUser should not be included in the returned list of potential mates.
EXAMPLES
For the following examples, assume members =
{"BETTY F M A A C C",
"TOM M F A D C A",
"SUE F M D D D D",
"ELLEN F M A A C A",
"JOE M F A A C A",
"ED M F A D D A",
"SALLY F M C D A B",
"MARGE F M A A C C"}
If currentUser="BETTY" and sf=2, BETTY and TOM have two identical answers and
BETTY and JOE have three identical answers, so the method should return
{"JOE","TOM"}.
If currentUser="JOE" and sf=1, the method should return
{"ELLEN","BETTY","MARGE"}.
If currentUser="MARGE" and sf=4, the method should return [].
Definition
Class:
MatchMaker
Method:
getBestMatches
Parameters:
string[], string, int
Returns:
string[]
Method signature:
string[] getBestMatches(string[] param0, string param1, int param2)
(be sure your method is public)
This problem statement is the exclusive and proprietary property of TopCoder, Inc.
Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc.
is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.
*/
- 程序练习---1(MatchMaker)
- Matchmaker
- 小程序开发利器:Matchmaker
- B. Matchmaker
- 练习小程序1
- java练习程序1
- 练习1:第一个程序
- 程序练习
- 程序练习
- 程序练习
- 程序练习
- android2.3程序练习1(贴图分享)
- 【程序46】宏#define命令练习(1)
- Object-C练习小程序(1)
- 练习程序:算法系列1:Google方程式
- 练习1-15 重写温度转换程序
- MASM-打字练习程序
- 练习小程序2
- 庆祝论坛开通 http://www.coderpub.com
- 第一次的亲密接触!
- wap手机一些agent
- 利用oracle long类型字段问题
- 12个最重要的J2EE最佳实践
- 程序练习---1(MatchMaker)
- 值得思考的 J2EE 架构的6个最佳实践
- 行走社会的100条忠告
- 使用Servlet动态生成图片
- 一个“树”,现在是1.0体验版,呵呵。摘得帖子
- 代表公司去川工做讲座
- 用Activator .CreateInstance代替new实现类的实例化
- 重定向(forward与sendRedirect)区别
- 读RTL8139驱动自己的总结(PCI相关)