Bitcoin Forum
June 22, 2024, 02:17:15 AM *
News: Voting for pizza day contest
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Some homemade analysis: Environmental flows of merit on BitcoinTalk  (Read 113 times)
Slava79 (OP)
Member
**
Offline Offline

Activity: 182
Merit: 17

¯\_(ツ)_/¯


View Profile
April 25, 2018, 03:56:03 PM
Merited by Jet Cash (1)
 #1

Hello everybody

I'm learning a new programming language nowadays - Kotlin and could not miss the opportunity to practice it with the BitcoinTalk raw data for merit flow available by  https://bitcointalk.org/merit.txt.xz.

I've got an idea that probably merit is going in circles - one user merits another, then second user merits the third and then third returns merit to the first. For whatever reason.

With the available data it is quite easy to check. I'm not that good at algorithms, so just created a quick and dirty script.

The data result  is quite interesting.

There are circles and some of them of different size.

These which are user1 -> user2 - > user1 I call circle size 2, these of type  user1 -> user2 -> user3 - > user1 circle of size 3 etc


The example script output:

Quote
Circle found: [988147, 521226, 995414, 929472, 995414, 521226, 988147]
Circle found: [988147, 521226, 995414, 929472, 995414, 929472, 995414, 521226, 995414, 521226, 988147]
Circle found: [988147, 521226, 995414, 929472, 995414, 929472, 995414, 521226, 988147]
Circle found: [988147, 521226, 995414, 929472, 995414, 929472, 995414, 929472, 995414, 521226, 988147]
Circle found: [988147, 521226, 988147]
Circle found: [1343594, 1196051, 1343594]
Circle found: [1517809, 658788, 1517809]

The script itself (warning - ugly, inefficient and probably contains bugs):

Code:
import java.io.File

// max recursion level
val maxLevel = 10

// minimum circle size
val maxCircleSize = 5

// restrict check only to users who gave merit less than maxMeritedUsers times
val maxMeritedUsers = 5

val events = File("../merit.txt")
        .readLines()
        .drop(1)
        .map { it.split("\t") }
        .map { (_, _, _, userFrom, userTo) -> Pair(userFrom, userTo) }
        .groupBy { it.first }
        .map { (userFrom, events) -> Pair(userFrom, events.map { it.second }) }
        .filter { it.second.size < maxMeritedUsers }
        .associate { it.first to it.second }

fun checkCircle(userFrom: String, usersTo: List<String>, circle: List<String>, level: Int) {

    if (level >= maxLevel) {
        return
    }

    usersTo.forEach { userTo ->

        if (userFrom == userTo) {
            println("Circle found: ${circle + userTo}")
        } else {
            checkCircle(userFrom, events[userTo].orEmpty(), circle + userTo, level + 1)
        }
    }
}

println("Unique user sent merit: ${events.keys.size}")

events.keys.forEach { userFrom ->

    val circle = listOf(userFrom)

    checkCircle(userFrom, events[userFrom].orEmpty(), circle, 0)

}



In order to run it you need to install Kotlin compiler.

Please feel free to play with it, for whatever goal. I hope it is interesting )




Building a JavaScript Smart Contracts Engine
Github | Site | Chat
Jet Cash
Legendary
*
Offline Offline

Activity: 2744
Merit: 2462


https://JetCash.com


View Profile WWW
April 25, 2018, 04:08:15 PM
 #2

All these new programming languages ( can we still call them languages) are quite fascinating. I've been collecting the free ebooks from packt, and I keep meaning to try to use some of them.

Offgrid campers allow you to enjoy life and preserve your health and wealth.
Save old Cars - my project to save old cars from scrapage schemes, and to reduce the sale of new cars.
My new Bitcoin transfer address is - bc1q9gtz8e40en6glgxwk4eujuau2fk5wxrprs6fys
Slava79 (OP)
Member
**
Offline Offline

Activity: 182
Merit: 17

¯\_(ツ)_/¯


View Profile
April 25, 2018, 04:16:31 PM
 #3

All these new programming languages ( can we still call them languages) are quite fascinating. I've been collecting the free ebooks from packt, and I keep meaning to try to use some of them.

I started a new project in Java recently, but Java really drives me mad, too verbose even with lambdas. And in Java10 they fucked up with 'var' and 'val'. So I switched to Kotlin as I can't avoid JVM anyway. Very happy with the language so far.

Building a JavaScript Smart Contracts Engine
Github | Site | Chat
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!