@@ -249,6 +249,21 @@ private static bool CheckIfUgly(int number)
249
249
return false ;
250
250
}
251
251
252
+ public int [ ] GenerateUglyNumbersArray ( int count )
253
+ {
254
+ var list = new HashSet < int > { 1 } ;
255
+ for ( var index = 1 ; index <= count ; index ++ )
256
+ {
257
+ list . Add ( index * 2 ) ;
258
+ list . Add ( index * 3 ) ;
259
+ list . Add ( index * 5 ) ;
260
+ }
261
+
262
+ var newList = list . ToList ( ) ;
263
+ newList . Sort ( ) ;
264
+ return newList . Take ( count ) . ToArray ( ) ;
265
+ }
266
+
252
267
[ Test ]
253
268
public void RemoveDuplicatesFromSortedArray_1 ( )
254
269
{
@@ -383,9 +398,9 @@ public void ContainsDuplicates_82(int []inputArray, bool isDuplicateElement)
383
398
{
384
399
//given
385
400
//when
386
- var isPalindrome = CheckIfArrayContainsDuplicatedElements ( inputArray ) ;
401
+ var containsDuplicateStatus = CheckIfArrayContainsDuplicatedElements ( inputArray ) ;
387
402
//then
388
- Assert . AreEqual ( isDuplicateElement , isPalindrome ) ;
403
+ Assert . AreEqual ( isDuplicateElement , containsDuplicateStatus ) ;
389
404
}
390
405
391
406
[ Test ]
@@ -399,10 +414,20 @@ public void CheckUglyNumbers_99(int number, bool isUgly)
399
414
{
400
415
//given
401
416
//when
402
- var isPalindrome = CheckIfUgly ( number ) ;
417
+ var uglyStatus = CheckIfUgly ( number ) ;
403
418
//then
404
- Assert . AreEqual ( isUgly , isPalindrome ) ;
419
+ Assert . AreEqual ( isUgly , uglyStatus ) ;
405
420
}
406
421
422
+ [ Test ]
423
+ [ TestCase ( 10 , new [ ] { 1 , 2 , 3 , 4 , 5 , 6 , 8 , 9 , 10 , 12 } ) ]
424
+ public void CheckUglyNumbers2_100 ( int numberOfUglyNumbers , int [ ] arrayWithUglyNumbers )
425
+ {
426
+ //given
427
+ //when
428
+ var arrayWithUglyNumbersGenerated = GenerateUglyNumbersArray ( numberOfUglyNumbers ) ;
429
+ //then
430
+ Assert . AreEqual ( arrayWithUglyNumbers , arrayWithUglyNumbersGenerated ) ;
431
+ }
407
432
}
408
433
}
0 commit comments