23
4
Recently, someone proposed more stringent limits for Python's default line length:
Clearly, no program should ever use more than 80 characters per line, for a whole host of reasons. First and foremost, for readability and maintainability, it is important to have a solid standard, so we can adjust the width of our text editors appropriately. As a secondary benefit, code can easily be transferred onto media that may have restrictions, and where adding line-breaks can be distracting, like print pages for review in a meeting, or punch cards.
But is 80 characters too high? Some suggest 79, or even as low as 75, to allow for an 80 character wide terminal to fit the code with a few columns devoted to line numbers. Clearly, ultimately, lower is better, as lower limits allow for the code to be used in more situations without reformatting.
Your goal is to find and demonstrate the minimum line length required by Your Favorite Language by writing a FizzBuzz variant with the fewest number of characters in any line.
Input
An integer, n, via any desired method.
Output
Print the numbers from 1 to n, (n ≥ 1, n ∈ ℤ) separated by line breaks, except:
- for multiples of 3 print "Apple"
- for multiples of 5 print "Pie"
- for multiples of both 3 and 5 print "ApplePie"
Scoring
The maximum line length in bytes, not including the line break (Cr, CrLf, Lf, or other system standard break, specify, as desired), and the total code length in bytes as a tiebreaker.
Rules
All line breaks must be meaningful. Line breaks that can be removed and adjacent lines directly concatenated without an impact on the output, must be removed.
An ambiguity we've found in the rule about linebreaks: if the program breaks upon removing one linebreak, but unbreaks upon removing additional linebreaks (i.e. removing any single linebreak breaks the program, but removing a combination of linebreaks can leave it unchanged), is that a valid answer? This came up in Lenguage, but it's probably also relevant in Retina (which cares about whether the program has an even or odd number of lines). – None – 2017-06-02T22:49:00.820
2On the newline restriction, if removing a specific group of newlines causes it to work but removing any single newline causes it to fail, must the newlines be removed? They are syntactically important is just that removing some of them cancels out their importance. – Post Rock Garf Hunter – 2017-06-02T22:56:31.940
3Not sure how I feel about the "meaningful" newlines rule. When it comes to legal syntax, a wide majority of programming languages don't care about newlines and will let you write the entire program on a single line - just take a look at most of the code-golf solutions here :-P – nderscore – 2017-06-02T23:37:22.263
@CalculatorFeline That must be a mistake. – Ørjan Johansen – 2017-06-02T23:46:10.723
1Why change it to Apple Pie instead of the standard – Rohan Jhunjhunwala – 2017-06-03T02:21:51.003
5@RohanJhunjhunwala To prevent using builtin FizzBuzz commands. – Ørjan Johansen – 2017-06-03T02:43:05.040
I take it that these rules require C-based programs to be written on one line since whitespace is not significant? – None – 2017-06-03T17:02:46.040
2+1 This is actually a really good idea for a code golf challenge! The small number of characters per line does seem impractical though I still love it though – George Willcox – 2017-06-03T18:07:42.850
1@Hosch250 I have interpreted the concatenation as being "with no space between", so you can still have newlines between tokens that would fuse together into one, and even without that interpretation e.g. after to-end-of-line comment markers. – Ørjan Johansen – 2017-06-04T01:19:46.563
@ais523 the rule is meant to prevent inserting linebreaks everywhere possible vs everywhere necessary, where that then prompts abuse of the grammar to make them necessary. Rules-wise, remove the first line break, concatenating the adjacent lines. If it produces the same output, it is deemed removable, if not, it isn't. Repeat down the length of the program. – Nick T – 2017-06-04T23:18:43.170
Is
n
guaranteed to be positive or do we need to handle 0 as well? – 12Me21 – 2018-02-13T19:19:10.363@12Me21 updated: "1 to n, (n ≥ 1, n ∈ ℤ)" – Nick T – 2018-02-13T20:21:51.393
All line breaks must be meaningful. Line breaks that can be removed and adjacent lines directly concatenated without an impact on the output, must be removed.
for real life line breaks are usually not meaningful, though (int fffff(|type1 value1,|type2 value2){
) – l4m2 – 2018-07-06T12:40:22.973