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 <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) |
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
#define _XOPEN_SOURCE | |
#include <unistd.h> | |
#include <stdio.h> | |
#include <cs50.h> | |
#include <string.h> | |
#include <ctype.h> | |
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
#define _XOPEN_SOURCE | |
#include <unistd.h> | |
#include <stdio.h> | |
#include <cs50.h> | |
#include <string.h> | |
#include <ctype.h> | |
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
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 |
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
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 |
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 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 |
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 time | |
import random | |
def f(L): | |
""" | |
L: list | |
return list cu elemente cu frecventa impara | |
""" | |
t0 = time.clock() |
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 time | |
import random | |
def f(L): | |
""" | |
L: list | |
return list cu elemente cu frecventa impara | |
""" | |
t0 = time.clock() |
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> | |
int main() | |
{ | |
double x = 3.1; | |
float y = 3.1; | |
printf("%.20f\n", x); // 3.10000000000000008882 | |
printf("%.20f\n", y); //3.09999990463256835938 |
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> | |
int main() | |
{ | |
float x = 3.1; | |
float y = 3.1; | |
printf("%.20f\n", x); // 3.09999990463256835938 | |
printf("%.20f\n", y); // 3.09999990463256835938 |
OlderNewer