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
#include <iostream> | |
#include <cmath> | |
using namespace std; | |
struct placedRect | |
{ | |
int x, | |
y, | |
width, | |
height; |
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
""" | |
Write a program that plays Tic-tac-toe with you and tries its best to lose | |
""" | |
def printBoard(b): | |
for i in range(3): | |
print(b[3*i], b[3*i+1], b[3*i+2]) | |
def getNext(b): | |
move = int(input("Your move, sir (must be a number from 1 to 9): ")) - 1 |
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
class Gomoku: | |
def __init__(self, size): | |
self.size = size | |
self.board = ['-'] * size * size | |
self.inarow = 5 | |
self.players = ['x', 'o'] | |
self.curplayer = 1 | |
def printboard(self): | |
s = self.size |
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
class Twitter(object): | |
def __init__(self): | |
""" | |
Initialize your data structure here. | |
""" | |
self.followers = {} | |
self.tweets = {} | |
def postTweet(self, userId, tweetId): |
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
n = int(input()) | |
for _ in range(n): | |
a, b = map(int, input().split()) | |
while b > a: | |
b &= (b-1) | |
print(b) |
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
n = 1000000 | |
primes = [False, False] + [True]*(n-2) | |
for i in range(2, int(n**0.5)+1): | |
if primes[i]: | |
primes[i*i::i] = [False] * len(primes[i*i::i]) | |
def check_rotations(num): | |
s = str(num) | |
return all(primes[int((s+s)[i:i+len(s)])] for i in range(len(s))) |
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
<div> | |
<div id="history"> | |
<ul id="completed_tasks"> | |
</ul> | |
</div> | |
<div id="working"> | |
Working on <span id="current_task">current task</span>, <span id="task_countdown">25:00</span> left. | |
</div> | |
<div id="break"> | |
Completed <span id="finished_task">a task</span>. On break, <span id="break_countdown">5:00</span> left. |
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
var objectsEqual = (a, b) => { | |
const aProps = Object.getOwnPropertyNames(a), | |
bProps = Object.getOwnPropertyNames(b); | |
if (aProps.length != bProps.length) { | |
return false; | |
} | |
for (var i=0; i<aProps.length; i++) { | |
const propName = aProps[i]; |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
from itertools import permutations | |
pieces = [[0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0], | |
[0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0], | |
[0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1], | |
[1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1], | |
[0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0], | |
[0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1]] | |
def rotations(piece): |
OlderNewer