Jump to content

One to hundred in 100 different ways

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
235 replies to this topic

#1
v0id

v0id

    Retired

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,936 posts
This is a programming-related game. The goal is to reach 100 ways of printing the numbers one to hundred. There's no limitations, only your imagination. You can use whatever language you want, and the size of the code can be as big as you want it to be.

Note that we're not following the numbers of the posts in the thread. If you're planning to submit a solution comment it with the number of the code, and if you simply want to comment on the thread or someone's code, leave the number of the code out.

And one more thing. You cannot post two solutions twice in a row. You'll need to wait for someone else to submit their solution in between.

Edited by v0id, 26 April 2008 - 10:51 AM.


#2
v0id

v0id

    Retired

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,936 posts
Let me start with the first one, in this case, in Python.

#001
for number in range(1, 101):
    print number


#3
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
So basically if we comment we don't include the number? or we are not allowed to make a comment unless we submit some code?
Anyways here is mine C#

#002
for(int i=1;i<=100;i++)
			{
				Console.WriteLine(i);
			}
			Console.ReadLine();


#4
v0id

v0id

    Retired

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,936 posts
Well, I see my description was rather confusing. You can comment in this thread without submitting a solution. Just leave the number of the code out. Like I do now.

Edited by v0id, 26 April 2008 - 10:27 AM.


#5
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
Great :)
Waiting for some other code... so I can submit another... and another... and another :) (Unless I forget them)

#6
chili5

chili5

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 7,247 posts
#003:

1 to 100 in javascript
<html>
<head>
<title></title>
<style type="text/css">
#header {
font-weight: bold;
}
</style>
</head>
<body>
<center><table border="1" cellpadding="0" cellspacing="0">
<tr>
<td><span id="header">Odd numbers</span></td>
<td><span id="header">Even numbers</span></td>
</tr>
<tr>
<td>
<script language="javascript">
for (t=1; t<=100; t+=2) {
document.write("<span style=\"background-color:red;\">" + t + "</span>");
document.write("<br>");
}
</script>
</td>
<td>
<script language="javascript">
for (i=0; i<=100; i+=2) {
document.write("<span style=\"background-color:gray;\">" + i + "</span>");
document.write("<br>");
}
</script>
</td>
</tr>
</table>
</center>
</body>
</html>


#7
R-G

R-G

    Programmer

  • Members
  • PipPipPipPip
  • 142 posts
Well, I'll follow with the fourth model, in this case with the solution of the computer programming language C++.

[highlight="C++"]
using namespace std;

int main()
{
int Numbers;

for(Numbers=1; Numbers<=100; Numbers++)
{
cout << Numbers;
}
}[/highlight]
Like an angel without a sense of mercy.

#8
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Forgot your number R-G. :)

005

Java using While:


int count = 0;

while (count < 100) {

  System.out.println(count);

  count = count + 1;	

}



#9
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Excellent idea v0id! +Rep given.

#10
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
#006

While using C++ [I'd like to see someone top this method]

cout << "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59\n60\n61\n62\n63\n64\n65\n66\n67\n68\n69\n70\n71\n72\n73\n74\n75\n76\n77\n78\n79\n80\n81\n82\n83\n84\n85\n86\n87\n88\n89\n90\n91\n92\n93\n94\n95\n96\n97\n98\n99\n100";


#11
chili5

chili5

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 7,247 posts
Wow john, that was rather interesting. :D

#007:

<?php
$i=0;
while($i<=100) 
{
echo $i . "<br />";
$i = $i + 1;
}
?>


#12
R-G

R-G

    Programmer

  • Members
  • PipPipPipPip
  • 142 posts
Yes, John, I think I can top it with your style in the eighth solution, while using the computer programming language Assembly.

[highlight="ASM"]
include 'win32ax.inc'

.code

start:
invoke MessageBox,HWND_DESKTOP,"1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100","Number Problem Solution",MB_OK
invoke ExitProcess,0

.end start[/highlight]
Like an angel without a sense of mercy.