From e48fb3dc57ff94a52fb854a3b0a975d53f14ce70 Mon Sep 17 00:00:00 2001 From: Andrew Schneider Date: Fri, 31 May 2024 20:23:35 -0400 Subject: fix README formatting --- challenge-271/atschneid/README.md | 96 +++++++++++++++++++-------------------- 1 file 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.
+
+> Write a script to return the row number containing maximum ones, in case of more than one rows then return smallest row number.
+
+> Example 1
+> Input: $matrix = [ [0, 1],
+> [1, 0],
+> ]
+> Output: 1
+
+> Row 1 and Row 2 have the same number of ones, so return row 1.
+> Example 2
+> Input: $matrix = [ [0, 0, 0],
+> [1, 0, 1],
+> ]
+> Output: 2
+
+> Row 2 has the maximum ones, so return row 2.
+> Example 3
+> Input: $matrix = [ [0, 0],
+> [1, 1],
+> [0, 0],
+> ]
+> Output: 2
+
+> Row 2 have the maximum ones, so return row 2.
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
+
+> 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.
+
+> Example 1
+> Input: @ints = (0, 1, 2, 3, 4, 5, 6, 7, 8)
+> Output: (0, 1, 2, 4, 8, 3, 5, 6, 7)
+
+> 0 = 0 one bits
+> 1 = 1 one bits
+> 2 = 1 one bits
+> 4 = 1 one bits
+> 8 = 1 one bits
+> 3 = 2 one bits
+> 5 = 2 one bits
+> 6 = 2 one bits
+> 7 = 3 one bits
+> Example 2
+> Input: @ints = (1024, 512, 256, 128, 64)
+> Output: (64, 128, 256, 512, 1024)
+
+> All integers in the given array have one 1-bits, so just sort them in ascending order.
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. -- cgit