Weekly Coder
95 subscribers
84 photos
6 videos
1 file
73 links
Byte sized weekly coding challenges to hone your problem-solving prowess.
Download Telegram
⏰ Wake Up Call

I remember a small Alarm app being one of my earliest projects after getting introduced to computer programming, and specifically Processing.

Though Windows 10 has one, let's pretend we're in the Windows 7 era (as was the case for me), and create a simple alarm app.

πŸ₯… Goal: Take time (in seconds, at first) and count down to 0 and sound the alarm.

✏️ Recommended Learning:
- libraries, minim
- .play (), .pause ()
- millis ()

🦢 Get Started with this audio example code.

⚑️ Bring the Thunder:
- Move past taking duration and take as input set time in the future
- Implement the options Dismiss
- Implement the option to Snooze
- Include a custom inserted text to appear along with the alarm sound

βš™οΈ Don't forget to add the minim audio library like this.

πŸ“… Submissions: Sunday Morning, 2:00 LT

πŸͺ Send your submissions in the comments.

@WeeklyCoder | Week 27
πŸ‘¨β€πŸ’»1
4️⃣ Connect Four

Let's create another simple game as this week's Coding Challenge.

πŸ“Ό Watch this 20 second video to understand the workings of the game.

πŸ₯… Goal: Recreate the game Connect Four with your favorite programming language and environment.

✏️ Recommended Learning:
- Integer, color
- IntList, .append (), .get ()
- keyReleased (), str ()

🦢 Get Started with this starting code.

πŸ› Fix the bug: In the starting code, the disks are arranged upside down. Fix this bug to let them 'fall' down.

πŸ“… Submissions: Sunday Morning, 2:00 LT

πŸͺ Send your submissions here.

@WeeklyCoder | Week 28
πŸ‘¨β€πŸ’»1
⚠️ "Energy flows where attention goes" β€” T.R.

How much of your attention is going where you want it to when you're on a computer?

We're getting that figured on this week's coding challenge!

πŸ₯… Goal: To make a simple active window tracking program to determine the most used apps.

✏️ Recommended Learning:
- Intict, key, value
- set (), size (), get (), hasKey ()
- increment operator

🦢 Get started: Here's a starting code with the JNA library included in the 'code' folder. It contains a function to get title of the focused window.

🐾 Steps: Start by obtaining the current title of the active window. Check if the title has been stored before. If it is new, count it as one. If old, increment the prev count by 1. Sort the stored item values (counts) and get the keys (titles).

πŸ“… Submissions: Sunday Morning, 2:00 LT

πŸͺ Send your submissions here.

@WeeklyCoder | Week 29
πŸ”₯1πŸ‘¨β€πŸ’»1
πŸ“ 8.764868, 38.999322

Feather light coding challenge for y'all this week.

πŸ₯… Goal: Calculate the distance between two points on the Earth's surface given two coordinates as latitude and longitude.

✏️ Recommended Learning:
- Haversine Formula
- asin (), sin (), cos (),
- sqrt (), pow (), radians ()

🐾 Steps: Start by studying Haversine Formula. Then convert each equation to programmatic expression.

βž• Testing coordinates:
Point 1: [8.76484622069578, 38.99934027941346]
Point 2: [8.945679343541766, 39.20198679710532]

πŸ“… Submissions: Sunday Morning, 2:00 LT

πŸͺ Send your submissions in the comments.

@WeeklyCoder | Week 30
πŸ‘¨β€πŸ’»1
⚑️Counting Flashes

Digital electric meters have an LED that flashes with each pulse, allowing for visual monitoring of energy consumption in real time.

*pulse here is a small and fixed amount of energy passing through the meter.

Pulse Rate is a common metric found on such meters [Unit imp/kWh].

✏️ Example: 3200 imp/kWh would indicate that for every kilowatt-hour (kWh) of electricity consumed, the meter will produce 3200 pulses (impulses).

πŸ₯… Goal: Write a program to calculate the total energy consumed in kWh given number of pulses and the imp/kWh of a meter.

πŸ–Ό Example photo of such a meter here.

πŸ“… Submissions: Sunday Morning, 2:00 LT

πŸͺ Send your submissions in the comments.

@WeeklyCoder | Week 31
πŸ‘¨β€πŸ’»1
πŸ”‚ Recursion Time

Let's do this math together. It's simple, add the digits in the numbers:
- 456381901
- 342999002
- 304072023

If you added the digits of each and the obtained result's digits iteratively until you get just a single digit, you'll notice the sums are: 1, 2, and 3 respectively.

Eg: 4567295

4+5+6+7+2+9+5 = 38
3+8 = 11
1+1= 2

Here's the neat thing. If you removed all 9's and all numbers that add up to 9, the sum of the digits will remain the same.

Eg: 4567295

Remove 9
Remove 4 & 5 because 4+5= 9
Remove 7 & 2 because 7+2=9
That leaves: 6 and 5

6+5 = 11
1+1 = 2

πŸ₯… Goal: Write a program to calculate the sum of each digit within a given integer iteratively/recursively until the sum of the resulting sum itself is a single digit.

✏️ Recommend Learning:
- Recursion

⚑ Bring the thunder:
- Remove numbers adding up to 9 and all 9's from the number before adding and see where that takes you.

πŸ“… Submissions: Sunday Morning, 2:00 LT

πŸͺ Send your submissions in the comments.

@WeeklyCoder | Week 32
πŸ‘¨β€πŸ’»1
πŸ€ͺ Tongue Twisters Time

Tongue twisters are playful phrases designed to challenge pronunciation by featuring repetitive sounds or combinations of words that are difficult to articulate quickly and accurately.

No actual tongue twists following from tongue twisters is probably a tender twist of tongue twisters.

πŸ₯… Goal: Given a tongue twister as a String, determine a word that's most likely responsible for the phrase being a tongue twister.

🍁 Example:
Given this: If Kantie can tie a tie and untie a tie, why can’t I tie a tie and untie a tie like Kantie can.

Output would be: 'tie'

✏️ Recommended Learning:
- StringDict
- Levenshtein distance (org.apache.commons.text.similarity.LevenshteinDistance
)
- Nested loops

πŸ“… Submissions: Sunday Morning, 2:00 LT

πŸͺ Send your submissions in the comments.

@WeeklyCoder | Week 33
πŸ‘¨β€πŸ’»1
β˜„οΈ Icy Mudballs

The last apperance of the comet Hale-Bopp (called Hale Comet for short) was back in April 1, 1997. The orbital period of Hale is approximately 2,533 years.

It's next appearance would thus be: 1997 + 2533 = 4530.

πŸ₯… Goal: Write a program to determine how many times the Hale Comet would appear in a Megannum (a 1,000,000 years).

✏️ Recommended Learning:
- operators: modulo, division

πŸ“… Submissions: Sunday Morning, 2:00 LT

πŸͺ Send your submissions in the comments.

@WeeklyCoder | Week 34
πŸ‘¨β€πŸ’»1
πŸͺ So, how much do you weigh?

πŸ₯… Goal: Given the g (acceleration due to gravity in m/sΒ²) of the planets in our solar system, write a computer program that takes in weight on Earth and calculates weight on all other planets.

🍁 Gravity Values (in m/s²):
Mercury: 3.7 | Venus: 8.87 | Earth: 9.81
Mars: 3.71 | Jupiter: 24.79 | Saturn: 10.44
Uranus: 8.69 | Neptune: 11.15 | Pluto (though not really a planet): 0.62

✏️ Recommended Learning:
- operators: division
- PImage, loadImage (), image ()

⚑️ Bring the thunder:
- Spice this up by getting creative and adding in some graphics to it.

πŸ“… Submissions: Sunday Morning, 2:00 LT

πŸͺ Send your submissions in the comments.

@WeeklyCoder | Week 35
πŸ‘¨β€πŸ’»1
🟩 + 🟩 = ⬛️ + 🟦 [3min challenge]

This week's challenge is so easy, you could solve it in just a single line of code!

Students are to be paired for a group work. The idea is to have optimal pairs of proficient students in different subjects.

The assumption is that, a student proficient in one subject isn't necessarily proficient in another. Meaning having a pair of students both proficient in the same subject is undesirable.

String phy_pro_students [] = {"Diana", "Lisa", "Margaret", "Monica", "John"};
String bio_pro_students [] = {"Dalton", "Ford", "Homer", "Tina", "Mia"};


Output it like this:
Pair 1: Diana - Dalton
Pair 2: Lisa - Ford
...

⚑️ Bring the thunder
- Though you have access to the above two String Arrays, you are to use the following alphabetically ordered version to make the pairs. [Here's the Array]

Green on Green Makes Black and Blue

πŸ“… Submissions: Sunday Morning, 2:00 LT

πŸͺ Send your submissions in the comments.

@WeeklyCoder | Week 36
πŸ‘¨β€πŸ’»1
πŸ‘‘ Zhhnoa Frghu!

It's Caesar's Cipher time!

Inspired by Julius Caesar, who used this method to protect his private messages, the challenge for this week is is to create a program that shifts each letter in a given String by 3 places.

Eg: If the shift is 3,
a becomes d | b > e | c > f | e > g | ... z > c

Can you crack the code and reveal the hidden title above?

⚑️Bring the thunder!
Click here for 3 increasingly difficult versions of the challenge.

🎁 Though maybe not the clearest at first glance, it* surely can be done in just one line of code. If you do, and are the first of three (unique) implementations to do and post it in the comments, something πŸ˜‹ may await you.

*Either the encryption or decryption of the bare minimum of the challenge.


πŸ“… Submissions: Sunday Morning, 2:00 LT

πŸͺ Send your submissions in the comments.

@WeeklyCoder | Week 37
🌐 It's JSON time!

This week's challenge brings you a stage to work with APIs. Head over to openexchangerates.org/signup/free and sign up and get your API Key.

Extract rates desired (eg. USD (base) to ETB). Use the data you obtained to:
- convert from one currency to another
- create a digital currency exchange board

🌱 Get started with these two barebones.
Example 1 | Example 2

🎁 Prizes of last week will be delivered at the Book Club Meetup this Saturday, Jul 6.

πŸ“… Submissions: Sunday Morning, 2:00 LT

πŸͺ Send your submissions in the comments.

@WeeklyCoder | Week 38
πŸ‘1
πŸ“¬ But can you validate an email?

Something super simple for you this week.

Let's implement a program that takes an email address as input and displays whether it is valid or not.

An email is considered valid if is in the format: username@domain.extension

⚑️ Bring the thunder!
- Introduce a user interface and add in animations too

πŸ“… Submissions: Sunday Morning, 2:00 LT

πŸͺ Send your submissions in the comments.

@WeeklyCoder | Week 39
πŸͺ„ Reminiscence time!

Let's recreate a very old game called Magic Paper this week.

The game is simple. You pick any two-digit number. You then add the two digits together. You then subtract the result from the original number.

Example: Let's say you picked 32
3 + 2 = 5
32 - 5 = 27
You then take this result and look for a symbol labeled 27.

Now, the point of the game is to, 'Magically' predict what sign you landed on.

So after you have picked your two-digit number, the game would let you see the list of symbols. And without any input form you whatsoever, it'll show you the symbol you saw.

Check out the screenshots of the original game here.

⚑️ Could you crack the "Magic" powering this game and recreate it?

πŸ“… Submissions: Sunday Morning, 2:00 LT

πŸͺ Send your submissions in the comments.

@WeeklyCoder | Week 40
πŸ” S is for Secure

This week, let's make a password strength checker to evaluate the security of a password.

Unauthorized access can come in forms of: brute force attacks, dictionary attacks, and guessing attacks

A strong password typically includes a mix of different character types (uppercase, lowercase, digits, special characters) and avoids common patterns or easily guessable information

πŸ₯… Goal: Let a user input their password and output its strength basing this list of evaluation criteria (as many as possible).

⚑️ Bring the thunder!
- How many of the evaluation criteria can you implement?
- Provide feedback on how to make the password stronger?
- Introduce some descent User Interface to make this more engaging and real-time interactive?

πŸ“… Submissions: Sunday Morning, 2:00 LT

πŸͺ Send your submissions in the comments.

@WeeklyCoder | Week 41
πŸ‘1
πŸ‘€ Last seen 42minutes ago

Quick one for ya this week.

πŸ₯… Goal: Given the number of milliseconds that have passed since the last time a user was active on an app, display their last seen.

Examples:
- 5000 -> Just now
- 62000 -> A minute ago
- 300000 -> 5 minutes ago
- 7200000 -> 2 hours ago
- +

⚑️ Bring the thunder!
A UNIX epoch time is the number of seconds* which have passed since 00:00:00 UTC β€” Jan 1, 1970.

As of writing this, it's 1722623321000. Supposing that's the last time a user was on the app, how long ago would their be their last seen?

* Excluding leap seconds

πŸ“… Submissions: Sunday Morning, 2:00 LT

πŸͺ Send your submissions in the comments.

@WeeklyCoder | Week 42
πŸ—Ί But do you see art?

Let's see how creative and artistic you can get this week!

πŸ₯… Goal: Base the given image of the world map in just two colors (0 - Black, and 255 - White) to create some form of art β€” any kind.

✏️ Recommended Learning:
- PImage, resize ()
- strokeCap ()
- .get (x, y) // for PImage
- saveFrame ()

// Image of this post was created using these above

πŸ“… Submissions: Sunday Morning, 2:00 LT

πŸͺ Send your submissions in the comments.

@WeeklyCoder | Week 43
🎲 Lucky? Prove it!

Let's play craps!

Craps is a fast-paced dice game where players bet on the outcome of rolls. The main goal is to predict whether the shooter will win or lose based on the numbers rolled.

One of the main bets you can make in the game of Craps is Pass Line Bet. Here's how to play it [Simplified]:

πŸ₯… Goal: Recreate the Pass Line Bet based on the description.

✏️ Recommended Learning:
- PImage
- random ()
- casting, loops

⚑️ Bring the Thunder!
- Use images images of dice to reveal a roll than just numbers in a console
- Use image of a casino or Craps table in the background to make it more appealing
- Add in rolling sounds of dice
- Include other types of bets than just Pass Line Bet

πŸ“… Submissions: Sunday Morning, 2:00 LT

πŸͺ Send your submissions in the comments.

@WeeklyCoder | Week 44
🧩 Unscrambling time!

Another game for ya this week!

πŸ₯… Goal: is to take a scrambled set of words and piece them back together into a meaningful sentence.

In this game, the computer will scramble words of a random sentence, and players win if they rearrange the words in the right order.

✏️ Recommended Learning:
- loadStrings ()
- split(), random()
- loops and conditionals

⚑️ Bring the Thunder!
- Introduce a non binary scoring system. Use Levenshtein's distance perhaps?
- Add a count down timer to turn the heat up on a player.
- Let the scoring system factor in time β€” the shorter the time the better.
- Use a hint system to reveal a word in the correct position .
- Include a bank of sentences to increase difficulty as you progress.

πŸ“… Submissions: Sunday Morning, 2:00 LT

πŸͺ Send your submissions in the comments!

@WeeklyCoder | Week 45
πŸ›« Your nearest airport!

We're revisiting
Haversine to calculate the distance between two points on the Earth's surface given two coordinates as latitude and longitude.

πŸ₯… Goal: To build a program that takes a user’s current location (latitude and longitude) and displays a list of the top 5 nearest airports, showing their IATA codes and names.

πŸŽ’ Resource: Here's a JSON file listing details of airports of the world. [Details here]

✏️ Recommended Learning:

- Haversine Formula
- asin (), sin (), cos (),
- sqrt (), pow (), radians ()

🐾 Steps: Start by studying Haversine Formula. Then convert each equation to programmatic expression.

βž• Testing coordinate:
8.764846, 38.999340

πŸ“… Submissions: Sunday Morning, 2:00 LT

πŸͺ Send your submissions in the comments!

@WeeklyCoder | Week 46