Skip to content

Instantly share code, notes, and snippets.

View FeraruSilviuMarian's full-sized avatar

silviusilviu FeraruSilviuMarian

View GitHub Profile
@FeraruSilviuMarian
FeraruSilviuMarian / initials.c
Created September 21, 2017 16:57
String to Acronym
#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <ctype.h>
// takes any string as input, returns the first letter (to uppercase) of each word as output
string StrToAcronym (string text);
int main (void)
@FeraruSilviuMarian
FeraruSilviuMarian / crack.c
Created September 22, 2017 11:13
takes a one-way hash as cmd-line input and attempts to match hash to letters
#define _XOPEN_SOURCE
#include <unistd.h>
#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <ctype.h>
@FeraruSilviuMarian
FeraruSilviuMarian / crack.c
Created September 22, 2017 15:14
generates plaintext combinations so far
#define _XOPEN_SOURCE
#include <unistd.h>
#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <ctype.h>
l = [2,3,4,5,1,4,5,1,2]
def f(L):
d = {}
for e in L:
d[e] = d.get(e, 0) + 1
for key in d:
if d[key] % 2 != 0:
return key
l = [1,1,2,3,3,2,1,2,3,3]
def f(L):
"""
L: list
return list cu elemente cu frecventa impara
"""
d = {}
for e in L:
d[e] = d.get(e, 0) + 1
import time
import random
def f(L):
"""
L: list
return list cu elemente cu frecventa impara
"""
t0 = time.clock()
def isSubstring(substring, string):
"""
substring: string
string: string
returns true if substring is substring of string e.g. 'cat' is substring of 'something cat something'
"""
si = 0 # substring indexer
for i in range(len(string)):
if string[i] == substring[si]:
si += 1 # notice, advancing the substring indexer each time we find a match
import time
import random
def f(L):
"""
L: list
return list cu elemente cu frecventa impara
"""
t0 = time.clock()
#include <stdio.h>
int main()
{
double x = 3.1;
float y = 3.1;
printf("%.20f\n", x); // 3.10000000000000008882
printf("%.20f\n", y); //3.09999990463256835938
#include <stdio.h>
int main()
{
float x = 3.1;
float y = 3.1;
printf("%.20f\n", x); // 3.09999990463256835938
printf("%.20f\n", y); // 3.09999990463256835938