Skip to content

Instantly share code, notes, and snippets.

@popey456963
popey456963 / bot.js
Created December 16, 2016 21:34
A JS Bot
var socket = require('socket.io-client')('http://localhost:8080', { transports: ['websocket'] })
var chalk = require('chalk')
var listen_events = ['queue_update', 'game_update']
socket.on('connect', function() {
console.log('Connected Successfully')
socket.emit('play', 'Beep Boop', 'Sy5tdf37g')
socket.emit('set_force_start', null, true)
})
@popey456963
popey456963 / main.py
Last active December 10, 2016 13:14
Challenge #294 Rack Management 3
# [2016-12-09] Challenge #294 [Hard] Rack management 3
# https://www.reddit.com/r/dailyprogrammer/comments/5hcd0x/20161209_challenge_294_hard_rack_management_3/
import copy, random, timeit
original_row = "sd?zeioao?mluvepesceinfxt?wyiru?ie?giator?t??nuefje?l?odndrotpewlgoobiinysagacaqski?aeh?rbhaervtnl?m"
words = [[line.strip(), 0] for line in open("enable1.txt") if len(line.strip()) < 11]
letters = "abcdefghijklmnopqsrtuvwxyz"
scores = [1,3,3,2,1,4,2,4,1,8,5,1,3,1,1,3,10,1,1,1,1,4,4,8,4,10]
practice = False
@popey456963
popey456963 / main.py
Created December 10, 2016 13:06
[2016-12-09] Challenge #294 [Intermediate] Rack management 2 (Bonus 2)
# [2016-12-09] Challenge #294 [Hard] Rack management 3
# https://www.reddit.com/r/dailyprogrammer/comments/5hcd0x/20161209_challenge_294_hard_rack_management_3/
import copy, random, timeit
original_row = "sd?zeioao?mluvepesceinfxt?wyiru?ie?giator?t??nuefje?l?odndrotpewlgoobiinysagacaqski?aeh?rbhaervtnl?m"
words = [[line.strip(), 0] for line in open("enable1.txt") if len(line.strip()) < 21]
letters = "abcdefghijklmnopqsrtuvwxyz"
scores = [1,3,3,2,1,4,2,4,1,8,5,1,3,1,1,3,10,1,1,1,1,4,4,8,4,10]
practice = False
@popey456963
popey456963 / main.py
Last active December 10, 2016 13:06
[2016-12-09] Challenge #294 [Intermediate] Rack management 2 (Bonus 1)
# [2016-12-09] Challenge #294 [Intermediate] Rack management 2
# https://www.reddit.com/r/dailyprogrammer/comments/5h40ml/20161207_challenge_294_intermediate_rack/
import copy, random, timeit
words = [[line.strip(), 0] for line in open("enable1.txt") if len(line.strip()) < 11]
tilescores = dict(zip("abcdefghijklmnopqrstuvwxyz?", [1,3,3,2,1,4,2,4,1,8,5,1,3,1,1,3,10,1,1,1,1,4,4,8,4,10,0]))
char_freq = {'a': 22, 'c': 15, 'b': 9, 'e': 25, 'd': 16, 'g': 13, 'f': 7, 'i': 23, 'h': 10, 'k': 6, 'j': 1, 'm': 11, 'l': 17, 'o': 19, 'n': 20, 'q': 0, 'p': 12, 's': 24, 'r': 21, 'u': 14, 't': 18, 'w': 5, 'v': 4, 'y': 8, 'x': 2, 'z': 3}
def calcScore(word):
@popey456963
popey456963 / test.py
Created December 9, 2016 14:37
Test Script by Cosmologican
import sys
from collections import Counter
N = 10 # number of tiles in the rack
words = set(line.strip() for line in open("enable1.txt"))
row = "sd?zeioao?mluvepesceinfxt?wyiru?ie?giator?t??nuefje?l?odndrotpewlgoobiinysagacaqski?aeh?rbhaervtnl?m"
rack = []
score = 0
for line in sys.stdin:
if not line: continue
@popey456963
popey456963 / word.py
Created November 10, 2016 21:33
Word Spacer
from nltk.corpus import brown
import copy
from nltk.probability import FreqDist
def findmostlikelytokens(testsentence, fq):
stack=[([], testsentence)]
resultlist=[]
while len(stack) > 0:
currentlist, sentence=stack.pop(0)
if len(sentence)==0:
from hlt import *
from networking import *
myID, gameMap = getInit()
sendInit("PythonBot")
while True:
moves = []
gameMap = getFrame()
for y in range(gameMap.height):
@popey456963
popey456963 / memo.py
Created November 5, 2016 09:45
Collatz Conjecture Memoisation
def memo(f):
def func(*args):
if args not in func.cache:
func.cache[args] = f(*args)
return func.cache[args]
func.cache = {}
return func
@memo
def collatz(n):
@popey456963
popey456963 / flip-switches.py
Created November 4, 2016 22:31
Flipping Switches
i,s='36047399',[0]*10
for j,k in zip(i,i[1:])[::2]:
r=sorted([int(j),int(k)]);r[1]+=1
for l in range(*r):s[l]^=1
print(s)
"Shop"
{
"ttt_sort_items"
{
"value" "1"
"description" "Sort shop items? 0 = Disabled. 1 = Enabled (default)."
}
"ttt_credits_killer_innocent_victim_innocent_subtract"
{
"value" "1500"