Skip to content

Instantly share code, notes, and snippets.

<!-- This is a solution for a question on stackoverflow -->
<!-- https://stackoverflow.com/questions/52892889/pause-resume-css-animations-when-switching-tabs -->
<!DOCTYPE html>
<html>
<head>
<title>animation</title>
<style type="text/css">
div#test {
@towkir
towkir / sortedfrequency.py
Last active October 28, 2016 16:36
Takes a list of number separated by comma as input, sorts the order of numbers, calculates their frequency and returns a sorted list of the result.
#!/usr/bin/python
print("This is a calculator that takes a series of numbers separated by comma,")
print("calculates their frequency and returns the result in a sorted method.")
print("Press Ctrl+C to exit the calculator")
try:
while True:
print("\nEnter your series of numbers separated by a 'comma':")
numbers = input()
numbers = numbers.split(",")
result = {}
@towkir
towkir / reversedsum.py
Last active October 28, 2016 16:35
Takes two numbers as input (abc and xyz) and returns the sum of their reversed form (cba + zyx)
#!/usr/bin/python
print("This is a calculator that takes two numbers of same lenght as input, reverses them and returns the sum")
print("Press Ctrl+C to exit the calculator")
try:
while True:
print("Enter a number:")
first = input()
for a in first:
try:
int(a)
@towkir
towkir / linearsearch.c
Created October 8, 2016 11:11
This C program has an array already saved in the source and it displays it; then requests a number from user, if the input number matches with any one in that array, it returns the position of that number in the array; otherwise, says that it is not in the array;
#include <stdio.h>
int main() {
int data[11] = {10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60};
int entry, i, position=1;
printf("Here is the array:\n");
for (i=0; i<11; i++){
printf("%d\t", data[i]);
}
printf("\n");
@towkir
towkir / pyramid_star.c
Created October 5, 2016 04:33
This C program takes an odd number (N) as input and returns a pyramid of N row
#include <stdio.h>
int main() {
int rows, i, j, k, spaces, stars;
printf("Enter rows for your pyramid:\n");
scanf("%d", &rows);
spaces = rows -1;
stars = 1;
if (rows % 2 > 0 && rows < 30){
printf("Your pyramid should look like this:\n");
@towkir
towkir / prime_in_range.c
Last active October 4, 2016 14:49
This C program takes a number as input and returns all the prime number between 1 and N (input number)
#include <stdio.h>
int main() {
int range, total_prime_in_range = 0;
printf("Enter your range:\n");
scanf("%d", &range);
printf("The prime numbers in that range are:\n");
for (int i=1; i<=range; i++){//loops through the input numbers
int not_prime = 0;
for (int j=2; j<i/2; j++){
@towkir
towkir / prime_or_not.c
Created October 1, 2016 19:37
This C program checks an input number and replies with the result after checking if the number is prime.
#include <stdio.h>
int main() {
int number;
printf("Enter your number:\n");
scanf("%d", &number);
if (number > 3){ // 1,2,3 are prime for sure; verification starts for bigger numbers;
for (int i = 2; i<number; i++){
if (number % i == 0){
printf("The number is not a prime number.\n");
@towkir
towkir / cgpa_checker.c
Created September 28, 2016 15:31
This C program takes a number(mark) as input and returns the grade of that number(mark)
#include <stdio.h>
int main() {
int mark;
printf("Enter your mark:\n");
scanf("%d", &mark);
if (mark <= 100){ //dive in only if mark is less than 100. mark can be negative too
if (mark >= 79) {
printf("Your grade is A+\n");
} else if (mark >= 69) {
@towkir
towkir / positive_or_negative.c
Created September 24, 2016 14:48
This C program checks a number from input and returns if it is positive or negative.
#include <stdio.h>
//a program that checks if a number is positive or negative or nutral
int main() {
int number;
printf("Enter your number:\n");
scanf("%d", &number);
if (number > 0) {
printf("The number is positive");
} else if (number < 0){
printf("The number is negative");
@towkir
towkir / odd_or_even.c
Created September 24, 2016 14:46
This C program checks a number from input and returns if it is even or odd number.
#include <stdio.h>
//a program that checks if a number is Even or Odd
int main() {
int number;
printf("Enter your number:\n");
scanf("%d", &number);
if (number % 2 == 0) {
printf("The number is Even");
} else {
printf("The number is Odd");