This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| import json | |
| ### SETTINGS ### | |
| # number of elements | |
| N = 4 | |
| # save cache dictionary? | |
| # if True, file 'N=3.txt' is created ('3' is replaced by whatever N is) | |
| SAVE_CACHE_TO_FILE = False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import readline | |
| def max_heapify(A, s, recCall = 1) -> int: | |
| left = 2*(s+1)-1 | |
| right = 2*(s+1) | |
| if left < len(A) and A[left] > A[s]: | |
| largest = left | |
| else: | |
| largest = s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # A small application to demonstrate the calculation steps for the Banzhaf Score and Shapley-Shubik Index | |
| # using the methods proposed by Kirsch, Werner, and Jessica Langner. "Power indices and minimal winning coalitions." Social Choice and Welfare 34.1 (2010): 33-46. | |
| library(shiny) | |
| library(sets) | |
| library(partitions) | |
| library(socialranking) | |
| library(MASS) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ###################################### | |
| # List of minimal winning coalitions # | |
| ###################################### | |
| mwcs <- list(c(1,2), c(1,3,4), c(1,3,5), c(1,4,5)) | |
| quota <- 6 | |
| onlyIntegerSolutions <- TRUE | |
| ###################################### | |
| # All the other stuff # | |
| ###################################### |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { Telegraf } = require('telegraf') | |
| var https = require('https'); | |
| https.get('https://lichess.org/api/puzzle/daily', res => { | |
| var body = '' | |
| res.on('data', chunk => body += chunk) | |
| res.on('end', () => sendPuzzle(JSON.parse(body))) | |
| }) | |
| function sendPuzzle(game) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from collections import defaultdict | |
| import random | |
| actions = ['N', 'E', 'S', 'W'] | |
| transition = { | |
| 'N': lambda s: (s[0] - 1, s[1]), | |
| 'S': lambda s: (s[0] + 1, s[1]), | |
| 'E': lambda s: (s[0], s[1] + 1), | |
| 'W': lambda s: (s[0], s[1] - 1) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Diagnostics; | |
| using System.IO; | |
| using System.IO.Compression; | |
| using System.Windows; | |
| namespace Unzippidy | |
| { | |
| class Program | |
| { |