Skip to content

vkaraujo/DailyCodingProblem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧠 Daily Coding Problem Solutions

This repository contains my solutions to problems sent by the Daily Coding Problem site, which sends me one coding problem every day. The primary goal of this repository is to document my journey through these problems and share my solutions, primarily written in Ruby.

🧱 Project Structure

Each problem is contained in its own folder inside the problems/ directory. Each folder is named problem_XXX, where XXX is the problem number.

  • solutionXXX.rb: The Ruby script containing the solution.
  • solutionXXX_spec.rb: The RSpec test file for the solution.
  • Readme.md: A markdown file describing the problem.

✅ Running Tests

Tests are written using RSpec. To run all tests:

bundle exec rake rspec

You can also run a specific test file:

bundle exec rspec problems/problem_001/solution001_spec.rb

🗂 Problem Index

Problem # Title / Summary Link
001 Check if any two numbers in a list sum to a target value. View
002 Generate a product array where each element is the product of all others except itself. View
003 Implement serialization and deserialization of a binary tree. View
004 Find the first missing positive integer in an unsorted array using constant space. View
005 Recreate car and cdr from functional pairs using closures. View
006 Implement an XOR linked list using memory-efficient pointer manipulation. View
007 Count the number of valid decodings of a numeric string using letter mappings. View
008 Count the number of unival (single-value) subtrees in a binary tree. View
009 Implement a job scheduler that delays function execution by a specified time. View
010 Build an autocomplete system using efficient prefix matching. View
011 Estimate the value of π using the Monte Carlo simulation method. View
012 Design a fixed-size log to record and retrieve the last N entries efficiently. View
013 Minimize painting cost for houses with the constraint that adjacent houses cannot share the same color. View
014 Find the intersection node of two singly linked lists in linear time and constant space. View
015 Determine the minimum number of rooms required to schedule all overlapping time intervals. View
016 Reconstruct a sentence from a string using valid dictionary words, allowing multiple valid segmentations. View
017 Find the shortest path in a 2D grid while avoiding walls and only moving in four directions. View
018 Check if a string of mixed brackets is balanced and properly nested. View
019 Justify a list of words into lines of fixed length by distributing spaces evenly. View
020 Implement run-length encoding and decoding of alphabetic strings. View
021 Compute the minimum number of edits needed to transform one string into another. View
022 Perform run-length encoding and decoding on alphabetic strings to compress repeated characters. View
023 Determine the edit distance between two strings using insertions, deletions, and substitutions. View
024 Generate the power set of a given set, representing all possible subsets. View
025 Design a stack with push, pop, and constant-time max retrieval. View
026 Generate a uniform random number from 1 to 7 using only a function that returns 1 to 5. View
027 Calculate the maximum profit from a single buy-sell transaction on stock prices. View
028 Evaluate an arithmetic expression represented as a binary tree. View
029 Build a URL shortener that maps URLs to unique short codes and supports bidirectional lookup. View
030 Search for a target word in a 2D character matrix along horizontal and vertical paths. View
031 Print the elements of a matrix in a clockwise spiral order. View
032 Find the largest product possible from any three integers in a list. View
033 Find the n-th positive integer whose digits sum to exactly 10. View

🛠 Tooling & Extras

Simple-Cov report

To run a coverage report:

COVERAGE=true bundle exec rake

The image below is just an example and won't be updated in a regular manner Test Coverage

Flog

Flog gem repo Flog reports the most tortured code in an easy to read pain report. The higher the score, the more pain the code is in.

If you download the project you can use

flog . # to run it for the whole project
# or
flog path/to/file.rb # to run it for a specific file

Due to the complexity of the challenges, lowering the flog score was not a priority. I only installed it to experiment with it.

License

MIT License

Acknowledgments

Thanks to the "Daily Coding Problem" site for providing these challenging and interesting problems. This repository is not affiliated with the site but serves as a personal project to track and share my solutions.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages