diff options
| author | Andrew Schneider <andrewschneider@Jessicas-Air.fios-router.home> | 2024-05-31 20:23:35 -0400 |
|---|---|---|
| committer | Andrew Schneider <andrewschneider@Jessicas-Air.fios-router.home> | 2024-05-31 20:23:35 -0400 |
| commit | e48fb3dc57ff94a52fb854a3b0a975d53f14ce70 (patch) | |
| tree | f55eb394e9a4801681a853e120ba355901791830 | |
| parent | 8ef83f8690ca9a424ea03cb766e182b9ad4b110f (diff) | |
| download | perlweeklychallenge-club-e48fb3dc57ff94a52fb854a3b0a975d53f14ce70.tar.gz perlweeklychallenge-club-e48fb3dc57ff94a52fb854a3b0a975d53f14ce70.tar.bz2 perlweeklychallenge-club-e48fb3dc57ff94a52fb854a3b0a975d53f14ce70.zip | |
fix README formatting
| -rw-r--r-- | challenge-271/atschneid/README.md | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/challenge-271/atschneid/README.md b/challenge-271/atschneid/README.md index cdefaf7b38..a590aed159 100644 --- a/challenge-271/atschneid/README.md +++ b/challenge-271/atschneid/README.md @@ -14,32 +14,32 @@ Now onto the code. ## Task 1: Maximum Ones -> You are given a m x n binary matrix.<\br> -<\br> -> Write a script to return the row number containing maximum ones, in case of more than one rows then return smallest row number.<\br> -<\br> -> Example 1<\br> -> Input: $matrix = [ [0, 1],<\br> -> [1, 0],<\br> -> ]<\br> -> Output: 1<\br> -<\br> -> Row 1 and Row 2 have the same number of ones, so return row 1.<\br> -> Example 2<\br> -> Input: $matrix = [ [0, 0, 0],<\br> -> [1, 0, 1],<\br> -> ]<\br> -> Output: 2<\br> -<\br> -> Row 2 has the maximum ones, so return row 2.<\br> -> Example 3<\br> -> Input: $matrix = [ [0, 0],<\br> -> [1, 1],<\br> -> [0, 0],<\br> -> ]<\br> -> Output: 2<\br> -<\br> -> Row 2 have the maximum ones, so return row 2.<\br> +> You are given a m x n binary matrix.<br/> +<br/> +> Write a script to return the row number containing maximum ones, in case of more than one rows then return smallest row number.<br/> +<br/> +> Example 1<br/> +> Input: $matrix = [ [0, 1],<br/> +> [1, 0],<br/> +> ]<br/> +> Output: 1<br/> +<br/> +> Row 1 and Row 2 have the same number of ones, so return row 1.<br/> +> Example 2<br/> +> Input: $matrix = [ [0, 0, 0],<br/> +> [1, 0, 1],<br/> +> ]<br/> +> Output: 2<br/> +<br/> +> Row 2 has the maximum ones, so return row 2.<br/> +> Example 3<br/> +> Input: $matrix = [ [0, 0],<br/> +> [1, 1],<br/> +> [0, 0],<br/> +> ]<br/> +> Output: 2<br/> +<br/> +> Row 2 have the maximum ones, so return row 2.<br/> One thing that surprised me here, we want the 1 indexed row. For example, I would have expected the first solution to be 0, the zeroth row. But, I'll solve the problem I'm given. @@ -64,28 +64,28 @@ And that's about it. I return that `$idx` value, then increment it (0 to 1 index ## Task 2: Sort by 1 bits -> You are give an array of integers, @ints.A<\br> -<\br> -> Write a script to sort the integers in ascending order by the number of 1 bits in their binary representation. In case more than one integers have the same number of 1 bits then sort them in ascending order.<\br> -<\br> -> Example 1<\br> -> Input: @ints = (0, 1, 2, 3, 4, 5, 6, 7, 8)<\br> -> Output: (0, 1, 2, 4, 8, 3, 5, 6, 7)<\br> -<\br> -> 0 = 0 one bits<\br> -> 1 = 1 one bits<\br> -> 2 = 1 one bits<\br> -> 4 = 1 one bits<\br> -> 8 = 1 one bits<\br> -> 3 = 2 one bits<\br> -> 5 = 2 one bits<\br> -> 6 = 2 one bits<\br> -> 7 = 3 one bits<\br> -> Example 2<\br> -> Input: @ints = (1024, 512, 256, 128, 64)<\br> -> Output: (64, 128, 256, 512, 1024)<\br> -<\br> -> All integers in the given array have one 1-bits, so just sort them in ascending order.<\br> +> You are give an array of integers, @ints.A<br/> +<br/> +> Write a script to sort the integers in ascending order by the number of 1 bits in their binary representation. In case more than one integers have the same number of 1 bits then sort them in ascending order.<br/> +<br/> +> Example 1<br/> +> Input: @ints = (0, 1, 2, 3, 4, 5, 6, 7, 8)<br/> +> Output: (0, 1, 2, 4, 8, 3, 5, 6, 7)<br/> +<br/> +> 0 = 0 one bits<br/> +> 1 = 1 one bits<br/> +> 2 = 1 one bits<br/> +> 4 = 1 one bits<br/> +> 8 = 1 one bits<br/> +> 3 = 2 one bits<br/> +> 5 = 2 one bits<br/> +> 6 = 2 one bits<br/> +> 7 = 3 one bits<br/> +> Example 2<br/> +> Input: @ints = (1024, 512, 256, 128, 64)<br/> +> Output: (64, 128, 256, 512, 1024)<br/> +<br/> +> All integers in the given array have one 1-bits, so just sort them in ascending order.<br/> At first I thought I was going to end up reusing some pieces of my solution to Task 1 for this, but it turned out to be just different enough that I didn't think it was worth it. |
