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 operator, types | |
def value(x): | |
return getattr(x, 'value', x) | |
class Cell(types.SimpleNamespace): | |
@property | |
def value(self): |
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
print("Welcome to the MadLibs game. If you type in words, we'll give you a story.") | |
name = input("Start by typing in a name: ") | |
noun1 = input("Give me a noun: ") | |
adjective1 = input("I need an adjective: ") | |
adjective2 = input("I really need an alpaca... just kidding, give me another adjective: ") | |
noun2 = input("Give me another noun: ") | |
adverb = input("PLEASE! I really want an adverb: ") | |
noun3 = input("Give me the last noun: ") | |
import random |
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
# First example: using an explicit namespace as a shared context | |
from types import SimpleNamespace as Context | |
def f(): | |
shared = Context(x=5) | |
def g(): |
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 Import Classical_Prop. | |
Variable Person : Type. | |
Variable Jack Anne George : Person. | |
Variable married : Person -> Prop. | |
Notation "a ^: b" := (married a /\ ~ married b) (at level 73). | |
Variable looksAt : Person -> Person -> Prop. | |
Notation "a ~> b" := (looksAt a b) (at level 72). | |
Hypothesis cond : Jack ~> Anne /\ Anne ~> George /\ Jack ^: George. | |
Theorem solution : exists p q : Person, p ~> q /\ p ^: q. | |
Proof. destruct (classic (married Anne)). |
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
[I]n my wildest dreams, I never imagined I'd have to write _essays_ here on | |
[ ]CheckiO. Yes, I know: who's talking? Really, I've written many mind-bogg | |
[l]ing things here already, and I have puzzled many folks reading my soluti | |
[o]ns. It's only fair that I puzzle myself now. :-So, what to write? You ha | |
[v]e already seen enough to realize that I consider Python one of the most | |
[e]xcellent inventions our civilization has ever made, not only in the tier | |
[ ]of programming languages. It still puzzles you: why one would think so? | |
[P]uzzling is good, because in this jaded culture, it is one of the rare wa | |
[y]s ideas can still be learned. Of course, my essay won't magically enligh | |
[t]en you. But neither will Zen of Python by itself. Those are only small 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 <sys/socket.h> | |
#include <sys/types.h> | |
#include <netdb.h> | |
#include <netinet/in.h> | |
#include <unistd.h> | |
#include <arpa/inet.h> | |
int main(void){ | |
struct hostent *hostinfo = gethostbyname("time-a.nist.gov"); | |
if(!hostinfo) herror("gethostbyname"); |
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 enum, struct | |
class Poruka(enum.IntEnum): | |
LOGIN = 1 | |
USERS = 2 | |
USERLIST = 3 | |
BYE = 4 | |
NEWMESSAGE = 5 | |
CHECKMESSAGES = 6 | |
MESSAGE = 7 |
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 collections | |
test = '''\ | |
value 5 goes to bot 2 | |
bot 2 gives low to bot 1 and high to bot 0 | |
value 3 goes to bot 1 | |
bot 1 gives low to output 1 and high to bot 0 | |
bot 0 gives low to output 2 and high to output 0 | |
value 2 goes to bot 2 |
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
URL: http://martinlaz.github.io/demos/cky.html | |
Gramatika: | |
Izraz -> Izraz + Član | Izraz - Član | Član | |
Član -> Član * Faktor | Faktor | |
Faktor -> broj | ( Izraz ) | |
Gramatika ChNF: | |
Izraz -> Izraz PlusClan | |
PlusClan -> Plus Clan |
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 math import sin, cos, tau | |
import collections | |
class frange(collections.namedtuple('_', 'start stop step')): | |
def __iter__(self): | |
t, end, step = super().__iter__() | |
while t <= end: | |
yield t | |
t += step |
OlderNewer