Clever or Convoluted Contest: Count from 10 to 1










.

2 Likes

[code]
IDENTIFICATION DIVISION.
PROGRAM-ID. CONVOLUTED.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 COUNT PIC 9 VALUE 0.

PROCEDURE DIVISION.
COUNT-DOWN.
PERFORM DO-COUNT VARYING COUNT FROM 10 BY -1 UNTIL COUNT=1
STOP RUN.

DO-COUNT.
DISPLAY COUNT.[/code]

2 Likes

ok ok… here.

First make one of these http://www.instructables.com/id/Functional-Soldered-Abacus-Pinky-Ring/step4/Mathematicians-do-it-with-more-precision/

Then move the beads to the 10’s place
Count to 10
Decrement by one bead
Repeat until no beads are left to move

Dangit. That last monkey just had to do it, too! (He was supposed to be the One left… :wink: )

3 Likes

I am starting to learn Python. This was in the book and I feel compelled to post it.

for i in range(10, 0, -1):
    print(i)

Edit: fixed dropped character.

1 Like

I’m wanting to learn python as well … isn’t there suppose to be a comma after 0 and before -1 ?

Yes. Thanks.


Here is an answer to the problem: 10

Hint: look through the edits

2 Likes

Overkill, golang plus recursion:

package main

import "fmt"

func recurseup(i int) {
  if (i < 10) {
    recurseup(i + 1)
  }
  fmt.Println(i)
}

func main() {
  recurseup(1);
}
1 Like

Nice one … I like the idea of using recursion … I don’t know golang but I can see how it works …

1 Like

Thanks!, Golang is pretty fun, it is like C, functional, but with really good parallel processing and IPC, and you can learn the entire language easily online : https://tour.golang.org/welcome/1 https://gobyexample.com/

1 Like

Going for convoluted in Java, excuse bad threading and error handling :slight_smile:

public class CountDown {
    
    public static void main (String[] args) {
        CountDown countDown = new CountDown();
        countDown.countAllTheThings();
    }
     
    public void countAllTheThings() {
          for (int i = 1; i  <= 10; i++) {
            CountWorker cw = new CountWorker(i);
            cw.start();
        }      
    }
    
    public class CountWorker extends Thread {
        private final int value;
                
        public CountWorker(int value) {
            this.value = value;
        }
        
        @Override
        public void run() {
            try  {
                Thread.sleep((long) (15 - this.value) * 1000 );
                System.out.println(value);
            } catch (InterruptedException ex) {
                System.out.println("Well this didn't work :(");
            }
        }
    }
}
1 Like

Okay, last one

+++++++++++++++++++++++++++++++++++++++++++++++++.>++++++++++++++++++++++++++++++++++++++++++++++++.----.<++++++++.>>++++++++[<.<-.>>-]
1 Like

haha … is that …

http://www.muppetlabs.com/~breadbox/bf/

Speaking of convoluted programming languages… here is a list

http://www.topdesignmag.com/top-13-most-absurd-programming-languages/

LOL, yeah, with ascii output :slight_smile: goo.gl/DF1shG <- naughty words in expanded URLS, I think someone already did BF tho, wanted to do it with ascii

1 Like

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

Totally beat me to it.

Okay, seriously last one… having way too much fun

10 CLS
20 LET I=10
30 PRINT I
40 LET I = I -1
50 IF I > 0 THEN GOTO 30
1 Like

I hope someone tries to figure how this one works … because it does count and print a list of 10 to 1
:smiley:

Here it is online …

I’m going to have to test this one … hmm

I like it, very slick, took me a sec to figure out where you were getting your initial conditions from.

1 Like