From 92a51920dcb1830efadd481c7df9a360728e241f Mon Sep 17 00:00:00 2001 From: sitarameez Date: Tue, 29 Jun 2021 14:39:12 -0400 Subject: [PATCH 1/4] did one right --- src/main/java/io/zipcoder/StringsAndThings.java | 13 +++++++++++-- .../classes/io/zipcoder/StringsAndThings.class | Bin 0 -> 1282 bytes .../ContainsEqualNumberOfIsAndNotTest.class | Bin 0 -> 1323 bytes .../stringsandthings/CountTripleTest.class | Bin 0 -> 1321 bytes .../zipcoder/stringsandthings/CountYZTest.class | Bin 0 -> 1372 bytes .../zipcoder/stringsandthings/GIsHappyTest.class | Bin 0 -> 1210 bytes .../stringsandthings/RemoveStringTest.class | Bin 0 -> 1308 bytes 7 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 target/classes/io/zipcoder/StringsAndThings.class create mode 100644 target/test-classes/io/zipcoder/stringsandthings/ContainsEqualNumberOfIsAndNotTest.class create mode 100644 target/test-classes/io/zipcoder/stringsandthings/CountTripleTest.class create mode 100644 target/test-classes/io/zipcoder/stringsandthings/CountYZTest.class create mode 100644 target/test-classes/io/zipcoder/stringsandthings/GIsHappyTest.class create mode 100644 target/test-classes/io/zipcoder/stringsandthings/RemoveStringTest.class diff --git a/src/main/java/io/zipcoder/StringsAndThings.java b/src/main/java/io/zipcoder/StringsAndThings.java index 073467a..8a34393 100644 --- a/src/main/java/io/zipcoder/StringsAndThings.java +++ b/src/main/java/io/zipcoder/StringsAndThings.java @@ -1,6 +1,8 @@ package io.zipcoder; +import java.util.Locale; + /** * @author tariq */ @@ -15,7 +17,12 @@ public class StringsAndThings { * countYZ("day fyyyz"); // Should return 2 */ public Integer countYZ(String input){ - return null; + int result=0; + //char lastLetter = input.charAt(input.length()); + if(input.endsWith("y") || input.endsWith("z")){ + result+=1; + } + return result; } /** @@ -28,7 +35,9 @@ public Integer countYZ(String input){ * removeString("Hello there", "x") // Should return "Hello there" */ public String removeString(String base, String remove){ - return null; + String result=""; + result = base.replace(remove,""); + return result; } /** diff --git a/target/classes/io/zipcoder/StringsAndThings.class b/target/classes/io/zipcoder/StringsAndThings.class new file mode 100644 index 0000000000000000000000000000000000000000..52f2207161e191fcf6e95ee535fcd4e6bb7925fd GIT binary patch literal 1282 zcma)6+fvg|6kR7NO)aTl1iTdmFVIq;UeIv{FQceq$66lB;OLAGr{T~BLlSaf2A=&1 z{R(|S#|J;aZ*m;>Ng|DcVls2iKKtyw_S$Qw{r2O_R{#sRS;R41EZ|ZRmvNDfp+pFBSGp`(aFYJEq;oQ`?a$==m)RmU}4XMm0ySYRmsYbXrE zeOZ?~8^R>|8P_lI3c^_nURYs|$Q+_$l}37^50p-i2ENVhNGz{2j8z(0Y5VileBs&L zq%I$2ftPyRZ;P!+IHp+4jOjOj7BL+bCQ+d8T|Rk`j2NUsXN139us zC})h;Q}mvR@h1|D6ra#=lI|JBoy91{DijH5P`+b?DRgm~5)%TiDOG}&jC`v$YvlK! zwdQ2Sq>JM*@)WJp)Nm!PHj^amS1VB!S&cw&E@r2aJfmc(}_MIy64zLZk_ mmq?W)PgyrnNm@x4^!xu0jQdAmT-ewA?>wFzfiV&DoBRm_bNX@s literal 0 HcmV?d00001 diff --git a/target/test-classes/io/zipcoder/stringsandthings/ContainsEqualNumberOfIsAndNotTest.class b/target/test-classes/io/zipcoder/stringsandthings/ContainsEqualNumberOfIsAndNotTest.class new file mode 100644 index 0000000000000000000000000000000000000000..556ec648ddd0173f22453fac00953e644e289eef GIT binary patch literal 1323 zcmb7DZBG+H5Pr5Tv|JA;MG+Jb3PLH$$&0TTA`nSPnvzJ!0H(EUm(>8~*) zi*q%G)FuTo^p~X)mEfc<+$yiz-UP zUTZ@fIIf_?exXsfy$EWNZp0ftxflk^$NU4gY_1Ni4aczsSCo)zLy5>QVJ!WJy3Ang zI)U2|TT&Ne=Ef^6XlfHV3^0sd*8&rL=x4}M!@LRl=)NW%V=;{-6U$gh95es` literal 0 HcmV?d00001 diff --git a/target/test-classes/io/zipcoder/stringsandthings/CountTripleTest.class b/target/test-classes/io/zipcoder/stringsandthings/CountTripleTest.class new file mode 100644 index 0000000000000000000000000000000000000000..29d3cfe89a19ec698f6f56f4b5783c566258b309 GIT binary patch literal 1321 zcmbW0YflqF6o%jFZA-gKDHr7`1(dcRtALt_F+rjUNtHxMgP+WFJCr45w{Ewj`man> zh$j93f0Xgv?Mll{6ZXUGnKN_V=bSS$zkYxJ31AgZQqVD@VK#*bX8MrETncw_FNt~I zlTV?5ViF5UENZx~VM!p<^jyoXHP`Lx&c1I5OqDFh_+&Lqr>b0I``r4PK;oHYTi$bl zXuePuh;4AAK!3@y)tlB~MY%h&Ql}?da!gq-OV{$}p)=;~TZAl~frLp&yUJB2VQe@p z+uL!i2IExIBQ)MrUaKK6`j#u!p(m9k?Re6&9Gjv9x;5jV#q5k1YR_>M12g7X zt%m|h)ov)$Q&oY%(t$jZMqS!9W7GCjO}T!B()3!g&fp%!Fp=|m%NG$V0;z4M<(lf1 z=PIpT z9+&AJ-FmaBTxOulzIgSL7=}vG6 ziBonA<4m%jB~8$Z;4gSG08d>6Cr-hASAxd~9;fI8L6g@4-?<2mo`O?Xf^!7V5Ijrp M+_k{dtUH3-AHtao{r~^~ literal 0 HcmV?d00001 diff --git a/target/test-classes/io/zipcoder/stringsandthings/CountYZTest.class b/target/test-classes/io/zipcoder/stringsandthings/CountYZTest.class new file mode 100644 index 0000000000000000000000000000000000000000..27178e441080925aa59e674cb2fb937740d251ba GIT binary patch literal 1372 zcmbtTYfsZ)7(MT9Eu+c+CxAzIo`;4x1^4qvVXhDTc%WiFj}ppZM$cmb ziz=2>EGsY+JQOH+zH8YHZ^N$d9fg6wRK;?PGpki|>e4lK|EaGFF${aO=gBFPR(pqP1g#~aWdl{StQXfk;EcQyUr>_7@JOD`}-gE zr00_`>q$Ro35>sI);f_@%d?2MVcU*x`j%r8kYsMdI1Z@Hcr6bdS8`CRB{(a@vFujh zhrP$fSPE!&q3>4s~YH9s($^sI|2R@hCndYN}kAiwJb zZcV(ZJxL)hf~q;3#6l(rvE@{{~YPB$Rrryp9c2z6EVTj zVw};KWh}xR|BLBxD#P69P_~l2K<=IX1(}6!P_`GBE}$mxBisZOlg21ijFD)Zr-_J4 z??A*C6t|?@ezNB#P5A_TU`2YX_ literal 0 HcmV?d00001 diff --git a/target/test-classes/io/zipcoder/stringsandthings/GIsHappyTest.class b/target/test-classes/io/zipcoder/stringsandthings/GIsHappyTest.class new file mode 100644 index 0000000000000000000000000000000000000000..97d69c05d93af48f51dd343f570612e004b2bfd8 GIT binary patch literal 1210 zcmb7@YflqV5Qg8=7FxCov_%n=i`=9w%F4wn#-x~_CJiRiG?8zo<+vQO>^6Hbt^dkI z!D!+S@JAWvY!`RIK*E>ZnK?7>Gc$Yk_n#lX0Bqu!hGEQSv7jM^`61|7%wb76_cSb{ ztf7Kx4lC+?KZgfdtY%>_6g=ORw&~UEgT|pU7-s6yF+R&q+c^-fv3KEoi(&AEw59)& zAziLC88WXZkzuqhZLu31w}ji^EsG+hy3^)Xle<#+Q842lN`kDMgG5bm`+!cV3FGx! z?+x#CdJW%yhA9NTd-v_oYk3~~@k|b-k?fBf6j!lY0b4}wYpw^6S@zHSw6%LyT zp*3oqxBY-y3}f{p{)rnFw@qW)aV)`YN-rcdBJ??h^$Us{4BDO(xNWf`)x^bQ->ZtC zqktmA)Kx3hF@jO*t=l!tZdb=ctYxvTV*{I6Jks$PPiO^nst%tjXGo>?dK6%&B&Dxh zB+VBO{jPN++CD?>Y(oso<-}6@-+il+2*rCU#yU}uL2vcf*yL6~tDw8FPr&$_)I3kP z1k`wFG+dRHDetQ*l<&uOxaA4V(d8YcOU>x=(qhOOAe+`m&k}hCy_t$uPr<&Bk-``~ z2g6_h4AsZ`Rgt=e9PVI>x;x`chn$&9 oI72ZpQC z6{Cqiz#nB?GaYQDpb0NC`|PvN`u1LD=I5_(KLD)beilQR&0sEz1ZD?u3G*5jG!!+I z!c;knMJ#Dp*07?%%;0tgcLat#-&OXmw`n)4tuPRnswl_&pbi>NQ@ZBPsr?Os^dn^} z|FJ-_SgHx6p0ZFNUs1Mv8SK}kTea$KW{ir{u-Y}tRpB~Lru>#7#QX~qH(}XL?y?DU zTkboDvcs-Q&nI=jlYVd@FuonwzS@^HpHGl=@Q??_SiV=Sepdx1!+LJNnMM zT<8_=G_cX56lY2`%}C#Oh?HaMi}dz z0$jr=R{~=^oQMuTL^9gb%iocBeT?L1q`Dg6j|HM~tncdRvCeo*nTRy6|IvIy%_MUp z#z3X~2`M9OWWGRqvAFaVgI#e0DHe^gbc}P2v+0QlQs^9xAxX+k;s%?{bEGLo3D$PT yn~uPRGr-vsaPD026fx5jEf73&A@Ix@;PeStKNmbl@I1i_1Q#y^zR9^0xb+*ujR_9` literal 0 HcmV?d00001 From a80134dfac89bb63b5b9f39c2cc2c0d682e0c709 Mon Sep 17 00:00:00 2001 From: sitarameez Date: Tue, 29 Jun 2021 18:11:25 -0400 Subject: [PATCH 2/4] two methods completed --- .../java/io/zipcoder/StringsAndThings.java | 20 ++++++++++++++---- .../io/zipcoder/StringsAndThings.class | Bin 1282 -> 1595 bytes 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/zipcoder/StringsAndThings.java b/src/main/java/io/zipcoder/StringsAndThings.java index 8a34393..089f128 100644 --- a/src/main/java/io/zipcoder/StringsAndThings.java +++ b/src/main/java/io/zipcoder/StringsAndThings.java @@ -18,9 +18,13 @@ public class StringsAndThings { */ public Integer countYZ(String input){ int result=0; - //char lastLetter = input.charAt(input.length()); - if(input.endsWith("y") || input.endsWith("z")){ - result+=1; + String words[]=input.split(" "); + for (String word:words + ) { + if(word.endsWith("y") || word.endsWith("z")){ + result+=1; + } + } return result; } @@ -49,7 +53,15 @@ public String removeString(String base, String remove){ * containsEqualNumberOfIsAndNot("noisxxnotyynotxisi") // Should return true */ public Boolean containsEqualNumberOfIsAndNot(String input){ - return null; + Boolean result =false; + String letter[] = input.split(""); + + + + //} + + + return result; } /** diff --git a/target/classes/io/zipcoder/StringsAndThings.class b/target/classes/io/zipcoder/StringsAndThings.class index 52f2207161e191fcf6e95ee535fcd4e6bb7925fd..4fd144b9cf924534b614deb50b85c8180973fbe8 100644 GIT binary patch literal 1595 zcmah{%W@M}5It8K>5hfOLq=8vwqwY{Zv?~<#sWLo=AkMhFYJ&CsVv6hi#=qR5u=e) zu;wRV$tK%m<4`R40KR}vp(rZk+|eLSf`M7w+uhTB`rOm~@}K7~0LH^aCJ6`zn zZGrKLwY%1yRdp?IC(f)-CPED_R68nQjq$r5Z0o)sk`8P`9R(C_f(g)!2AIOKg3H??pA8XTUMJ&k(34$7_ogX zv>dN}^?t{4yK1iAX=r7dK1qL0i)G(;mE{q6Fu|Z7HFp~A8&<3JK;Td$@Mhq&^sI6l zekZWiHAg$8|Ig!$7Br6n4pX-=iFzKFaGCalJQlG;wHXr1E*&yZ@c}I6Ylao2MlPEn{}+;I$k2~-Ja!k z)cPHPp@~LvX8kpjfoi#yO`%qkz$?2}u%YgElxM4YLjC{5lZd@7Nbrb9rMurw=Dr^x zPT>#*)?XGvPlV?YdR5-k9+|1XA^xI~!qGSh7{D>w`ECM=7^Ej~93`H*_!YBF-mB@$ z)5X+2(#_cgqhh?MWzw~5DO<`s#dyUiWzR3jiYyxY$UH%TR+iRdWFMu(qpbMj-K*he zkbe><9rYfCqn3+BUQjx5h;R@K$(?k8sV-_CV>la#|Cx-LPPx|ap!)D z4FWruKQoZEFoRjf=LY61%ws_S78bGOmgJWEA@3tdBFH(^qeFnLw3hp>Me3o(H!$DH z*kT3f? z4tV^8&uH*bM;tvY5G;(Mm&KB$fC2dhM@T06+38Pkz+OcS*?KNBZR?LPa# Date: Wed, 30 Jun 2021 22:24:54 -0400 Subject: [PATCH 3/4] finally figured out is and not --- .../java/io/zipcoder/StringsAndThings.java | 66 +++++++++++------- .../io/zipcoder/StringsAndThings.class | Bin 1595 -> 1960 bytes 2 files changed, 41 insertions(+), 25 deletions(-) diff --git a/src/main/java/io/zipcoder/StringsAndThings.java b/src/main/java/io/zipcoder/StringsAndThings.java index 089f128..c6dfdac 100644 --- a/src/main/java/io/zipcoder/StringsAndThings.java +++ b/src/main/java/io/zipcoder/StringsAndThings.java @@ -13,17 +13,17 @@ public class StringsAndThings { * but not the 'y' in "yellow" (not case sensitive). We'll say that a y or z is at the end of a word if there is not an alphabetic * letter immediately following it. (Note: Character.isLetter(char) tests if a char is an alphabetic letter.) * example : countYZ("fez day"); // Should return 2 - * countYZ("day fez"); // Should return 2 - * countYZ("day fyyyz"); // Should return 2 + * countYZ("day fez"); // Should return 2 + * countYZ("day fyyyz"); // Should return 2 */ - public Integer countYZ(String input){ - int result=0; - String words[]=input.split(" "); - for (String word:words - ) { - if(word.endsWith("y") || word.endsWith("z")){ - result+=1; - } + public Integer countYZ(String input) { + int result = 0; + String[] words = input.split(" "); + for (String word : words + ) { + if (word.endsWith("y") || word.endsWith("z")) { + result += 1; + } } return result; @@ -33,36 +33,52 @@ public Integer countYZ(String input){ * Given two strings, base and remove, return a version of the base string where all instances of the remove string have * been removed (not case sensitive). You may assume that the remove string is length 1 or more. * Remove only non-overlapping instances, so with "xxx" removing "xx" leaves "x". - * + *

* example : removeString("Hello there", "llo") // Should return "He there" - * removeString("Hello there", "e") // Should return "Hllo thr" - * removeString("Hello there", "x") // Should return "Hello there" + * removeString("Hello there", "e") // Should return "Hllo thr" + * removeString("Hello there", "x") // Should return "Hello there" */ - public String removeString(String base, String remove){ - String result=""; - result = base.replace(remove,""); + public String removeString(String base, String remove) { + String result = ""; + result = base.replace(remove, ""); return result; } /** * Given a string, return true if the number of appearances of "is" anywhere in the string is equal * to the number of appearances of "not" anywhere in the string (case sensitive) - * + *

* example : containsEqualNumberOfIsAndNot("This is not") // Should return false - * containsEqualNumberOfIsAndNot("This is notnot") // Should return true - * containsEqualNumberOfIsAndNot("noisxxnotyynotxisi") // Should return true + * containsEqualNumberOfIsAndNot("This is notnot") // Should return true + * containsEqualNumberOfIsAndNot("noisxxnotyynotxisi") // Should return true */ - public Boolean containsEqualNumberOfIsAndNot(String input){ - Boolean result =false; - String letter[] = input.split(""); + public Boolean containsEqualNumberOfIsAndNot(String input) { + Boolean result = false; + String[] inputSplitIntoLetters = input.split(""); + int countOfIs=0; + int countOfNot=0; + for(int i=0;iP_Ofa%Je zx=9gKz%#foF~o@98Ao)XlbQK1=lgHpe?D5T{i#nsK5PN#!8I=e=rz&j zMLz~iB%~ZPG33QCPMa8!_NW(QIAbCzjd2qbCeE6eG%;l$Y2e(GfgOYLyn%2zAzmsX zTizD6v0yg8TD0d^b6Go?w+qu5+s-^#6R21$6!Z4%Qj)sY)l&uAz;yYm7)c&LwSZ`3 zJ_|EQQGaY<78j_L49r=$h~SCCfe8Pd z@S)4;H3E&k%Dvi^=x}OFUxb=Mw3l7fQwqj)$&4JThqmmxq`rrDrZZq}LQSc0O^xen z+!ORfx3t?YFc%GaVgcVK)~%g=X9TAhTTKIV@aq^=zbTfiw%!> zwfiQh1@&hzHCeOk9m}hbgT>h_(8rGHm5$ix}WCyyB^qu@oBKww01{5J@QJh)ir$9H2xEnON40v delta 691 zcmaixyKd8P6vltYcKAES=_PFw3I);@2qY=jP)Z7cUZCngVCl%fh{S*d3oLm82IO}@ zj7$iDgv8pXK;k7(g@EtxSm}aCA-OHK9rt{GKidy>%B2_2pFMqPG_xn7+X%m9)8T9uMD-er9Myn-j$lYZ zb~1Yu)tXa94a!U_PSt@DRc7RkS>|%=n`qCbvLDg%(4)FSEK#SX*D2pF@IE@Gnh~(c zJjdnBtaE||LQV>KhUkw-o#T|_v^jKW!=(9(MHLPReu~?)@siio#A8iH@|9{lXm_f^ z_#@@P$_G^f{Pq*-Lrb=;D?9lWt Date: Wed, 30 Jun 2021 22:40:48 -0400 Subject: [PATCH 4/4] completed this lab --- .../java/io/zipcoder/StringsAndThings.java | 27 +++++++++++++++--- .../io/zipcoder/StringsAndThings.class | Bin 1960 -> 2303 bytes 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/zipcoder/StringsAndThings.java b/src/main/java/io/zipcoder/StringsAndThings.java index c6dfdac..5cfec4c 100644 --- a/src/main/java/io/zipcoder/StringsAndThings.java +++ b/src/main/java/io/zipcoder/StringsAndThings.java @@ -87,9 +87,21 @@ public Boolean containsEqualNumberOfIsAndNot(String input) { * gHappy("xxgxx") // Should return false * gHappy("xxggyygxx") // Should return false */ - public Boolean gIsHappy(String input){ - return null; - } + public Boolean gIsHappy(String input) { + Boolean result = false; + String[] letter = input.split(""); + for (int i = 0; i < letter.length - 1; i++) { + if (letter[i].equals("g") && letter[i + 1].equals("g")) { + result = true; + } + if (i > 0) { + if (letter[i].equals("g") && letter[i - 1].equals("g")) { + result = true; + } + } + } + return result; + } /** @@ -100,6 +112,13 @@ public Boolean gIsHappy(String input){ * countTriple("a") // Should return 0 */ public Integer countTriple(String input){ - return null; + int result=0; + String[] letter = input.split(""); + for(int i=0;icTx=*7P_Y69(Lzy?hw@Mas-RFn1w1$&IqqNs-T*nO>>n3j6 z7{j;#Y)s&miD9*#v~e3#bVzY5b3Ecmb1Z$>(Ndx$NCx%uL4fJ`EzOR|(z>$z9#DXC z+BQ!B1BY;!v%nElIKI#2m?+DBm643{YNkgu%5W56m|XYe{gri$djcAIP>Cwe1r($j z5$LF)XANYI1(+skO&k{{>i8GD^Czmfu?y`7a|@inNp&wHW*8|s7X__EeM4~4+C)Jj z_KrImD*z7g9EkE;k3uv!6j3+AtE!0Ssw!roSD2AH{H!m`SuiH1?#g~Ko{{msuft*N zCs~LJH5yU+-(J~zFFpM12<+)9qb+B1c zZFCn#A@6T?tKd!FGAzrWk<_=~AF2-$Sx@M#G9+W$a^W=wV&V+(8@W(TTelN0P@gTrD{w zt0oArEtNp(fs&p;Nl&0zPoN33cui0Yxrabrgt`a?Ab+ddX-xDf!+eTAu6O+p->AS` zXh(o@*XGxlYjSpc8=7$NK38nP{7vZgYKrfbW>>EAIi3*iDcWgw^L_U_+fMK?_Nn3? eRorXsUQ)TO-T4O<8*vY|YH1O3k=n?h;oL8)euZrS delta 758 zcmaixJ8u&~6otRp>}JN!hA0j(Plr4SI5y8DJj|N_HUvWgfkX%isvseSNQNSA@&l-l zYkEo~Bnk?C06&2rfrMy~g)nEcc*`>0ST^6|MT1+f z)XGmcH@6zA!CYmCodz>1NX%`j%C}uNkYbneSSJv%n>~t#z3fY{Z^IRnZTtu)wmoWA zh;iZflf$ZB=-_=eqCG<(`v(|ROi^M?=pH77oFr^%ytPbPri|sFUZa`67}G|R;HS6^ z(;V`1)$v%Jp<;i=Rc8vBHTRKJwfJ5;0bczMokL#V8Tu$BF7oY;uBv_xC#u9EWKNwu zq@^#XXw+Bmvl`!`*Ya5JEhQeyayG0VT9k`kO{jO->K%^}uf%agY%v=gO*{_poMY+; z^}nBSTv?R(9wBOpuH)NsBC##sQ~4%QpXQ%ztI(wRZIywN!2Gr8FAg3h_Ok8MuArbJ W$mn8{>+&T3