create account

Computation Contest #8 Results and Solution by quantumdeveloper

View this thread on: hive.blogpeakd.comecency.com
· @quantumdeveloper ·
$0.21
Computation Contest #8 Results and Solution
## Solution
The problem of this contest was to simply draw a fractal of your choice.
I chose to draw this fractal as an example:
![](https://steemitimages.com/p/NTy4GV6ooFRkjTArCrebYc2WCCmX2KY4SfTbUDpHWg6ZYJGkq8E4SrzkN9Wb6bJ6edcAZLw2LnPmaggmW4rxafEMHM5c8ppCQiW5Xgm5ZA6VUbWgxnL39NqcHBLhkgZbdUSrH5QgJEy7SvTzcWSjWCWyQzUqmF3EG9YzbohY?format=match&mode=fit&width=640)
This fractal was generated with the [chaos game](https://en.wikipedia.org/wiki/Chaos_game) algorithm.
The chaos game works on a few simple rules:

##### Start with a set of n points in a 2d plane.
##### Choose a random point x on the plane.
##### Now in a loop make:
1. Choose one of the n points randomly
2. Move x half the distance towards the chosen point
3. Paint a dot at x(Preferably with low alpha, to make the image look smoother).

In the example shown above I used 5 points:
The 4 corners of a rectangle and the exact center.

Here is my implementation:
```
import javax.swing.JFrame;
import java.awt.Color;
import java.awt.Graphics;

public class fractal extends JFrame {
	double x, y;
	int len;
	double [] xP;
	double [] yP;
	
	public fractal() {
		// Initialize JFrame:
		super("Fractal");
		this.setSize(1800, 1200);
		this.setVisible(true);
		this.setResizable(false);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		// Initialize points:
		// Here 4 corners of a rectangle and the center:
		xP = new double[]{100, 100, 1700, 1700, 900};
		yP = new double[]{100, 1100, 1100, 100, 600};
		len = 5;
		// Start at one of the corners:
		x = xP[0];
		y = yP[0];
	}
	int n = 0;
	@Override
	public void paint(Graphics g) {
		// Make sure the background really gets drawn black:
		if(n <= 100) {
			g.setColor(Color.BLACK);
			g.fillRect(0, 0, 1800, 1200);
			n++;
		}
		// Use some color different to the background with low alpha value to draw the current position of the dot:
		g.setColor(new Color(255, 255, 255, 2));
		g.drawRect((int)x, (int)y, 1, 1);
		// Choose a new point:
		int z = (int)(len * Math.random());
		// Move the point half the distance to that point:
		x -= (x-xP[z])/2;
		y -= (y-yP[z])/2;
	}
	public static void main(String [] args) {
		fractal f = new fractal();
		while(true) {
			f.repaint();
		}
	}
}
```

I wonder why only one participant showed up, although it wasn't that hard.

*↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓*
### List of participants with their entries:
Name | Solution found | Comment
 - | - | -
@enderrag | ![](https://steemitimages.com/p/D5zH9SyxCKd9GJ4T6rkBdeqZw1coQAaQyCUzUF4FozBvW8Xj3yYZ7TKHn6hm8XbcabrV7Wj8LrypigV8sKrJ67sQQE2mdrVdSc6pa5RmfPhh6k1zzMzoFgKv4MxPA8dfcdVLMt?format=match&mode=fit&width=640) | Looks good, although I don't like that the edges are cut.

*↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓*

## Winners:
Congratulations @enderrag, you won 2 SBI!

*↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓*
### The next contest starts soon. Don't miss it!
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
👎  
properties (23)
authorquantumdeveloper
permlinkcomputation-contest-8-results-and-solution
categoryprogramming
json_metadata{"tags":["programming","puzzle","contest","steembasicincome","stem","math","steemstem","steemiteducation","palnet","sbi"],"users":["enderrag"],"image":["https://steemitimages.com/p/NTy4GV6ooFRkjTArCrebYc2WCCmX2KY4SfTbUDpHWg6ZYJGkq8E4SrzkN9Wb6bJ6edcAZLw2LnPmaggmW4rxafEMHM5c8ppCQiW5Xgm5ZA6VUbWgxnL39NqcHBLhkgZbdUSrH5QgJEy7SvTzcWSjWCWyQzUqmF3EG9YzbohY?format=match&mode=fit&width=640","https://steemitimages.com/p/D5zH9SyxCKd9GJ4T6rkBdeqZw1coQAaQyCUzUF4FozBvW8Xj3yYZ7TKHn6hm8XbcabrV7Wj8LrypigV8sKrJ67sQQE2mdrVdSc6pa5RmfPhh6k1zzMzoFgKv4MxPA8dfcdVLMt?format=match&mode=fit&width=640"],"links":["https://en.wikipedia.org/wiki/Chaos_game"],"app":"palnet/0.1","format":"markdown","canonical_url":"undefined/@quantumdeveloper/computation-contest-8-results-and-solution"}
created2019-12-30 23:30:57
last_update2019-12-30 23:30:57
depth0
children4
last_payout2020-01-06 23:30:57
cashout_time1969-12-31 23:59:59
total_payout_value0.109 HBD
curator_payout_value0.105 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length2,911
author_reputation4,456,611,502,865
root_title"Computation Contest #8 Results and Solution"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id93,879,591
net_rshares1,189,231,787,216
author_curate_reward""
vote details (31)
@mapxv ·
A member bonus $trendotoken tip, and !trendovoter, for @quantumdeveloper from MAPXV! These bonuses are for members, selected at random, and last for a few days.

Also consider our [MAPR fund](https://steem-engine.com/?p=market&t=MAPR) and [MAXUV](https://steem-engine.com/?p=market&t=MAXUV) vote bonds too.
MAP Steem Fintech: growing your STEEM without SP.
properties (22)
authormapxv
permlinkre-computation-contest-8-results-and-solution-20191230t233845z
categoryprogramming
json_metadata"{"app": "rewarding/0.1.5"}"
created2019-12-30 23:38:48
last_update2019-12-30 23:38:48
depth1
children1
last_payout2020-01-06 23:38:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length361
author_reputation9,809,854,088,378
root_title"Computation Contest #8 Results and Solution"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id93,879,773
net_rshares0
@trendotoken ·
Congratulations @mapxv, you successfuly trended the post shared by @quantumdeveloper!
@quantumdeveloper will receive <b>4.72489200</b> [TRDO](https://steem-engine.com/?p=history&t=TRDO) & @mapxv will get <b>3.14992800</b> [TRDO](https://steem-engine.com/?p=history&t=TRDO) curation in 3 Days from Post Created Date!

<b>"Call [TRDO](https://steem-engine.com/?p=history&t=TRDO), Your Comment Worth Something!"</b>
---
<sup>To view or trade TRDO go to [steem-engine.com](https://steem-engine.com/?p=market&t=TRDO)
Join [TRDO Discord Channel](https://discord.gg/wySP8T9) or Join [TRDO Web Site](http://www.trendotoken.info/)</sup>
properties (22)
authortrendotoken
permlinkre-mapxv-re-computation-contest-8-results-and-solution-20191230t233845z-20191230t233859875z
categoryprogramming
json_metadata{"tags":["comments-scot","trendo-bot"],"app":"comments-scot/1.1","format":"markdown"}
created2019-12-30 23:39:00
last_update2019-12-30 23:39:00
depth2
children0
last_payout2020-01-06 23:39:00
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length628
author_reputation5,546,209,053,433
root_title"Computation Contest #8 Results and Solution"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id93,879,776
net_rshares0
@trendotoken ·
Congratulations @quantumdeveloper, your post successfully recieved <b>4.724892</b> [TRDO](https://steem-engine.com/?p=history&t=TRDO) from below listed TRENDO callers:<br>

>	<sup>@mapxv earned : **3.149928** [TRDO](https://steem-engine.com/?p=history&t=TRDO) curation</sup> 

---
<sup>To view or trade TRDO go to [steem-engine.com](https://steem-engine.com/?p=market&t=TRDO)
Join [TRDO Discord Channel](https://discord.gg/wySP8T9) or Join [TRDO Web Site](http://www.trendotoken.info/)</sup>
properties (22)
authortrendotoken
permlinkre-quantumdeveloper-computation-contest-8-results-and-solution-20200102t234524175z
categoryprogramming
json_metadata{"tags":["trdo","trendo-bot"],"app":"comments-scot/1.1","format":"markdown"}
created2020-01-02 23:45:27
last_update2020-01-02 23:45:27
depth1
children0
last_payout2020-01-09 23:45:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length491
author_reputation5,546,209,053,433
root_title"Computation Contest #8 Results and Solution"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id93,966,886
net_rshares0
@trendovoter ·
Congratulations @mapxv, <b>50.57%</b> upvote has been shared with your successful call on the post that shared by @quantumdeveloper!

---
<sup>Support <b>@trendotoken</b> projects by delegating : <b>[100SP](https://beta.steemconnect.com/sign/delegateVestingShares?delegator=YOURUSERNAME&delegatee=trendovoter&vesting_shares=100.000%20SP)</b> , <b>[200SP](https://beta.steemconnect.com/sign/delegateVestingShares?delegator=YOURUSERNAME&delegatee=trendovoter&vesting_shares=200.000%20SP) , <b>[500SP](https://beta.steemconnect.com/sign/delegateVestingShares?delegator=YOURUSERNAME&delegatee=trendovoter&vesting_shares=500.000%20SP)</b> , <b>[1000SP](https://beta.steemconnect.com/sign/delegateVestingShares?delegator=YOURUSERNAME&delegatee=trendovoter&vesting_shares=1000.000%20SP)</b> , <b>[2000SP](https://beta.steemconnect.com/sign/delegateVestingShares?delegator=YOURUSERNAME&delegatee=trendovoter&vesting_shares=2000.000%20SP)</b></sup>
properties (22)
authortrendovoter
permlinkre-quantumdeveloper-computation-contest-8-results-and-solution-20191230t233900136z
categoryprogramming
json_metadata{"tags":["trdo","newsteem"],"app":"trdo-voter/1.0","format":"markdown"}
created2019-12-30 23:39:00
last_update2019-12-30 23:39:00
depth1
children0
last_payout2020-01-06 23:39:00
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length944
author_reputation58,041,103,589
root_title"Computation Contest #8 Results and Solution"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id93,879,777
net_rshares0