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
belongs_to :user, counter_cache: true |
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
belongs_to :user, counter_cache: true |
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
belongs_to :user, counter_cache: true |
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
# add a word to an existing trie, recursively | |
def addWord(word, trie): | |
# non-base case | |
if word: | |
letter, rest = word[0], word[1:] | |
if letter not in trie: | |
trie[letter] = {} | |
addWord(rest, trie[letter]) | |
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
counter = 0 | |
def inorder(node): | |
if node: | |
inorder(node.left) | |
visit(node) | |
inorder(node.right) | |
def visit(node): | |
node.label = counter |
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
def updateBoard(board, click): | |
row, col = click | |
# 1. click on a mine, the game is over | |
if board[row][col] == 'M': | |
board[row][col] = 'X' | |
return board | |
adjacentMines = countMines(board, click) |
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
# output how many paired neighbors can be smushed, ignoring 0s | |
def rowCount(arr): | |
if len(arr) > 0: | |
count = 0 | |
prev = arr[0] | |
for i in range(1, len(arr)): | |
curr = arr[i] | |
if curr == 0: | |
continue | |
if curr == prev: |
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
# student_submission.feature | |
Feature: upload a project | |
As a proud student | |
So that I can upload my awesome project | |
I want to submit my project with the required submission details | |
Background: course exists and is ready for submissions | |
Given I am a Student |
NewerOlder