Skip to content

Instantly share code, notes, and snippets.

View AlinaWithAFace's full-sized avatar
🍑

Alina Christenbury AlinaWithAFace

🍑
View GitHub Profile
/*
https://goo.gl/z0Rk3j
Written in JavaScript
Background
Back in middle school, I had a peculiar way of dealing with super boring classes. I would take my handy pocket calculator and play a "Game of Threes". Here's how you play it:
First, you mash in a random large number to start with. Then, repeatedly do the following:
If the number is divisible by 3, divide it by 3.
If it's not, either add 1 or subtract 1 (to make it divisible by 3), then divide it by 3.
@AlinaWithAFace
AlinaWithAFace / [2016-06-13] Challenge #271 [Easy] Critical Hit
Last active June 28, 2016 14:42
[2016-06-13] Challenge #271 [Easy] Critical Hit
/*
https://www.reddit.com/r/dailyprogrammer/comments/4nvrnx/20160613_challenge_271_easy_critical_hit/
Description
Critical hits work a bit differently in this RPG. If you roll the maximum value on a die, you get to roll the die again and add both dice rolls to get your final score. Critical hits can stack indefinitely -- a second max value means you get a third roll, and so on. With enough luck, any number of points is possible.
Input
d -- The number of sides on your die.
h -- The amount of health left on the enemy.
/*
https://www.reddit.com/r/dailyprogrammer/comments/3ofsyb/20151012_challenge_236_easy_random_bag_system/
# Description
Contrary to popular belief, the [tetromino pieces](http://i.imgur.com/65G37Aq.png) you are given in a game of [Tetris](https://en.wikipedia.org/wiki/Tetris) are not randomly selected. Instead, all seven pieces are placed into a "bag." A piece is randomly removed from the bag and presented to the player until the bag is empty. When the bag is empty, it is refilled and the process is repeated for any additional pieces that are needed.
In this way, it is assured that the player will never go too long without seeing a particular piece. It is possible for the player to receive two identical pieces in a row, but never three or more. Your task for today is to implement this system.
# Input Description
@AlinaWithAFace
AlinaWithAFace / gglCalEventsOnSpreadSheet.gs
Created June 7, 2017 22:31 — forked from egorlitvinenko/gglCalEventsOnSpreadSheet.gs
Script to read Google Calendar Events and Count total Hours
/*
**Steps**
1. Go to your google Drive and start a new Empty SpreadSheet.
2. Go to the Menu: Tools --> Script Editor --> Blank Document.
3. Copy+paste the code into the new Code.gs and Save the File
4. Go to the Menu: Resources --> Advanced Google Services
5. Scroll till you find the **Calendar API** and turn it **ON**
6. Click On the Link to the **Google Developers Console.** *a new tab will open.*
7. In the SearchBox type Calendar and click on Calendar API and enable it.
8. Once enabled return to the window with the code and click OK to return.
@AlinaWithAFace
AlinaWithAFace / CISC-275-Iterators.java
Last active February 15, 2018 02:39
Some iterator basics and how concurrent modification errors happen
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.Random;
import static java.lang.Math.abs;
// DONE 1. Any problem from lecture exercises is fair game on the exam.
// DONE 2. Fill in the class below, making an ArrayList of Cows where appropriate. A Cow has a name. Read the entire
@AlinaWithAFace
AlinaWithAFace / FriedEggException.java
Created April 18, 2018 16:25
An example micro-program with an example exception and exception handling
//Write minimal code. You may not need all lines.
//A FriedEggException is a kind of Exception.
//Define a minimal FriedEggException to be used below.
class FriedEggException extends Exception {
public FriedEggException(String message) {
super(message);
}
}
@AlinaWithAFace
AlinaWithAFace / HashSetPractice.java
Created April 18, 2018 17:04
Here's a small example where we override a hashset's equals and hashcode functiosn in order to determind uniqueness ourselves
import java.util.HashSet;
/**
* Assume two cows are the same if they have the same name.
* Write class Cow and the necessary methods to make main this work, and put a print statement inside each method.
* Then on the lines next to each call to add, write what the methods would print.
*/
class HashSetPractice {
/*
* On the comment lines provided, write *all* that is printed as a
import java.io.*;
import java.util.*;
public class Solution {
// Write your code here.
Stack<String> stack = new Stack<>();
Queue<String> queue = new LinkedList<>();
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);