This file contains 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
def descending_sub_n_digit_palindromes(n): | |
while n >= 0: | |
k = (n + 1) // 2 | |
highest = 10 ** k - 1 | |
lowest = highest // 10 | |
for x in range(highest, lowest, -1): | |
s_x = str(x) # "abcde" | |
rev = s_x[::-1] # "edcba" |
This file contains 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
# We could iterate over factors and check for palindromes in their products, | |
# but this is slower than iterating over palindromes and trying to split them | |
# up[1]: the approach used here examines possible solutions in descending | |
# order, so we always find the biggest one first. This allows us to exit early. | |
# | |
# Either way, here's a definition for `is_palindrome` that ended up being | |
# unnecessary: | |
# | |
# def is_palindrome(x): | |
# """Is the given positive integer x a palindromic number?""" |
This file contains 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
Introduction | |
============ | |
Futoshiki (不等式, meaning “inequality”) is a Japanese logic puzzle similar to | |
Sudoku and the like. Numbers from 1 to n must be placed on an n-by-n grid | |
(which usually already contains some values) such that each row and each column | |
is a permutation of `[1..n]`. Additionally, less-than or greater-than signs are | |
placed between cells, constraining their mutual ordering. | |
An example puzzle looks like this: |
This file contains 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
#!/usr/bin/python | |
# dewinfont is copyright 2001 Simon Tatham. All rights reserved. | |
# | |
# Permission is hereby granted, free of charge, to any person | |
# obtaining a copy of this software and associated documentation files | |
# (the "Software"), to deal in the Software without restriction, | |
# including without limitation the rights to use, copy, modify, merge, | |
# publish, distribute, sublicense, and/or sell copies of the Software, | |
# and to permit persons to whom the Software is furnished to do so, |
This file contains 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
require 'nokogiri' | |
require 'open-uri' | |
url = ARGV[0] || gets | |
out = ARGV[1] || url.split('/')[-1] | |
puts "Retrieving album page..." | |
url = "http://imgur.com/a/#{url}" unless url =~ /^http/ | |
doc = Nokogiri::HTML(open(url).read) |
This file contains 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 pexpect, ANSI | |
import sys | |
from random import choice | |
NAME = 'rfkbot' | |
PASS = 'kitten' | |
HARD_MODE = True | |
login = 'l{0}\n{1}\n{2} '.format(NAME, PASS, 'R' if HARD_MODE else 'r') |
This file contains 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
=begin | |
<nooodl> @mind flayer | |
<Kroisos> mind flayer (h) | AC: 5 | Speed: 12 | MR: 90 | Attacks: 1d4 weapon | |
physical, 2d1 tentacle eatbrain, 2d1 tentacle eatbrain, 2d1 tentacle | |
eatbrain | Corpse: none | Resist: none | |
<nooodl> @s ac<0 speed<=6 mr | |
<Kroisos> ghost (ac: -5, speed: 3, mr: 50), hezrou (ac: -2, speed: 6, mr:55), | |
ice devil (ac: -4, speed: 6, mr: 55), pit fiend (ac: -3, speed: 6, mr: 65), | |
balrog (ac: -2, speed: 5, mr: 75), Juiblex (ac: -7, speed: 3, mr: 65), | |
Geryon (ac: -3, speed: 3, mr: 75) |