aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbigail <abigail@abigail.be>2021-01-27 17:59:57 +0100
committerAbigail <abigail@abigail.be>2021-01-27 17:59:57 +0100
commit9a417c9df1e355f0535a038f32a3952eb44ffba8 (patch)
tree80088faa9f9522c394e675a4604f20fd63f64cc1
parentf45c80eb175b2a9ce859779629f6fd46ee58049a (diff)
downloadperlweeklychallenge-club-9a417c9df1e355f0535a038f32a3952eb44ffba8.tar.gz
perlweeklychallenge-club-9a417c9df1e355f0535a038f32a3952eb44ffba8.tar.bz2
perlweeklychallenge-club-9a417c9df1e355f0535a038f32a3952eb44ffba8.zip
Notes come after the examples.
-rw-r--r--challenge-097/abigail/README.md40
1 files changed, 20 insertions, 20 deletions
diff --git a/challenge-097/abigail/README.md b/challenge-097/abigail/README.md
index 30c09a9877..fa6376b47c 100644
--- a/challenge-097/abigail/README.md
+++ b/challenge-097/abigail/README.md
@@ -43,26 +43,6 @@ You are given a binary string `$B` and an integer `$S`.
Write a script to split the binary string `$B` of size `$S` and then
find the minimum number of flips required to make it all the same.
-### Notes
-We will be reading the strings from STDIN. The number of sections
-will be passed in as an option: -s SECTIONS.
-
-To calculate the mininim number of flips required, note that we
-can calculate the number of flips for each position independently;
-that is, flipping a bit at position $i doesn't influence how the
-number of flips required for position $j, if $i != $j.
-
-For each position $i, we either need to flip all the 0s to 1s,
-or all the 1s to 0s. To minimize the number of flips, we count
-the number of 0s in each position, and compare that with the
-number of 1s in that position. Then we take the minimum of 0s
-and 1s, and sum this for all positions.
-
-There is no need to split the input string into chunks,
-we can leave it as is. The $i-th character of the $j-th section
-is as position $j * $s_len + $i, where $s_len is the length
-of a section.
-
### Examples
#### Example 1
~~~~
@@ -85,6 +65,26 @@ Binary Substrings:
"0111": 2 flips to make it "1011"
~~~~
+### Notes
+We will be reading the strings from STDIN. The number of sections
+will be passed in as an option: -s SECTIONS.
+
+To calculate the mininim number of flips required, note that we
+can calculate the number of flips for each position independently;
+that is, flipping a bit at position $i doesn't influence how the
+number of flips required for position $j, if $i != $j.
+
+For each position $i, we either need to flip all the 0s to 1s,
+or all the 1s to 0s. To minimize the number of flips, we count
+the number of 0s in each position, and compare that with the
+number of 1s in that position. Then we take the minimum of 0s
+and 1s, and sum this for all positions.
+
+There is no need to split the input string into chunks,
+we can leave it as is. The $i-th character of the $j-th section
+is as position $j * $s_len + $i, where $s_len is the length
+of a section.
+
### Solutions
* [AWK](awk/ch-2.awk)
* [C](c/ch-2.c)