## One Million Hits

### March 29, 2013

Programming Praxis passed one-million all-time hits yesterday at 9:22pm GMT (that’s 4:22pm CDT where I live). My thanks to all of you for making this happen.

Your task is to write a program that outputs the number 1000000; be as fun and creative as you can. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.

Pages: 1 2

print bin(64)[2:]

[...] today’s Programming Praxis exercise, our goal is ro print the number 1000000 in a creative way. Let’s [...]

My Haskell solution (see http://bonsaicode.wordpress.com/2013/03/29/programming-praxis-one-million-hits/ for a version with comments):

This is too simple, but I needed it for real earlier today.

I just wasn’t sure of counting the zeroes, and I don’t know if

the system understands anything but a string of digits, so:

./configure \

--enable-single-host \

--enable-c-opt \

--enable-multiple-versions \

--enable-shared \

CFLAGS=-D___FORCE_MAX_HEAP=$(echo 1,000,000 | tr -d ,)

Forth program inspired by [1].

The number one million represented using postfix notation with only the number one, addition and multiplication.

[1] Zeroless Arithmetic: Representing Integers ONLY using ONE,

Edinah K. Gnang and Doron Zeilberger,

http://www.math.rutgers.edu/~zeilberg/mamarim/mamarimhtml/arif.html

Postscript program using the number one, addition and exponentiation.

This one I wrote just for fun: a random binary digit for each letter

of “million”, freely instantiated but constrained to match. Cheers.

(define (digit) (random-integer 2))

(define (fold op o args)

(if (null? args) o

(fold op (op o (car args)) (cdr args))))

(fold (lambda (o arg)

(do ((x (digit) (digit))

(y (digit) (digit)))

((o x y) (write x) <))) >

(string->list "million"))

`(newline)`

Thanks Dan (and others). I’m beginning to think this Internet thing really works.

By the way, WordPress doesn’t count what it calls syndicated views, which are things like RSS feeds where people read the blog without actually generating a hit. Most exercises generate two or three times as many syndicated views as hits, so the actual count is higher. Unfortunately WordPress doesn’t give a total on syndicated views.