Skip to content

Instantly share code, notes, and snippets.

@notsoluckycharm
notsoluckycharm / app.cpp
Created February 28, 2020 22:03
recursive array join by seperator
/*(Print an array) Write a recursive method that display all the
elements in an array of intergers, separated by spaces. */
#include<iostream>
#include<string>
using namespace std;
string recursiveJoin(int arr[], string seperator, int size, int index=0)
{
if (index == size - 1) {
@notsoluckycharm
notsoluckycharm / beeswax.js
Last active March 30, 2018 16:30
Beeswax code challenge
// Timed response to problem:
// https://drive.google.com/file/d/0B4I3zDNqwzpCZ1BmbTN6TEJxTGVYZWV5WEtTR3BmZ08zdlF3/view
// time taken: 8 minutes.
let strings = [
'hello world',
'{} ',
'{{{foo();}}}{} ',
'{{}{}} ',
@notsoluckycharm
notsoluckycharm / coin_machine.js
Created March 7, 2018 02:44
Given an input, return the least change possible
const denomizations = [ .01, .05, .1, .25, .5, 1.0 ];
const input = .75;
function returnLeastChange(input = 0, change = {}, denomizations = []){
let pointer = 0;
const toReturn = {};
let newInput = input;
while(pointer < denomizations.length - 1){
const x = denomizations[pointer];
if(x <= newInput ){
@notsoluckycharm
notsoluckycharm / index.js
Last active February 26, 2018 11:50
CodeCademy Bowling
/**
# Given an array that represents **individual rolls** of a player in a game bolwing,
# write an algorithm to score the game.
#
# Example:
#
# Note: each score is a roll
# scores = [10,7,3,7,2,9,1,10,10,10,2,3,6,0,7,3,3]
# max = 22 rolls (10 frames + last spare -> bonus roll)
# spare score == 110
/** Find the number of occurances of a substring within another string, occurances do not need to be
* in immediate sequence. for example the pattern ab will match with (a)(b)xcy(a)z(b) for an answer of 3
*
*/
var strPos = function( string, substring ){
var count = 0;
if( substring.length > 0 ){
var pos = 0;
string.split('').forEach(function(character){
pos += 1;
@notsoluckycharm
notsoluckycharm / gist:56b414cd3c458a7355e8
Last active August 29, 2015 14:06
Retrieve Attendance Taken As a Percentage ( times taken / time should have taken ) For All Courses Taught At Schools Associated With A Specific Account For The Entire Year
select first_name, last_name, last_sign_in_at, days_taken, days_total, days_taken / days_total as performance
from(
SELECT tmp.user_id, sum( days_taken ) as days_taken, sum( days_total ) as days_total
FROM account_user
inner join account_institution on account_institution.account_id = account_user.account_id
inner join courses_institutions on courses_institutions.institution_id = account_institution.institution_id
left outer join (
SELECT courses_users.user_id, courses_users.course_id, count(*)::decimal as days_taken, courses_users.role,
(
SELECT count(*)::decimal
/**
* Add a General Comment to the Mongo reporting collection
* Goal: Should be of similar nature to /webapp/../java/../pages/UserReport.java
* Accepts: email
* subject
url
comment
sig
tag
*/