To have isloated and consistent development environment, we apply Docker.
- Make sure the code is easy to deploy or to be executed on developers' environments.
- Make sure the code has consistent behaviour when we change the environment.
| class Solution: | |
| def isPalindrome(self, x: int) -> bool: | |
| if x < 0: | |
| return False | |
| length = math.ceil(math.log10(x)) | |
| if length <= 1: | |
| return True | |
| """ | |
| Loads a textfile, builds a Word2Vec model, and prints similarity of words. | |
| """ | |
| import urllib.request | |
| import nltk | |
| from nltk.tokenize import sent_tokenize, word_tokenize | |
| from gensim.models import Word2Vec | |
| # Source: Project Gutenberg's Alice's Adventures in Wonderland. | |
| CORPUS_TEXT_URL = 'https://www.gutenberg.org/files/11/11.txt' |
| extern struct FILE* STDIN; | |
| int getchar() { | |
| return STDIN->read(); | |
| } |
| #include "file.h" | |
| void (*open)(char *name, int mode) {/*...*/}; | |
| void (*close) {/*...*/}; | |
| int (*read)() {/*...*/}; | |
| void (*write)(char) {/*...*/}; | |
| void (*seek)(long index, int mode) {/*...*/}; | |
| struct FILE console = {open, close, read, write, seek}; |
| // The UNIX operating system requires that every IO device driver provide five | |
| // standard functions: open, close, read, write, seek. | |
| struct FILE { | |
| void (*open)(char *name, int mode); | |
| void (*close)(); | |
| int (*read)(); | |
| void (*write)(char); | |
| void (*seek)(long index, int mode); | |
| } |
| #include <stdio.h> | |
| void copy() { | |
| int c; | |
| while ((c=getchar()) != EOF) { | |
| putchar(c); | |
| } | |
| } |
| /* main.c */ | |
| #include "point.h" | |
| #include "labeledPoint.h" | |
| #include <stdio.h> | |
| int main(int argc, char** argv) { | |
| struct LabeledPoint* origin = makeLabeledPoint(0.0, 0.0, "origin"); | |
| struct LabeledPoint* lowerLeft = makeLabeledPoint(-1.0, -1.0, "lowerLeft"); | |
| printf("distance = %f\n", getDistance( | |
| (struct Point*) origin, (struct Point*) lowerLeft)); |
| /* labeledPoint.h */ | |
| struct LabeledPoint; | |
| struct LabeledPoint* makeLabeledPoint(double x, double y, char* label); | |
| void setLabel(struct LabeledPoint *lp, char *label); | |
| char* getLabel(struct LabeledPoint *lp); |
| /* labeledPoint.c */ | |
| #include "labeledPoint.h" | |
| #include <stdlib.h> | |
| struct LabeledPoint { | |
| double x, y; | |
| char* name; | |
| }; | |
| struct LabeledPoint* makeLabeledPoint(double x, double y, char* label) { |