This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
**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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.*; | |
public class Solution { | |
// Write your code here. | |
Stack<String> stack = new Stack<>(); | |
Queue<String> queue = new LinkedList<>(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
OlderNewer