Problem Statement
The original circle is described by a
Create a class Dating that contains a method dates that is given circle and k and returns
a
Definition
- Class:
- Dating
- Method:
- dates
- Parameters:
- String, int
- Returns:
- String
- Method signature:
- String dates(String circle, int k)
- (be sure your method is public)
Constraints
- circle will contain between 1 and 50 characters, inclusive, all letters 'A'-'Z' or 'a'-'z'.
- The characters in circle will be distinct.
- k will be between 1 and 100, inclusive.
Examples
"abXCd"
2
Returns: "bC dX"
Starting at the beginning we count 'a' as 1 and 'b' as 2 so 'b' chooses 'C' since 'C' is a lot hotter than 'X'. Then we count 'X' as 1 and 'd' as 2 (since 'C' is off discussing world affairs with 'b') so 'd' chooses 'X'. At this point only 'a' is left so the party breaks up.
"abXCd"
8
Returns: "Xa dC"
We count all the way around the circle and arrive at 'X' as the first to choose. The next chooser is 'd' since we count all the way around the circle more than twice (since there are only 3 people left at this point).
"ABC"
2
Returns: ""
"HGFhgfz"
1
Returns: "Hf Gg Fh"
"DiuwSFab"
98
Returns: "iD wF aS"
"ABCDEFGHIJKLMNOPQRSTUVWXYabcdefghijklmnopqrstuvwxy"
100
Returns: "yA Ea Mb Yc sB Sd xC nD kF pG Ke jH Xf lI Og Nh oJ uL wP Ui Tm rQ Vq Rt vW"
Let's assume that the original circle is described with a String containing lowercase letters for women and uppercase letters for men. The last one in the String is actually adjacent to the first one thus forming the circle. The k-th person counting around the circle makes the first choice. Letters nearer the beginning of the alphabet represent hotter individuals, and the chooser always chooses the hottest remaining member of the opposite sex. The next choice is made by the k-th person with the count continuing from the last chooser's position, only counting those who are still in the circle. This continues until the party breaks up.
"DiuwSFablmnoLMNOA"
53
Returns: "iA mD nF aL wM oN Sb Ol"
"abcdefghijklmnopqrstuvwxyABCDEFGHIJKLMNOPQRSTUVWXY"
1
Returns: "aA bB cC dD eE fF gG hH iI jJ kK lL mM nN oO pP qQ rR sS tT uU vV wW xX yY"
"ZzYyXxWwvVUuTtSsQqBbMmr"
12
Returns: "uB zM Sb wQ yT Zm Yq Wr sU xV Xt"
"ABCDEFGHIJkLMNOPQRSTUVWXYZ"
26
Returns: "Zk"
"ABCDEFGHIJkLMNOPQRSTUVWXYZ"
25
Returns: "Yk"
"ABCDEFGHIJkLMNOPQRSTUVWXYZ"
37
Returns: "kA"
"GHKJghkjYOIUerytX"
2
Returns: "He Jg kG Yh Ij rK tO Uy"
"XmOxgzjAMqlfevnNpkKoywrZTbiVh"
25
Returns: "Tb wA yK Ze Xf jM oN qO gV"
"kCGIfnpMtrmgONcUwPxWhLsEiVXFdZQJHRYTqeKvA"
80
Returns: "Kc Ad nC wE He Uf pF Gg mI Xh Wi Zk Nq Vr Js Tt Rv Ox"
"mOVoEfHenNMPRrZtkXsDpduagljhGYUv"
85
Returns: "pD rE Za gG eH Od Nf Uh nM Pj Rk lV tX sY"
"EubxqfgocnyzUSpIeWliQCjdhrk"
74
Returns: "iC Wb hE yI oQ pS zU"
"yNaxcSMYnfpuqVdezvZkogQmHLb"
2
Returns: "Na cH Mb nL pQ qS dV zY Ze"
"cqPEKxhTHakiYjAougbrtCFlnNezwypV"
47
Returns: "Aa Vb Cc jE iF uH eK Yg Th lN rP"
"joFHLzriJxNYPSfyOKspMtuqlQBIhmwdacEVkXg"
13
Returns: "Pa Qc oB yE wF xH lI Jd hK Sf jL mM tN pO qV zX kY"
"VgXLMjnFywHlqRYDUdzvhOsbcNSoiBEfmkexAa"
23
Returns: "sA yB kD Oa qE jF gH xL Vb nM Uc oN Yd lR hS zX"
"OAyNpDdZKLtIzxlfbBShEMJiQTjoVFGnPgRWuXsa"
1
Returns: "Oa Ab yB Nd pD Zf Kg Lh tE Ii zF xG lJ Sj Mn Qo Ts Vu"
"mgUJxeXnwdPRHcsaquWCDvjSfIhN"
12
Returns: "Ra fC wD Ic Pd gH jJ uN qS vU eW xX"
"njxiyktugvhecoqzabmfl"
82
Returns: ""
"ljcfhznIMgTJvOuwtSXdksomFaRUE"
41
Returns: "Ja Rc wE Md nF Tf kI Og tS hU sX"
"yimsqwjegopvzfdNnUxt"
78
Returns: "Ud sN"
"RlQOfAFBkXPYKiEqUWDdVCzaHMrJIgNZSGLT"
90
Returns: "Wa fA Gd Sg Oi Vk Pl Kq Ir Jz"
"FbmQiPCMENHOfUqXnKYJRZgvWALseGTDo"
27
Returns: "Lb Ze Yf Kg Ri sA mC Un Fo Wq Gv"
"SkIYJNHKMbjAwGzCgcPdZQVnyX"
79
Returns: "Sb Kc Vd Zg Yj kA Cn Nw Iy Qz"
"iDsnfvtburTgwYeOkdyBlxj"
37
Returns: "Yb tB fD rO yT"
"hxfdzaep"
20
Returns: ""
"rSEzTtVLIDfmkwihbuseUqMxYcGvFn"
75
Returns: "iD zE Fb Sc wG Ve fI vL mM uT Yh tU"
"reSZpdlcYqfFxnkamLCIKObwgoWit"
15
Returns: "kC eF Ia lK iL bO xS fW mY tZ"
"CXwhJzWkLabxvBfDIROyHjcNUSPlE"
48
Returns: "Oa xB kC bD Hc hE Pf wI Nj Xl Wv Jy Rz"
"EsDxCvRWSVNIgwHoXTMFZOQ"
32
Returns: "Sg Zo Is Wv Nw Ox"
"xlbyjaimMzpvshnugqWNYdrt"
84
Returns: "vM aN pW lY"
"mPYNBiTbtXoIxLsApejuEKcSCzkGVRgFwyrdQZUMa"
13
Returns: "xA kB Ma sC gE iF cG Pb Kd Ne Rj Im Yo Qp rL Ut Su Tw Vy Zz"
"nOzefQswgBvTI"
99
Returns: "wB sI Qe gO zT"
"HGFhgfz"
1
Returns: "Hf Gg Fh"
"ABCDEfghiJKLmnopQrstuVWXYzabcd"
5
Returns: "Ea Jb oA tB Yc fC Ld rD Xg mK uQ iV zW"
"a"
1
Returns: ""
"ABCDE"
21
Returns: ""
"abXCd"
8
Returns: "Xa dC"
"HxyGFaZMnPo"
7
Returns: "Za yF xG nH Po"
"ABCDEFGd"
2
Returns: "Bd"
"aA"
1
Returns: "aA"
"asdGHJoiuLK"
7
Returns: "oG dH sJ uK La"
"PnFeCDabhKLMotzwx"
4
Returns: "eC hD oF xK bL wM tP"
"abcdefghijklmnopqrstuvwxyz"
100
Returns: ""
"ab"
1
Returns: ""
"ABCDEFGabcdefgHIJKhijkLMNOPQRSYTzyxWv"
99
Returns: "Na Kb Jc Md vA Pe Lf zB kC Sg jD Eh Ri Qx Oy"
"abcDEF"
6
Returns: "Fa cD bE"
"AZ"
1
Returns: ""
"kAbBaEdDeFfgGhHiIjJK"
99
Returns: "Ja eA gB Gb iD hE jF dH Kf kI"
"AB"
2
Returns: ""
"ABCD"
2
Returns: ""
"aB"
1
Returns: "aB"
"aqwertyuiopPOIUYTREQAmnblkMNBLKJ"
6
Returns: "tA Pa Rb kB qE iI Te Nl yJ Ym wK Un oL uM Op rQ"
"ABD"
2
Returns: ""
"ABCDEFG"
5
Returns: ""
"dguftweEWhHr"
1
Returns: "dE gH uW"
"abAB"
1
Returns: "aA bB"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
100
Returns: ""
"abXCd"
100
Returns: "dC aX"
"abcdefghijklmnOPQRSTWXVzytpqCBA"
99
Returns: "fA Ra hB eC nO dP kQ cS Vb jT iW gX"
"npIgGDLxAtasOouEqPfwMCbFrNjivHQkKmcBlhedJ"
60
Returns: "fA dB Fa sC Ib Jc pD Oe jE xG hH Lg Ni rK oM vP tQ"
"ABCDEFGHIJKLMNOPQRSTUVWXYyxwvutsrqponmlkjihgfedcba"
1
Returns: "Aa Bb Cc Dd Ee Ff Gg Hh Ii Jj Kk Ll Mm Nn Oo Pp Qq Rr Ss Tt Uu Vv Ww Xx Yy"
"a"
11
Returns: ""
"Aa"
1
Returns: "Aa"
"abcdefghijkABCDEF"
3
Returns: "cA fB iC Da bE gF"
"abcdefg"
2
Returns: ""
"ab"
2
Returns: ""
"YZyz"
1
Returns: "Yy Zz"
"zFJxSchKLgfdEYmRretyuioQWTUqwPADnIHasGZXMvblOkjNCB"
94
Returns: "lA Ma bB zC fD Wc Fd qE eG mH yI sJ rK gL oN Sh uO Yi Xj Pk xQ nR Tt wU vZ"
"AB"
3
Returns: ""
"ABC"
34
Returns: ""
"abXCd"
5
Returns: "dC bX"
"aAbBcC"
3
Returns: "bA Ca Bc"
"abXCd"
2
Returns: "bC dX"
"abcdA"
1
Returns: "aA"
"abcdefghijXZ"
12
Returns: "Za cX"
"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuU"
1
Returns: "aA bB cC dD eE fF gG hH iI jJ kK lL mM nN oO pP qQ rR sS tT uU"
"PnFrgqjSeRCDabhKLMotzwx"
5
Returns: "gC Ra Lb wD rF hK xM Se nP"
"abcd"
2
Returns: ""
"ABCDEFG"
100
Returns: ""
"abcdefG"
98
Returns: "Ga"
"abc"
2
Returns: ""
"HGFhgfzIopPMTL"
10
Returns: "pF zG fH oI Lg Ph"
"aAbdefSDIF"
1
Returns: "aA bD dF eI fS"
"aBcDeF"
4
Returns: "Da cB Fe"
"abcd"
1
Returns: ""
"HGFhgfzabcdywe"
34
Returns: "fF Ga bH"
"bAaBcCdD"
3
Returns: "aA Cb Bc dD"
"RZpz"
99
Returns: "pR zZ"
"ABCDEFGabcdrtyuhgfjklvMPZ"
99
Returns: "Pa Fb Mc Cd vA uB Df Zg lE Gh"
"ABCDEFGHIJKLMNOPQRSTUVWXYabcdefghijklmnopqrstuvwxy"
100
Returns: "yA Ea Mb Yc sB Sd xC nD kF pG Ke jH Xf lI Og Nh oJ uL wP Ui Tm rQ Vq Rt vW"
"alksdjfhOWAEIFJqwerVNM"
7
Returns: "fA Ja Md We Vh Ej lF rI Nk qO"
"CfPaTQVRSbUedW"
99
Returns: "Ca Tb fP Rd eQ"
"abc"
1
Returns: ""
"HGFhgfzk"
1
Returns: "Hf Gg Fh"
"abcdEABCDef"
10
Returns: "eA fB cC bD dE"
"abcdefgh"
100
Returns: ""