Skip to content

Commit cfd6aa6

Browse files
authored
Merge branch 'code-differently:main' into lj-lesson-06
2 parents 28b0cd5 + 83d16b5 commit cfd6aa6

File tree

20 files changed

+6229
-2
lines changed

20 files changed

+6229
-2
lines changed

.devcontainer/devcontainer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@
3535
"ms-dotnettools.csdevkit",
3636
"ritwickdey.LiveServer",
3737
"mechatroner.rainbow-csv",
38-
"alexcvzz.vscode-sqlite"
38+
"alexcvzz.vscode-sqlite",
39+
"Orta.vscode-jest",
40+
"firsttris.vscode-jest-runner"
3941
],
4042
"settings": {
4143
"terminal.integrated.defaultProfile.linux": "zsh",
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Check Lesson 07 Pull Request
2+
3+
on:
4+
pull_request:
5+
branches: [ "main" ]
6+
paths:
7+
- "lesson_07/conditionals/**"
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Use Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: '20.x'
23+
24+
- name: Build Shared Lib with Node.js
25+
working-directory: ./lib/typescript/codedifferently-instructional
26+
run: npm ci
27+
28+
- name: Build Lesson 07 with Node.js
29+
working-directory: ./lesson_07/conditionals
30+
run: |
31+
npm ci
32+
npm run check

.github/workflows/check_push.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,10 @@ jobs:
6262
npm ci
6363
npm run compile
6464
65+
- name: Build Lesson 07 with Node.js
66+
working-directory: ./lesson_07/conditionals
67+
run: |
68+
npm ci
69+
npm run compile
70+
6571

lesson_04/xaviercruz/README.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
## Java Implementation
2+
3+
```java
4+
5+
public class Main{
6+
public static void main(String args[]){
7+
8+
System.out.println(isPrime(3)); // Output: true
9+
System.out.println(isPrime(4)); // Output: false;
10+
}
11+
12+
13+
public static boolean isPrime(int n){
14+
if (n <= 1) {
15+
return false;
16+
}
17+
for (int i = 2; i < Math.sqrt(n); i++) {
18+
if (n % i == 0) {
19+
return false;
20+
}
21+
}
22+
return true;
23+
}
24+
}
25+
26+
27+
```
28+
29+
## Python Implementation
30+
31+
```python
32+
33+
def is_prime(n: int) -> bool:
34+
if n <= 1:
35+
return False
36+
for i in range(2, int(math.sqrt(n)) + 1):
37+
if n % i == 0:
38+
return False
39+
return True
40+
41+
print(is_prime(3)) # Output: true
42+
print(is_prime(4)) # Output: false
43+
44+
```
45+
46+
## Explanation
47+
48+
### Core Differences
49+
50+
**Syntax**:
51+
52+
- Java: Java requires explicit class definitions, and all code must reside within a class. The main method is the entry point of the application. Java uses semicolons to terminate statements and curly braces to define blocks of code.
53+
54+
- Python: Python has a more concise and readable syntax, using indentation to define blocks of code without the need for curly braces or semicolons. There is no need for an explicit main method; you can simply write functions at the top level.
55+
56+
**Type Declaration**:
57+
58+
- Java: It is a statically typed language, meaning variable types must be declared explicitly (e.g., `int n`). This can help catch type-related errors at compile time.
59+
60+
- Python: Python is dynamically typed, allowing variables to be assigned without explicit type declarations. Type hints can be used (as seen in `n: int`), but they are not enforced at runtime.
61+
62+
**Libraries and Imports**:
63+
64+
- Java: You need to import specific libraries (e.g., `Math` for square root calculations) explicitly.
65+
66+
- Python: The math library needs to be imported, as shown in the Python implementation. However, the import syntax is simple (`import math`), and Python's built-in functions often eliminate the need for additional libraries.
67+
68+
**Boolean Representation**:
69+
70+
- Java: Uses `true` and `false` (with a lowercase 'T' and 'F') for boolean values.
71+
72+
- Python: Uses `True` and `False` (with a capital 'T' and 'F') but it’s more flexible with types and doesn’t require strict boolean checks.
73+
74+
### Core Similarities
75+
76+
**Logic of Prime Detection**:
77+
78+
- Both implementations use a similar logic to determine if a number is prime:
79+
- A number less than or equal to 1 is not prime.
80+
- The algorithm checks for divisibility from 2 up to the square root of the number.
81+
- If any divisor is found, the number is not prime; otherwise, it is prime.
82+
83+
**Control Structures**:
84+
85+
- Both languages employ similar control structures such as if statements and for loops. The iteration over possible divisors is done using a loop, and the logic to return a boolean value is consistent.
86+
87+
**Functionality**:
88+
89+
- Both implementations return a boolean value indicating whether the input number is prime.
90+
91+
## Conclusion
92+
Both Java and Python successfully implement a prime number detection algorithm with logical similarities and notable differences in syntax, type handling, and structure. The choice between the two languages often comes down to the specific use case, existing codebase, or personal preference, as each offers unique advantages. Java's robustness and performance are great for large-scale applications, while Python's simplicity and readability are ideal for rapid development and scripting.

lesson_05/josephcaballero/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# User Stories
2+
3+
## User Story 1
4+
As a Store Owner I want to be able to track my inventory more effectively so that I take less losses and don't show false inventory.
5+
6+
## User Story 2
7+
As an Internet user I want to be able to go online without ads popping up left and right so i dont get distacted or even irritated
8+
9+
## User Story 3
10+
As a Website Visitor I want to be able to effectively be able to traverse the website on any device and not be blinded by the colors or have to squint to see anything so I can have a good viewing experience.
11+
12+
# Finding Bugs
13+
14+
## Dark Mode Bug
15+
Upon clicking the dark mode button the screen didnt change color only the top bar did, not only that the bar actually made it so some of the buttons weren't able to be seen and even changed one.
16+
17+
## Sidebar Text Deletion
18+
Upon clicking the sidebar and collapsing it I was greeted with more than I expected when the sidebar actually got rid of the respective text but also the tab for today's tasks seemed to have also been removed as well when collapsing the sidebar.
19+
20+
## Creating New Tasks
21+
When trying to create new tasks I see that my text disappears after I press the "add task" button and only reappears when I reload the page or log back in .

lesson_07/README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,12 @@ Please review the following resources before lecture:
1010

1111
## Homework
1212

13-
TODO(anthonydmays): Finish this
13+
- [ ] Complete [Conditionals and Loops](#conditionals-and-loops) exercise.
14+
- [ ] Do pre-work for [lesson 08](/lesson_08/).
15+
16+
## Conditionals and Loops
17+
18+
This exercise will provide you ample opportunities to practice your understanding of conditional expressions and loops. To complete this assignment, implement the functions in [lesson7.ts][lesson7-file], ensure the tests pass, and submit a PR. Remember to use the [Conventional Commits][conventional-commits] spec for your commit messages and pull requests.
19+
20+
[lesson7-file]: ./conditionals/src/lesson7.ts
21+
[conventional-commits]: https://www.conventionalcommits.org/en/v1.0.0/

lesson_07/conditionals/.editorconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
insert_final_newline = true

lesson_07/conditionals/.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build/
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Ignore artifacts:
2+
build
3+
coverage

lesson_07/conditionals/.prettierrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

0 commit comments

Comments
 (0)