Skip to main content
3 of 3
revised program and summarized changes
Kasran
  • 691
  • 5
  • 6

Befunge-93, 268 260 256 (grid size: 72x6=432)

#v"K">:!#@_v>$"enin">,,,,::-" rof emit a erew sderdnuh neet">:#,_$::!!-#
, ,,,"The "<|\!\%-"\^"::%-" #":-!!:
   -"#-"-::$_ "hgie"^v1"two-thousands are a time to run"
$_$  "nuf"v"rum"
v1-"##",,,<      >:#,_"moorssalc dezilivic a"1
_# < ^,,\-"AK."$_,#!:

This is my first time golfing, so I figured I'd try a language that hadn't already been done for this problem, since I wouldn't be adding anything otherwise. Since it's Befunge-93 compatible (fits inside an 80x25 grid and uses only Befunge-93 instructions), it should work in Befunge-98 too. Just in case, I also avoided having the pointer pass over any non-instruction characters other than space. I couldn't remember whether the specification actually defined those characters as no-ops, and I'll be having no nasal demons in MY code.

You can't really ungolf Befunge code. The key thing to note here is that Befunge pushes characters to the stack as their ASCII values, making it relatively simple to refer to numbers without literally referring to them. The "K" in the top left is 75, referring to the number of repetitions times the number of "the" clauses per repetition; I use modulus and some other craftiness on (copies of) this number to determine which path to take through the printing on each go-around. ::- is a nice idiom for zero, useful for zero-terminating strings; I use it twice here.

On occasion the pointer needs to pass through a place where I'm defining a string, hence the specific choices of characters used to get certain numbers at some points.

The nice thing about a lot of Befunge interpreters is that you can watch the pointer dart around the grid, as well as see what values are in the stack. That way you can step through and see how the program works yourself, more or less! I'd recommend using http://befungius.aurlien.net/ if you don't have your own preferred Befunge interpreter.

This can probably be pared down a bit (or a lot) more. Please give me feedback! If I need to provide a better explanation, someone let me know; I'm new to this.

Edit - shaved off a few bytes by getting rid of the unnecessary redirect to the last row when the program terminates (just putting the @ where the ^ used to be).

Another edit - shaved off some more bytes in various places, mostly with trickery. (Also added the grid size, as seems to be the trend with Befunge answers.)

Kasran
  • 691
  • 5
  • 6