init commit
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
# Club Challenges
|
||||
## Introduction
|
||||
**Welcome to Salt Lake Community College's Programming Club Challenges!**
|
||||
These challenges are designed for programmers of all skill levels. Each challenge has a "core" problem that should be accessible to all.
|
||||
Each challenge has progressively more difficult "bonus challenges" to test your programming knowledge.
|
||||
|
||||
## Getting Started with Basic Git Commands
|
||||
`git clone https://github.com/quaxlyqueen/club-challenges` ~ Makes a local copy of the repository on your machine.
|
||||
`git pull` ~ Retrieves the most recent changes from the "remote" repository (GitHub).
|
||||
`git branch NAME` ~ Creates a new branch called NAME. Substitute this with the changes you're making.
|
||||
`git checkout NAME` ~ Changes your current branch to NAME. The default branch is `main`.
|
||||
`git stage -A` ~ Prepares all of the changes in your local repository for a commit.
|
||||
`git commit -m "A message"` ~ Saves a snapshot of your local repository to your machine. You can revert back to this at anytime.
|
||||
`git push` ~ Uploads your changes onto the remote repository (GitHub).
|
||||
|
||||
While this may seem complex, for future club challenges you'd simply need to type in the terminal `git pull` to get the next challenge.
|
||||
|
||||
## Running Java code from the terminal
|
||||
`javac File.java` ~ Compiles your `.java` file into an executable `.class` file
|
||||
`java File` ~ Executes your `.class` file
|
||||
|
||||
## Shameless plug
|
||||
If you're interested in automating terminal commands, check out my scripts repo at <a href="https://github.com/quaxlyqueen/scripts">quaxlyqueen/scripts</a>.
|
||||
|
||||
## FAQ
|
||||
**What is Git?**<br />Git is an industry-standard **V**ersion **C**ontrol **S**ystem (VCS), that allows multiple programmers to work on projects together asynchronously.
|
||||
Git is a powerful **C**ommand **L**ine **I**nterface (CLI) tool, and GitHub is a way to visually interact with repositories.
|
||||
<br /><br />
|
||||
**What is a repository?**<br />A repository, or "repo", is a shareable project directory. There are two main types of repositories: remote and local.
|
||||
A remote repository is a directory hosted on a server, such as GitHub. Whenever you clone a repository onto your machine, you have a local repository.
|
||||
Think of this as a Google Docs for programmers, except instead of your changes being shared automatically, it is whenever **you** decide your changes
|
||||
are ready to be shared.
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Sum of Multiples of 3 or 5.
|
||||
*
|
||||
* In this week's club challenge, find the sum of each multiple of either 3 or 5, with the condition that the multiple is less than 1000.
|
||||
* eg. For multiples of 3 or 5 below 10, the answer would be the 3 + 5 + 6 + 9 = 23.
|
||||
*
|
||||
* Credit: Project Euler Problem 1.
|
||||
*/
|
||||
public class Week2 {
|
||||
|
||||
/**
|
||||
* HINT: Solution 1 uses 1000 iterations in 1 loop.
|
||||
*/
|
||||
public static int problem1() {
|
||||
return -1; // TODO
|
||||
}
|
||||
|
||||
/**
|
||||
* BONUS CHALLENGE: Find a more efficient solution for problem 1 (ie. a solution that uses less than 1000 iterations).
|
||||
*/
|
||||
public static int problem2() {
|
||||
return -1; // TODO
|
||||
}
|
||||
|
||||
/**
|
||||
* Test driver should not be edited!
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
int sum1 = problem1();
|
||||
int sum2 = problem2();
|
||||
|
||||
System.out.println(sum1 == 233168 ? "Problem 1 is correct!" : "Problem 1 (" + sum1 + ") is not correct...");
|
||||
System.out.println(sum2 == 233168 ? "Problem 2 is correct!" : "Problem 2 (" + sum2 + ") is not correct...");
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* In this week's club bonus challenges, you will be tasked with solving problems relating to the Fibonacci Sequence.
|
||||
*
|
||||
* For those unfamiliar, the Fibonacci Seuqence is generated by adding the prior two terms. Starting with 1 & 2, The
|
||||
* first 10 terms are 1, 2, 3, 5, 8, 13, 21, 34, 55, 89.
|
||||
*/
|
||||
public class Week4 {
|
||||
|
||||
/**
|
||||
* Only consider terms of the Fibonacci Sequence below 4 million. Find the sum of only the even terms.
|
||||
* eg. The first 5 terms counted would be 2, 8, 34, 144, 610, . . ., and the sum of those terms is 366.
|
||||
*
|
||||
* Credit: Project Euler Problem 2.
|
||||
* HINT: If your algorithm works for terms below 200, it'll work for the terms below any value.
|
||||
*/
|
||||
public static int problem1() {
|
||||
return -1; // TODO
|
||||
}
|
||||
|
||||
/**
|
||||
* Write an algorithm that will calculate the nth EVEN term of the Fibonacci Sequence.
|
||||
*
|
||||
* HINT: This only requires a minor modification to your solution for Problem1.
|
||||
*/
|
||||
public static int problem2(int n) {
|
||||
return -1; // TODO
|
||||
}
|
||||
|
||||
/**
|
||||
* Write an algorithm that finds the first EVEN term of the Fibonacci Sequence that has n digits.
|
||||
* eg. if n = 3, value = 144.
|
||||
*
|
||||
* Then, find the average of all of the EVEN terms up to this value.
|
||||
*/
|
||||
public static double problem3(int n) {
|
||||
return -1.0; // TODO
|
||||
}
|
||||
|
||||
/**
|
||||
* Test driver should not be edited!
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
int sum1 = problem1();
|
||||
int sum2 = problem2(10);
|
||||
double avg3 = problem3(5);
|
||||
|
||||
System.out.println(sum1 == 4613732 ? "Problem 1 is correct!" : "Problem 1 (" + sum1 + ") is not correct...");
|
||||
System.out.println(sum2 == 196418 ? "Problem 2 is correct!" : "Problem 2 (" + sum2 + ") is not correct...");
|
||||
System.out.println(avg3 == 2046.0 ? "Problem 3 is correct!" : "Problem 3 (" + avg3 + ") is not correct...");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user