Skip to content

Instantly share code, notes, and snippets.

@martinweigert
martinweigert / TicTacToe.py
Last active April 14, 2017 13:26
Tic Tac Toe: Checking whether a player has won, and if so, which one
#0 means an empty square
#1 means that player 1 put their token in that space.
#2 means that player 2 put their token in that space.
#task: tell me whether anyone has won, and tell me which player won, if any.
#task source http://www.practicepython.org/exercise/2015/11/16/26-check-tic-tac-toe.html
game = [[1, 1, 2],[0, 1, 2],[1, 2, 1]]
winner = ""
@martinweigert
martinweigert / tictactoe.py
Last active April 18, 2017 22:34
Full TicTacTo game
#kind of a milestone for me, built completely on my own.
#task source: http://www.practicepython.org/exercise/2016/08/03/29-tic-tac-toe-game.html
import sys
def play_again():
global player1_count
global player2_count
user_input = input("Do you want to play again? Type 'y' for yes or any key for no. ")
if user_input.startswith("y"):
@martinweigert
martinweigert / gist:020abe5e1e40393eb62abc42a8b427a5
Last active July 19, 2017 10:58
analyze_hn_frontpage_csv.py
import matplotlib.pyplot as plt
import statistics
from collections import Counter
from collections import defaultdict
import requests
import json
import datetime
from wordcloud import WordCloud
import random