Skip to content

Instantly share code, notes, and snippets.

View primaryobjects's full-sized avatar

Kory Becker primaryobjects

View GitHub Profile
@primaryobjects
primaryobjects / defuse.js
Created November 22, 2016 01:50
[2016-11-21] Challenge #293 [Easy] Defusing the bomb
#
# [2016-11-21] Challenge #293 [Easy] Defusing the bomb
# To disarm the bomb you have to cut some wires. These wires are either white, black, purple, red, green or orange.
# https://www.reddit.com/r/dailyprogrammer/comments/5e4mde/20161121_challenge_293_easy_defusing_the_bomb/
# Demo at http://jsbin.com/fufohasawi/edit?js,console
#
# by Kory Becker
# http://primaryobjects.com
#
@primaryobjects
primaryobjects / goldilocks.R
Created November 10, 2016 02:14
[2016-11-07] Challenge #291 [Easy] Goldilocks' Bear Necessities
#
# [2016-11-07] Challenge #291 [Easy] Goldilocks' Bear Necessities
# Write a function that returns the rows for each chair weight and porridge temperature combination that satisifes Goldilocks.
# https://www.reddit.com/r/dailyprogrammer/comments/5bn0b7/20161107_challenge_291_easy_goldilocks_bear/
# Demo at http://www.r-fiddle.org/#/fiddle?id=gx70BvH8
#
# by Kory Becker
# http://primaryobjects.com
#
@primaryobjects
primaryobjects / starStruck.R
Created October 11, 2016 02:55
starStruck - Count the number of stars in the string, but only stars that are in a group of two or more.
#
# starStruck - Write a function that counts the number of stars in the input - but only Stars that are in a group of two or more count. Stars that appear by themselves don't count. Print the number of stars that count.
# https://www.reddit.com/r/dailyprogrammer/comments/56mfgz/weekly_26_mini_challenges/
# Demo at http://www.r-fiddle.org/#/fiddle?id=KSCKA9Gp&version=2
#
# by Kory Becker
# http://primaryobjects.com
#
starStruck <- function(input) {
@primaryobjects
primaryobjects / index.js
Last active December 15, 2019 07:02
Amazon Alexa books skill. Runs on chatskills. Reads data from Goodreads.com API of book ratings.
var alexa = require('alexa-app');
var chatskills = require('chatskills');
var readlineSync = require('readline-sync');
var xml2js = require('xml2js').parseString;
var request = require('request');
var deasync = require('deasync');
// Define an alexa-app
//var app = new alexa.app('books');
var app = chatskills.app('books');
@primaryobjects
primaryobjects / index.js
Last active July 12, 2018 20:38
Amazon Alexa books skill. Runs on alexa-app-server. Reads data from Goodreads.com API of book ratings.
var alexa = require('alexa-app');
//var chatskills = require('chatskills');
//var readlineSync = require('readline-sync');
var xml2js = require('xml2js').parseString;
var request = require('request');
var deasync = require('deasync');
// Define an alexa-app
var app = new alexa.app('books');
//var app = chatskills.app('books');
@primaryobjects
primaryobjects / array-sum-parity.txt
Last active October 7, 2016 23:27
Simple array and loop exercise.
1. Create a function that determines whether the sum of a list of numbers is even or odd.
The function should return true if the sum is even and false if the sum is odd.
Examples:
For the numbers 1, 2, 3 the function will return true.
For the numbers 2, 1, 4 the function will return false.
2. Create a function that determines whether the difference of a list of numbers is even or odd.
The function should return true if the difference is even and false if the difference is odd.
@primaryobjects
primaryobjects / arrays2.txt
Last active October 6, 2016 16:55
More simple loop exercises.
1. Create a function, using a for-loop, that takes a number as an argument and prints "Lesson X" for X-many times.
For example, if you call the function with the argument 3, it will print:
"
Lesson 1
Lesson 2
Lesson 3
"
2. Create another function, similar to the above, using a while-loop.
@primaryobjects
primaryobjects / arrays.txt
Last active October 5, 2016 21:17
Simple array and loop exercises.
A. Arrays
1. Initialize an array with the names of your family.
2. Add a new name to the array.
3. Add one more name to the array.
4. Print the second and third names in the array to the console.
5. Create an associative array containing a list of songs and their author, and print the first and last song to the console.
@primaryobjects
primaryobjects / revfact.R
Created October 4, 2016 22:32
Reverse Factorial Function
#
# [2016-10-04] Challenge #286 [Easy] Reverse Factorial Function
# https://www.reddit.com/r/dailyprogrammer/comments/55nior/20161003_challenge_286_easy_reverse_factorial/
# Your program should report what each number is as a factorial, or "NONE" if it's not legitimately a factorial.
#
revFac <- function(n, index = 2) {
remainder <- n / index
if (remainder > 1) {
revFac(remainder, index + 1)
@primaryobjects
primaryobjects / index.html
Last active September 22, 2016 03:16
[2016-09-21] Challenge #284 [Intermediate] Punch Card Creator
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
</head>
<body>
<div id="output"></div>