create account

Daily Steem-Python Challenge #19, Win 1 Steem! by steempytutorials

View this thread on: hive.blogpeakd.comecency.com
· @steempytutorials · (edited)
$2.37
Daily Steem-Python Challenge #19, Win 1 Steem!
<center>https://cdn.discordapp.com/attachments/404587860872921088/405329216280723458/challenge.png</center>

For each tutorial we release there will be a relevant challenge where the winner receives 1 STEEM! 

### Challenge

Take the code from the tutorial from [here](https://github.com/amosbastian/steempy-tutorials/tree/master/part_19) and change it to be able to do the following

1. Counting blocks is perfect for multi threading as each blocks does not effect another block. Alter the code in such a way that is takes `amount_of_threads` as a second command line argument and equally divides the blocks to be analysed among these threads.  Combine the collected data and the end.

That's it! Good luck to everyone participating!

### Deadline
The prize money will be rewarded to the person that solves the problem first. If there is no solution within 7 days after this post has been submitted the prize pool expires.

### Relevant Tutorial(s)
- [Part 19: Analysing The Steem Blockchain From A Custom Block Number For A Custom Block Count](https://steemit.com/utopian-io/@steempytutorials/part-19-analysing-the-steem-blockchain-for-a-custom-block-number-for-a-custom-block-count)

---

If you have questions about the tutorial or the challenge then don't hesitate to comment below or contact us on [Discord](https://discord.gg/rYTV87W)!
👍  , , , , , , , , , , , , , , ,
properties (23)
authorsteempytutorials
permlinkdaily-steem-python-challenge-19-win-1-steem
categoryprogramming
json_metadata{"tags":["programming","python","contest","bot","steemdev"],"image":["https://cdn.discordapp.com/attachments/404587860872921088/405329216280723458/challenge.png"],"links":["https://github.com/amosbastian/steempy-tutorials/tree/master/part_19","https://steemit.com/utopian-io/@steempytutorials/part-19-analysing-the-steem-blockchain-for-a-custom-block-number-for-a-custom-block-count","https://discord.gg/rYTV87W"],"app":"steemit/0.1","format":"markdown"}
created2018-01-31 15:05:27
last_update2018-01-31 15:10:51
depth0
children3
last_payout2018-02-07 15:05:27
cashout_time1969-12-31 23:59:59
total_payout_value2.339 HBD
curator_payout_value0.032 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,342
author_reputation31,094,047,689,691
root_title"Daily Steem-Python Challenge #19, Win 1 Steem!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id33,879,996
net_rshares379,560,787,460
author_curate_reward""
vote details (16)
@bruce-forks ·
$0.07
[Here's](https://gist.github.com/bruce-forks/51d24ddaddaca7465302e0b77f006857) my solution. Hope you like it!
👍  
properties (23)
authorbruce-forks
permlinkre-steempytutorials-daily-steem-python-challenge-19-win-1-steem-20180201t054041432z
categoryprogramming
json_metadata{"tags":["programming"],"links":["https://gist.github.com/bruce-forks/51d24ddaddaca7465302e0b77f006857"],"app":"steemit/0.1"}
created2018-02-01 05:40:39
last_update2018-02-01 05:40:39
depth1
children2
last_payout2018-02-08 05:40:39
cashout_time1969-12-31 23:59:59
total_payout_value0.052 HBD
curator_payout_value0.014 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length109
author_reputation534,201,026,995
root_title"Daily Steem-Python Challenge #19, Win 1 Steem!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id34,045,243
net_rshares11,415,530,758
author_curate_reward""
vote details (1)
@juliank ·
Nice work! I will send you the prize money.

Question:

You create a separate dict for each thread:
`results.append({})`

And you also lock this dict for every write:
```
      lock.acquire()
            if operation not in self.stats:
                self.stats[operation] = 1
            else:
                self.stats[operation] += 1
            lock.release()
```

Is this required since the dict is still part of the results list? I do not know, so this is a genuine question.

My solution is a bit different in that regard and also yields faster times, I will be submitting a tutorial soon.
👍  
properties (23)
authorjuliank
permlinkre-bruce-forks-re-steempytutorials-daily-steem-python-challenge-19-win-1-steem-20180202t000838091z
categoryprogramming
json_metadata{"tags":["programming"],"app":"steemit/0.1"}
created2018-02-02 00:08:39
last_update2018-02-02 00:08:39
depth2
children1
last_payout2018-02-09 00:08:39
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_length598
author_reputation117,823,071,447,502
root_title"Daily Steem-Python Challenge #19, Win 1 Steem!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id34,256,737
net_rshares613,754,140
author_curate_reward""
vote details (1)
@bruce-forks ·
Yeah, I don't think that lock is necessary. I used it because I thought since they are all part of a larger array I should use it to be safe, but I think it would be just as safe without. Nice catch!
properties (22)
authorbruce-forks
permlinkre-juliank-re-bruce-forks-re-steempytutorials-daily-steem-python-challenge-19-win-1-steem-20180203t223425340z
categoryprogramming
json_metadata{"tags":["programming"],"app":"steemit/0.1"}
created2018-02-03 22:34:24
last_update2018-02-03 22:34:24
depth3
children0
last_payout2018-02-10 22:34:24
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_length199
author_reputation534,201,026,995
root_title"Daily Steem-Python Challenge #19, Win 1 Steem!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id34,744,984
net_rshares0