Skip to content

Instantly share code, notes, and snippets.

@ianmuge
ianmuge / starwars_celebration.py
Created October 23, 2019 20:01
hackajob star wars celebration task
import urllib.request as req
import json
base_url="https://challenges.hackajob.co/swapi/api/"
film_search_url=base_url+"films/?search="
people_search_url=base_url+"people/?search="
class Solution:
def run(self, film, character):
#films by character
films_char=None
@ianmuge
ianmuge / english_classroom.py
Created November 7, 2019 20:56
Morse Code to English and vice versa function
class Solution:
def run(self, morseToEnglish, textToTranslate):
correlation = {'A': '.-', 'B': '-...', 'C': '-.-.',
'D': '-..', 'E': '.', 'F': '..-.',
'G': '--.', 'H': '....', 'I': '..',
'J': '.---', 'K': '-.-', 'L': '.-..',
'M': '--', 'N': '-.', 'O': '---',
'P': '.--.', 'Q': '--.-', 'R': '.-.',
'S': '...', 'T': '-', 'U': '..-',
'V': '...-', 'W': '.--', 'X': '-..-',
@ianmuge
ianmuge / football_scores.php
Created November 7, 2019 22:44
Get total scores of any team in 2014-2015 season
<?php
function run($teamKey)
{
/*
* Some work here; return type and arguments should be according to the problem's requirements
*/
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://raw.githubusercontent.com/openfootball/football.json/master/2014-15/en.1.json");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
@ianmuge
ianmuge / movie_collection.php
Created November 8, 2019 00:16
Hackajob Movie collection challenge
<?php
function run($n, $m, $movies) {
$init_array=range(1,$n);
$to_out=[];
foreach ($movies as $mov){
$key=array_search($mov,$init_array);
if($key==0){
array_push($to_out,($key));
}else{
array_push($to_out,($key));
@ianmuge
ianmuge / install.sh
Last active November 22, 2019 22:21
plaidml setup and initialization
pip install plaidml plaidml-keras plaidbench keras
pip install tensorflow
plaidml-setup
@ianmuge
ianmuge / fizzbuzz.php
Created February 28, 2020 14:31
FizzBuzz
function fizzBuzz($n) {
$output=[];
foreach (range(1,$n,1) as $val){
if(($val % 5)==0 and ($val % 3)==0){
$output[]="FizzBuzz";
}elseif (($val % 3)==0){
$output[]="Fizz";
}elseif (($val % 5)==0){
$output[]="Buzz";
}else{
@ianmuge
ianmuge / index.html
Created February 29, 2020 01:54
React form progressbar
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous" />
</head>
<body style="margin: 0;">
<div id="app"></div>
</body>
</html>
@ianmuge
ianmuge / fizzbuzz.py
Created February 29, 2020 01:55
FizzBuzz
def fizzBuzz(n):
output=[]
for val in range(1,n+1,1):
if((val % 5)==0 and (val % 3)==0):
output.append("FizzBuzz")
elif ((val % 3)==0):
output.append("Fizz")
elif ((val % 5)==0):
output.append("Buzz")
else:
@ianmuge
ianmuge / min_flips.py
Created April 1, 2020 11:08
Adjacent Coin problem
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def flip(c):
return 1 if (c == 0) else 0
def do_flips(A,exc):
cnt=0
for i,x in enumerate(A):
if x!=exc:
cnt+=1
@ianmuge
ianmuge / trustpilot.py
Created April 3, 2020 15:57
trustpilot backend/SRE challenge
"""
Author: Ian Muge
Date:
"""
import multiprocessing,threading,collections,itertools,hashlib,time
from pprint import pprint
"""
Base functions
"""