Re: 500 ways to print [1..10]! 80 80

Python

def counting(i=0):
    while i < 11:         
        print i,
        i += 1
 
counting()
Re: 500 ways to print [1..10]! 80 80

First LUA version: for i = 1,10 do print(i) end

Re: 500 ways to print [1..10]! 80 80

Python

def counting(i=0):
    while i < 11:         
        print i,
        i += 1
 
counting()

slightly shorter way in python

print range(1,11)
Re: 500 ways to print [1..10]! 80 80

Casio:

for 0[save]a to 10 step 1[enter]
a[print]
next[enter]

I don't know how to put some char's :S

Re: 500 ways to print [1..10]! 80 80

You said to count the number of ways by post count, so that's why I do this one in an new post.

Basic:

10 L = 1
20 PRINT L
30 L = L + 1
40 IF L <= 10 then 20
50 END

I did some basic on my commodore, but my parent's get pissed off every time I take it down to the television, so...

Re: 500 ways to print [1..10]! 80 80

I definitely will have the shortest
Matlab 1:10

Re: 500 ways to print [1..10]! 80 80

how about a competition for most obfuscated :)
C++

#include <iostream>

int main()
{
    int _0(0);
    while("\"#$%&\'()*+,"[_0]!=',')
        std::cout<<static_cast<int>("\"#$%&\'()*+"[_0++]-'!')<<" ";
}
Re: 500 ways to print [1..10]! 80 80

C++

#include <iostream>

int main()
{
    for(int i = 1; i <= 10; std::cout << i++);
    return 0;
}
#include <iostream>

int main()
{
    int i = 1;
    while(i <= 10 ? std::cout << i++: false);
    return 0;
}
Re: 500 ways to print [1..10]! 80 80

How about one with a recursive function?

#include <stdio.h>
 
int count(int);
 
int main()
{
    return count(0);
}
 
int count(int iTeller)
{
    iTeller++;
    printf("%d ", iTeller);
    if (iTeller < 10)
        count(iTeller);
    else 
        return 0;
}
Re: 500 ways to print [1..10]! 80 80

how about a function that could, potentially, print 1...10 =P

(in Perl)
for(my($i) = 2; $i <= 11; $i++){
  print int(rand()*$i);
  print " ";
};

very silly.

Re: 500 ways to print [1..10]! 80 80

Another Perl version:

s/./'print "'.(-64+ord $&)."\n\""/gee for $x = "ABCDEFGHIJ"

"print [1..10]" you say? Funny you should mention that!

A Haskell version:

main = print [1..10]
Re: 500 ways to print [1..10]! 80 80
#include <iostream.h>
#include <stdlib.h>

void printNumbers();

const NUMBERS = 10;

void main()
{
    printNumbers();
    system("pause");
}

void printNumbers()
{
   int numberArray[NUMBERS];

    for(int i = 0; i < NUMBERS; i++)
   {
       numberArray[i] = i;
   }

   for(int i = 0; i < NUMBERS; i++)
   {
       cout << (numberArray[i] + 1) << endl;
   }
}
Re: 500 ways to print [1..10]! 80 80

That's funny. Your version prints

1
2
3
4
5
6
7
8
9
10
-bash: pause: command not found
Re: 500 ways to print [1..10]! 80 80

Thats because I think you usign *nix while the system("pause") is windows only (methinks).

Re: 500 ways to print [1..10]! 80 80

Not Asm, Basic, C but --> D

import std.stdio;

void main(char[][] args)
{
    writefln("1 2 3 4 5 6 7 8 9 10");

}

And void main() is allowed in D ;)

Regards Niek

Re: 500 ways to print [1..10]! 80 80

Very simple one in brainfuck:

+++++++++++++++++++++++++++++++++++++++++++++++++.+.+.+.+.+.+.+.+.--------.-.

It really doesn't get any simpler...

Niek

[edit] hmmm... that's not the name of the language... ;) [/edit]

Re: 500 ways to print [1..10]! 80 80

In AWK (shell script) (not exactly a language but..)

awk '{ for(i=1;i<11;i++) {print i} }'
Re: 500 ways to print [1..10]! 80 80

Very simple one in brainfuck:

+++++++++++++++++++++++++++++++++++++++++++++++++.+.+.+.+.+.+.+.+.--------.-.

It really doesn't get any simpler...

Sorry, it does :)

++++[>++++[>+++>+++<<-]<-]>>+.+.+.+.+.+.+.+.+.>+.-.
Re: 500 ways to print [1..10]! 80 80

Sorry, it does :)

I meant for the programmer, your program uses loops which I don't really master in Brainfck.

Now for something in Cow

MoO MoO MoO MoO MOO moO MoO MoO MoO MOO moO MoO MoO MoO moO MoO MoO MoO mOo mOo MOo moo mOo MOo moo  moO moO MoO OOM MoO OOM MoO OOM MoO OOM MoO OOM MoO OOM MoO OOM MoO OOM MoO OOM moO MoO OOM MOo OOM

That sucked, it's even more confusing then BF...

Niek

Re: 500 ways to print [1..10]! 80 80

Something in English;

Print 1...10
Re: 500 ways to print [1..10]! 80 80

Lets sort in Common Lisp (Lispworks interpreter):

>> (defun main () (format t "~s" (sort '(10 4 3 2 5 9 8 7 1 6) #'<)) )
 
>> (main)
Re: 500 ways to print [1..10]! 80 80
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace Count1to10
{
    /// <summary>
    /// Summary description for Form1.
    /// </summary>
    public class formCounter : System.Windows.Forms.Form
    {
        private System.Windows.Forms.Button btnGo;
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.Container components = null;

        public formCounter()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose( bool disposing )
        {
            if( disposing )
            {
                if (components != null) 
                {
                    components.Dispose();
                }
            }
            base.Dispose( disposing );
        }

        #region Windows Form Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.btnGo = new System.Windows.Forms.Button();
            this.SuspendLayout();
            // 
            // btnGo
            // 
            this.btnGo.Location = new System.Drawing.Point(112, 112);
            this.btnGo.Name = "btnGo";
            this.btnGo.TabIndex = 0;
            this.btnGo.Text = "GO!";
            this.btnGo.Click += new System.EventHandler(this.btnGo_Click);
            // 
            // formCounter
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(292, 266);
            this.Controls.Add(this.btnGo);
            this.Name = "formCounter";
            this.Text = "Counter";
            this.ResumeLayout(false);

        }
        #endregion

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main() 
        {
            Application.Run(new formCounter());
        }

        private void btnGo_Click(object sender, System.EventArgs e)
        {
            for (int i=1; i < 11; i++)
            {
                MessageBox.Show(i.ToString());
            }
        }
    }
}

Nice...

commented: Daj nemoj zajebavati da si iz Kikinde! Pa ja sam ziveo preko galacke +4
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.