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 min_val(self, player, depth, max_depth): | |
#print "min_val depth of", depth | |
if self.game_won()[0]: | |
return self.utility() | |
if depth >= max_depth: #do I need =>? | |
return 0 | |
else: | |
depth = depth + 1 | |
min_init = 10 | |
player = self.next_turn(player) |
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
>>> li = ["Larry", "Curly"] | |
>>> li.pop (1) | |
<built−in method pop of list object at 010DF884> | |
>>> getattr(li, "pop") (2) | |
<built−in method pop of list object at 010DF884> | |
>>> getattr(li, "append")("Moe") (3) | |
>>> li | |
["Larry", "Curly", "Moe"] | |
1. This gets a reference to the pop method of the list. Note that this is not |
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
>>> a = [1,2] | |
>>> b = [1,2] | |
>>> c = a | |
>>> a is b | |
False | |
>>> a is c | |
True | |
>>> a == b | |
True |
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 getTalk(volume='shout'): | |
def whisper(word='hello'): | |
return word.lower()+'...' | |
def shout(word='hello'): | |
return word.capitalize()+"!" | |
if volume == 'shout' : # reference function without calling it | |
return shout | |
else: | |
return whisper |
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 random | |
import pdb | |
import sys | |
import pygame | |
from pygame.locals import QUIT, MOUSEBUTTONDOWN | |
class Game: | |
BLACK = (0,0,0) | |
WHITE = (255,255,255) | |
GREY = (140,140,140) |
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 <stdlib.h> | |
# include <stdio.h> | |
int main() | |
{ | |
int myarray[10] = {100,4,'c','d','e','f','g','h','i','j'}; | |
int *a_goddamn_pointer; | |
int x, y, z, w; | |
a_goddamn_pointer = &myarray; |
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
for (int i=0; i<15; i++) | |
{ | |
int c = rand(); | |
printf("%d\n", c); | |
} |
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 <stdio.h> | |
#include <stdlib.h> | |
void quicksort(int *array, int length); | |
void swap(int *a, int *b); | |
void print(int *array, int length); | |
int main() |
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 <stdio.h> | |
#include <stdlib.h> | |
void quicksort(int *array, int length); | |
void swap(int *a, int *b); | |
void print(int *array, int length); | |
int main() |
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
>>>a = '%s' | |
>>>a %= 1 # equivalently, a = a % 1 | |
>>>a == '1' | |
True | |
# A more clear version | |
>>> f = '%s' % 1 | |
>>> f | |
'1' |
OlderNewer