Clever or Convoluted Contest: Count from 10 to 1

Here is a quick programming contest. It is judged on having the most clever and/or convoluted solution to the problem.

The problem is this … count backwards from 10 to 1

There are no other rules. You can post your answers here or send me a private message and I will email it to my other account and print it out then type it back in and post your message here.

Good Luck … Winner takes all

<?php
for($i=10; $i>1; $i--) { echo $i . "\n"; }
?>

or

<?php
$tmp_array = array_keys(array_reverse(range(1, 10)));
foreach($tmp_array as $key => $value) { echo $value . "\n"; }
?>

-the purring dork

1 Like

You can put it on one line using MS BASIC on the TRS-80 CoCo. :slight_smile:

10 FOR X=10 TO 1 STEP -1: PRINT X;", ";: NEXT

2 Likes

How about …

<?php
	$a = 10;
	while($a >= 1) {
		print $a."\n";
		$a = floor($a * 0.99);
	}
?>

a90a69ffc90118d0f9

(small error fixed)

2 Likes

Ok… you got me curious … how do I run that @zmetzing ? .

That’s part of the fun. :slight_smile:

2 Likes

Very good and clever … I’m a bit rusty but this brings me back :slight_smile:

I’m not going to give it away in case others want to figure it out. I haven’t tested it but it looks like it should work

This one does not really count … or does it?

31300a390a380a370a360a350a340a330a320a31

	lda	#10
L_002	adc	#$FF
	cmp	#1
	clc
	bne	L_0002

Since we do not apparently have to display it but just count it,

for (int i = 10; --i > 1 ; )
	;

Edit: a couple of fixes

2 Likes

here is one for php programmers to figure out …

<?php while($a-=print(isset($a)?$a:$a=ord("\n"))."\n"); ?>

@denzuko@alanlu … do you have a submission for this topic?

IntStream.range(0, 10).map(i -> 10 - i);

1 Like
name "dz16"
org  100h	; set location counter to 100h

mov ax, 1003h  
mov bx, 00h        
int 10h

mov dl, 0Ah
mov ah, 02h

goto10:
sub dl, 01h
int 021h    
jz exit
loop goto10

exit:
ret

that looks like byte code to me

1 Like

Well … what does it say?

I see many entries that are short … how about some convoluted entries …

What is the slowest way to get from 10 to 1? …

Possible idea hint … I didn’t say you had to stick to whole numbers…
Possible idea hint… There is nothing in the specifications that says it needs to be runnable on a computer

Because you asked for it:
+++++ +++++[.-]

1 Like
uint8_t n = 10;

while (n > 1)
{
  n = round(rand()*(n-1)+1);
  printf(n);
}

X
IX
VIII
VII
VI
V
IV
III
II
I

Now is this body more descriptive, discourse?