Draco
October 9, 2016, 2:22am
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
Comter
October 9, 2016, 2:28am
2
<?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.
10 FOR X=10 TO 1 STEP -1: PRINT X;", ";: NEXT
2 Likes
Draco
October 9, 2016, 3:20am
4
How about …
<?php
$a = 10;
while($a >= 1) {
print $a."\n";
$a = floor($a * 0.99);
}
?>
Draco
October 9, 2016, 3:43am
6
zmetzing:
a90a69ffc90118d0f9
Ok… you got me curious … how do I run that @zmetzing ? .
Draco
October 9, 2016, 4:01am
8
Very good and clever … I’m a bit rusty but this brings me back
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
Draco
October 9, 2016, 4:16am
9
This one does not really count … or does it?
31300a390a380a370a360a350a340a330a320a31
Bill
October 9, 2016, 1:07pm
10
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
Draco
October 9, 2016, 7:59pm
11
here is one for php programmers to figure out …
<?php
while($a-=print(isset($a)?$a:$a=ord("\n"))."\n");
?>
Draco
October 9, 2016, 8:07pm
12
@denzuko … @alanlu … do you have a submission for this topic?
IntStream.range(0, 10).map(i → 10 - i);
1 Like
denzuko
October 10, 2016, 3:07am
14
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
denzuko
October 10, 2016, 3:08am
15
that looks like byte code to me
1 Like
Draco
October 10, 2016, 3:42am
17
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
denzuko
October 10, 2016, 4:59am
18
Because you asked for it:
+++++ +++++[.-]
1 Like
uint8_t n = 10;
while (n > 1)
{
n = round(rand()*(n-1)+1);
printf(n);
}
Bill
October 10, 2016, 5:04am
20
X
IX
VIII
VII
VI
V
IV
III
II
I
Now is this body more descriptive, discourse?