This site makes extensive use of JavaScript.
Please enable JavaScript in your browser.
Classic Theme
Thottbot Theme
Drop by and say hi! (Recycle Bin)
Post Reply
Return to board index
Post by
Lombax
Hai RB.
Post by
Interest
Hai RB.
Oh hai there.
Post by
Adamsm
Oh gods, this is going to be fun!
Post by
Patty
There's a spoiler box? Something else for me to get confused about on the website, regrettably. D:
Post by
Adamsm
Heh yeah...only problem is that it's going to split up posts for the spoiling lol. Wish it could be set up like tvtropes.
Post by
Interest
Oh gods, this is going to be fun!
Ooo they added spoiler tags.
YES.
Post by
Adamsm
More people need to poke their noses into Feedback lol.
Post by
Toldry
GUYS GUYS
I was bored and made a program in Java that creates a 2-dimentional array that represents a sierpinski carpet of d iterations
Here's the code:
public class sierpinski_carpet
{
public static void main(String;
for(int i=0;i<carpet.length;i++)
for(int j=0;j<carpet.length;j++)
carpet=1;
sierpinskize(carpet,d,0,0);
return carpet;
}
public static void sierpinskize(intcarpet,int d,int x,int y)
{
if(d==0)return;
for(int i=x;i<x+(int)Math.pow(3,d);i+=(int)Math.pow(3,d-1))
for(int j=y;j<y+(int)Math.pow(3,d);j+=(int)Math.pow(3,d-1))
{
if(i==x+(int)Math.pow(3,d-1)&&j==y+(int)Math.pow(3,d-1))
clear_area(carpet,d-1,i,j);
else
sierpinskize(carpet,d-1,i,j);
}
}
public static void clear_area(intcarpet,int d,int x,int y)
{
for(int i=x;i<x+(int)Math.pow(3,d);i++)
{
for(int j=y;j<y+(int)Math.pow(3,d);j++)
{
carpet=0;
}
}
}
public static void print_carpet(intcarpet)
{
boolean v;
for(int i=0;i<carpet.length;i++)
{
for(int j=0;j<carpet.length;j++)
{
v=carpet==1;
System.out.print(v?"*":" ");
}
System.out.println();
}
}
}
And here's the result for d=4
*********************************************************************************
* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** *
*********************************************************************************
*** ****** ****** ****** ****** ****** ****** ****** ****** ***
* * * ** * * ** * * ** * * ** * * ** * * ** * * ** * * ** * * *
*** ****** ****** ****** ****** ****** ****** ****** ****** ***
*********************************************************************************
* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** *
*********************************************************************************
********* ****************** ****************** *********
* ** ** * * ** ** ** ** ** * * ** ** ** ** ** * * ** ** *
********* ****************** ****************** *********
*** *** *** ****** *** *** ****** *** *** ***
* * * * * * * ** * * * * * * ** * * * * * * *
*** *** *** ****** *** *** ****** *** *** ***
********* ****************** ****************** *********
* ** ** * * ** ** ** ** ** * * ** ** ** ** ** * * ** ** *
********* ****************** ****************** *********
*********************************************************************************
* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** *
*********************************************************************************
*** ****** ****** ****** ****** ****** ****** ****** ****** ***
* * * ** * * ** * * ** * * ** * * ** * * ** * * ** * * ** * * *
*** ****** ****** ****** ****** ****** ****** ****** ****** ***
*********************************************************************************
* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** *
*********************************************************************************
*************************** ***************************
* ** ** ** ** ** ** ** ** * * ** ** ** ** ** ** ** ** *
*************************** ***************************
*** ****** ****** *** *** ****** ****** ***
* * * ** * * ** * * * * * * ** * * ** * * *
*** ****** ****** *** *** ****** ****** ***
*************************** ***************************
* ** ** ** ** ** ** ** ** * * ** ** ** ** ** ** ** ** *
*************************** ***************************
********* ********* ********* *********
* ** ** * * ** ** * * ** ** * * ** ** *
********* ********* ********* *********
*** *** *** *** *** *** *** ***
* * * * * * * * * * * * * * * *
*** *** *** *** *** *** *** ***
********* ********* ********* *********
* ** ** * * ** ** * * ** ** * * ** ** *
********* ********* ********* *********
*************************** ***************************
* ** ** ** ** ** ** ** ** * * ** ** ** ** ** ** ** ** *
*************************** ***************************
*** ****** ****** *** *** ****** ****** ***
* * * ** * * ** * * * * * * ** * * ** * * *
*** ****** ****** *** *** ****** ****** ***
*************************** ***************************
* ** ** ** ** ** ** ** ** * * ** ** ** ** ** ** ** ** *
*************************** ***************************
*********************************************************************************
* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** *
*********************************************************************************
*** ****** ****** ****** ****** ****** ****** ****** ****** ***
* * * ** * * ** * * ** * * ** * * ** * * ** * * ** * * ** * * *
*** ****** ****** ****** ****** ****** ****** ****** ****** ***
*********************************************************************************
* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** *
*********************************************************************************
********* ****************** ****************** *********
* ** ** * * ** ** ** ** ** * * ** ** ** ** ** * * ** ** *
********* ****************** ****************** *********
*** *** *** ****** *** *** ****** *** *** ***
* * * * * * * ** * * * * * * ** * * * * * * *
*** *** *** ****** *** *** ****** *** *** ***
********* ****************** ****************** *********
* ** ** * * ** ** ** ** ** * * ** ** ** ** ** * * ** ** *
********* ****************** ****************** *********
*********************************************************************************
* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** *
*********************************************************************************
*** ****** ****** ****** ****** ****** ****** ****** ****** ***
* * * ** * * ** * * ** * * ** * * ** * * ** * * ** * * ** * * *
*** ****** ****** ****** ****** ****** ****** ****** ****** ***
*********************************************************************************
* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** *
*********************************************************************************
WATCHA THINK?
Post by
Monday
Nice.
Also, ohaithar Toldry.
Post by
Toldry
Hello, Blacksmith.
Post by
Toldry
Also, it only took me 1 hour and 2 minutes to create that code
Post by
Skreeran
Wut?
Post by
606231
This post was from a user who has deleted their account.
Post by
Monday
One question; How the #$%^ do you do that stuff? I sorta wanna know =/
Also Quoted for refrence.
l2code brah.
Post by
Interest
Toldry: Looks cool.
Post by
606231
This post was from a user who has deleted their account.
Post by
606231
This post was from a user who has deleted their account.
Post by
Monday
Cya Bin.
Adios. Can't save it cos it goes over 75k Word Limit
=/
One question; How the #$%^ do you do that stuff? I sorta wanna know =/
Also Quoted for refrence.
l2code brah.
But I do want to learn.
=/
Get some books and go to classes then. I can guarantee your local Barnes & Noble has a section on coding (assuming you have one near you ofc).
Post by
Adamsm
Wut?
Fix'd.
Post by
812974
This post was from a user who has deleted their account.
Post Reply
You are not logged in. Please
log in
to post a reply or
register
if you don't already have an account.