Skip to content

Instantly share code, notes, and snippets.

@PierraKimathi-zz
PierraKimathi-zz / Munene.py
Created February 10, 2019 19:52
Munene Word Search
"""
Munene is extremely disappointed to find out that no one in the office knows his first name. Even his close mates call him only by his last name. Frustrated, he decides to make his fellow workmates know his first name by forcing them to solve this question.
You are given a long string as input in each testcase, containing any ASCII character. Your task is to find out the number of times SUVO and SUVOJIT appears in it.
Note: This problem CAN BE SOLVED IN Java, Python or PHP.
Input Format
The first line contains the number of testcases, T. Next, T lines follow each containing a long string S.
Output Format
For each long string S, display the no. of times SUVO and SUVOJIT appears in it."""
@PierraKimathi-zz
PierraKimathi-zz / leapyear.cpp
Created February 3, 2019 21:37
determining if a year is leap or not
bool IsLeapYear(int year)
{
return (!(year % 400) || (!(year % 4) && year % 100));
}
@PierraKimathi-zz
PierraKimathi-zz / leapyear.js
Created February 3, 2019 21:34
Determining if year is leap or not
function isLeapYear(year) {
return ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);
}
@PierraKimathi-zz
PierraKimathi-zz / leapyear.py
Created February 3, 2019 21:29
Determining if a number is leap or not
def isLeapYear(year):
if year % 100 == 0:
if year % 400 == 0 and year % 4 == 0:
return True
return False
elif year % 4 == 0:
return True
return False
@PierraKimathi-zz
PierraKimathi-zz / multiply.js
Created January 28, 2019 07:23
Simple multiplication
function simpleMultiplication(number) {
var multi =0;
if(number%2==0){
multi = number*8;
}else{
multi = number*9;
}
return multi;
console.log(multi)
}
@PierraKimathi-zz
PierraKimathi-zz / find_needle.js
Last active January 22, 2019 09:00
Find the word needle in a list
function find_needle(haystack) {
var needleIndex = haystack.IndexOf('needle');
return 'found the needle at position' + needleIndex;
}
find_needle(['hay', 'junk', 'hay', 'hay', 'moreJunk', 'needle', 'randomJunk'])
@PierraKimathi-zz
PierraKimathi-zz / reverse_words.py
Last active January 15, 2019 08:25
Reverse words in a sentence
def reverse_words(str):
return ' '.join(s[::-1] for s in str.split(' '))