Skip to content

Instantly share code, notes, and snippets.

View rafiq's full-sized avatar

Rafiq Kamal rafiq

View GitHub Profile
@rafiq
rafiq / doubleDoubles.js
Created January 26, 2021 04:48
Help me figure out why the 44 number is not working
/*
I have an error with the 44 argument. I think it has something to do with lines 24 to 27 where the logic is getting messed up due to it being such a small string. We may be able to just add another piece of logic to the if statement on line 22, but I am not sure what I would add.
I know I can solve this more simply by changing the numbers to a string and comparing the first of the string to the second half of the string, but I chose to use two pointers because it is more robust due to the fact that it can handle all character types which is why I want to use it.
INSTRUCTIONS:
A double number is an even-length number whose left-side digits are exactly the same as its right-side digits. For example, 44, 3333, 103103, and 7676 are all double numbers, whereas 444, 334433, and 107 are not.
Write a function that returns the number provided as an argument multiplied by two, unless the argument is a double number; return double numbers as-is.
*/
@rafiq
rafiq / gist:aefa84ff5ef9a4f02f8b67264d6abdf9
Created March 28, 2021 15:09
#1 Strings: Find The Longest Substring and Required Data. 6 kyu Code Wars JS
/*
We have to find the longest substring of identical characters in a very long string.
Let's see an example:
s1 = "1111aa994bbbb1111AAAAAFF?<mmMaaaaaaaaaaaaaaaaaaaaaaaaabf"
The longest substring in s1 is "aaaaaaaaaaaaaaaaaaaaaaaaa" having a length of 25, made of character, "a", with its corresponding ascii code equals to "97", and having its starting index 29 and the ending one 53.
We express the results using an array in the following order: ["97", 25, [29,53]]
from matplotlib import pyplot as plt
import math
import re
import heapq
from scipy.spatial.distance import hamming
import statistics
f = open("/Users/rafiqkamal/Desktop/Data_Science/RNAProject210110/RNAL20StructuresGSSizes.txt")
contents = f.readlines()
@rafiq
rafiq / RNAProject2.py
Last active November 17, 2021 04:30
This is the second iteration of the RNA structures project.
# -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
from matplotlib import pyplot as plt
import math
import re
@rafiq
rafiq / Common Patterns in Real Data
Last active December 3, 2021 16:33
Common Patterns in Real Data
import pandas as pd
import numpy as np
import KC
import matplotlib.pyplot as plt
windowSize = 5 #This is the length of a "good data" string
num_of_dots_allowed = 0 #How many dots are allowed in the "good data"
step = 1 #How many data points we skip (granulate the data)
fileName = "/Users/rafiqkamal/Desktop/Data_Science/timeSeries/Energy and Mining 50 series 200 plus entities World Bank.xlsx"#insert file name here
originalData = pd.read_excel(fileName)
@rafiq
rafiq / api.js
Created December 7, 2021 16:24
Practice booking app back end code
const express = require('express');
const router = express.Router();
const fs = require('fs');
const path = require('path');
const sqlite3 = require('sqlite3').verbose();
const db = new sqlite3.Database(path.join(__dirname, '../db/development.sqlite3'));
function sleep(time) {
const stop = new Date().getTime();
while(new Date().getTime() < stop + time) {
from numpy.core import numeric
import pandas as pd
import random
# from random import randrange
import numpy as np
import KC
import matplotlib.pyplot as plt
windowSize = 10 #This is the length of a "good data" string
@rafiq
rafiq / dataset
Last active January 8, 2022 14:18
dataset
[7.0, 8.1, 7.0, 7.0, 9.3, 7.0, 8.1, 9.3, 7.0, 7.0, 7.0, 5.8, 7.0, 8.1, 9.3, 7.0, 8.1, 7.0, 5.8, 9.3, 5.8, 7.0, 7.0, 8.1, 8.1, 7.0, 8.1, 2.3, 7.0, 5.8, 8.1, 2.3]
from datetime import date
import pandas as pd
import random
import numpy as np
import KC
import matplotlib.pyplot as plt
today = date.today()
current_date = today.strftime("%b-%d-%Y")
windowSize = 11 #This is the length of a "good data" string