943,936 Members | Top Members by Rank

Ad:
You are currently viewing page 7 of this multi-page discussion thread; Jump to the first page
Oct 27th, 2006
0

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

Python
[php]
def counting(i=0):
while i < 11:
print i,
i += 1

counting()
[/php]
Reputation Points: 10
Solved Threads: 3
Newbie Poster
Zonr_0 is offline Offline
16 posts
since Oct 2006
Oct 30th, 2006
0

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

First LUA version:

for i = 1,10 do print(i) end
Last edited by ~s.o.s~; Oct 30th, 2006 at 2:09 pm.
Super Moderator
Featured Poster
Reputation Points: 3233
Solved Threads: 719
Failure as a human
~s.o.s~ is offline Offline
8,871 posts
since Jun 2006
Oct 31st, 2006
0

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

Click to Expand / Collapse  Quote originally posted by Zonr_0 ...
Python
[php]
def counting(i=0):
while i < 11:
print i,
i += 1

counting()
[/php]
slightly shorter way in python

print range(1,11)
pty
Reputation Points: 64
Solved Threads: 39
Posting Pro
pty is offline Offline
530 posts
since Oct 2005
Oct 31st, 2006
0

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

Casio:
for 0[save]a to 10 step 1[enter]
a[print]
next[enter]
I don't know how to put some char's
Last edited by Anonymusius; Oct 31st, 2006 at 1:05 pm.
Reputation Points: 129
Solved Threads: 11
Posting Whiz in Training
Anonymusius is offline Offline
223 posts
since Aug 2006
Oct 31st, 2006
0

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

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...
Reputation Points: 129
Solved Threads: 11
Posting Whiz in Training
Anonymusius is offline Offline
223 posts
since Aug 2006
Nov 6th, 2006
0

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

I definitely will have the shortest
Matlab
1:10
Reputation Points: 10
Solved Threads: 0
Newbie Poster
AnonCSAddict is offline Offline
4 posts
since Nov 2006
Nov 6th, 2006
0

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

how about a competition for most obfuscated
C++
#include <iostream>

int main()
{
    int _0(0);
    while("\"#$%&\'()*+,"[_0]!=',')
        std::cout<<static_cast<int>("\"#$%&\'()*+"[_0++]-'!')<<" ";
}
Last edited by Bench; Nov 6th, 2006 at 3:01 pm. Reason: Grr! The [CODE=CPP] tag filters out escape sequences!
Reputation Points: 307
Solved Threads: 62
Posting Pro
Bench is offline Offline
565 posts
since Feb 2006
Nov 14th, 2006
0

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

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;
}
Reputation Points: 10
Solved Threads: 0
Newbie Poster
webspy is offline Offline
13 posts
since Sep 2006
Nov 14th, 2006
0

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

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;
}
Moderator
Featured Poster
Reputation Points: 4142
Solved Threads: 394
Industrious Poster
Nick Evan is offline Offline
4,132 posts
since Oct 2006
Nov 14th, 2006
0

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

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.
Last edited by MattEvans; Nov 14th, 2006 at 10:21 pm.
Moderator
Featured Poster
Reputation Points: 522
Solved Threads: 64
Veteran Poster
MattEvans is offline Offline
1,091 posts
since Jul 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in IT Professionals' Lounge Forum Timeline: Merrrrryyyyy Christmas!
Next Thread in IT Professionals' Lounge Forum Timeline: creating skins





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC