Skip to content

Instantly share code, notes, and snippets.

View AndyNovo's full-sized avatar

Andy Novocin AndyNovo

View GitHub Profile
[0, 0, 2, 1, 1, 1, 1, 2, 1]
[1, 2, 1, 1, 0, 0, 2, 1, 1]
[2, 0, 2, 1, 0, 2, 0, 0, 2]
[2, 0, 2, 1, 0, 0, 2, 1, 1]
[0, 2, 1, 0, 0, 2, 2, 1, 1]
[1, 1, 2, 1, 0, 0, 2, 1, 1]
[0, 2, 1, 0, 2, 1, 0, 2, 1]
[2, 1, 0, 2, 0, 0, 2, 2, 0]
[1, 1, 2, 1, 0, 2, 0, 0, 2]
[2, 1, 0, 2, 0, 0, 2, 1, 1]
import hashlib
import sys
def xor(s1,s2):
return ''.join(chr(ord(a) ^ ord(b)) for a,b in zip(s1,s2))
def repeat(s, l):
return (s*(int(l/len(s))+1))[:l]
key = sys.argv[1]
function expmod( base, exp, mod ){
if (exp === 0) return 1;
if (exp % 2 === 0){
return Math.pow( expmod( base, (exp / 2), mod), 2) % mod;
}
else {
return (base * expmod( base, (exp - 1), mod)) % mod;
}
}
@AndyNovo
AndyNovo / loop4.c
Created March 20, 2017 16:55
Using a function this time
#include "stdio.h"
int compare(int a, int b){
return a == b;
}
int main() {
int i=0;
for(; !compare(i, 5); i++){
@AndyNovo
AndyNovo / loop3.c
Created March 20, 2017 16:48
Yet another version
#include "stdio.h"
int main() {
for (int i=0;i<5;printf("i = %d\n",i++)){}
return 0;
}
@AndyNovo
AndyNovo / loop2.c
Created March 20, 2017 16:46
Same loop
#include "stdio.h"
int main() {
int i=0;
for ( ; i != 5 ; ){
printf("i = %d\n", i);
i = i+1;
}
return 0;
}
@AndyNovo
AndyNovo / loop.c
Created March 20, 2017 16:44
Basic C loop
#include "stdio.h"
int main() {
int i;
//The first part of this for loop is run once as an initialization
//the second part is checked for truth at the end of each execution to determine if the loop should be run again
//the third part is executed at the end of the loop (typically used to increment something)
for (i = 0; i < 5; i++){
printf("i = %d\n", i);
}
@AndyNovo
AndyNovo / compare.cpp
Created March 20, 2017 16:37
Basic string comparison
#include <iostream>
using namespace std;
int main() {
string text = "text1";
string text2 = "text1";
if (text.compare(text2) == 0){
cout << "They are the same" << endl;
} else {
@AndyNovo
AndyNovo / string.cpp
Created March 20, 2017 16:29
Basic String usage
#include <iostream>
using namespace std;
int main() {
string text = "Andy is the greatest";
cout << text << endl;
}
@AndyNovo
AndyNovo / hello.cpp
Last active March 20, 2017 16:27
Basic C++ Hello World
#include <iostream>
//Note that there is a different input/output library iostream
//Also a slightly different notation for including <libraryname> instead of "libraryname.h"
//Again there is a "main" function with a return type "int"
int main() {
//Now printf is replaced by a "stream" concept, where "cout" is the output stream
//and we pipe values into that output stream by the "<<" operator.
//Also the "\n" has a more abstract version "endl" for a platform independent newline character
std::cout << "Hello World!" << std::endl;