New answers tagged programming-challenge
1
vote
Advent of Code 2023 - Day 2: Cube Conundrum
three variables for one concept
MAX_RED = 12
MAX_GREEN = 13
MAX_BLUE = 14
My first impression is that this will likely turn out to be inconvenient,
with three <...
1
vote
Advent of Code 2023 Day 3, Part 2 in Python
representation
What would you do differently?
You used many immutable strings to represent the schematic diagram.
Given that this spatially-oriented problem is asking us to examine
Moore ...
0
votes
Advent of Code 2023 day 1: Trebuchet in JS, part 2
Automatic Semicolon Insertion ASI
Generally your use of semicolons is consistent as preferred (use them rather than not) however there is one potential issue.
JavaScript requires semicolon. If you do ...
2
votes
Advent of Code 2023, Day 8 Part 1 - Beginner Rust Solution
I honed my Rust through Advent of Code as well, so welcome to the club. I can tell you with hindsight that trying to handle errors in a formal way for early days with relatively simple input ...
1
vote
Advent of Code 2023 day 1: Trebuchet (Part 1 and 2)
Don't assume all lines will fit into a fixed-size buffer
You use a buffer with a hardcoded size of 1024 characters. As you write in the comments, it suffices for the sample data. But what if you would ...
1
vote
Advent of Code 2023 day 1: Trebuchet in JS
Use functions
ALways encapsulate code in a function at the very minimum.
Example It should look something like...
...
2
votes
Accepted
Advent of Code 2023 day 1: Trebuchet
Bug
"1zero" is probably supposed to evaluate to 10. You don't handle the digit "zero".
Reversing the string
...
1
vote
Accepted
String represents a road. One character travels on the road obeying the stops - Code challenge (advent.js day 5)
carefully read the requirements
The original problem asks us to
Create a function that simulates the sled's movement ...
Somehow you leapt from that to
All must be in just one function.
I see no ...
3
votes
Advent of code 2023 day 4: Count scratchcard points - mostly in Bash
Got a tip from @choroba's alternative solution.
To conditionally initialize or update an entry in a map, instead of:
...
3
votes
Advent of code 2023 day 4: Count scratchcard points - mostly in Bash
one word per line
In nums_to_lines, these six lines follow a very clear pattern.
But it seems a bit long.
I tend to use ...
4
votes
Advent of code 2023 day 2: count possible qube games - in pure Bash
What would you do differently?
Well, choosing a language better suited to the task springs to mind, maybe python.
In particular, I find this inconsistency distracting when reading such scripts:
...
5
votes
Advent of code 2023 day 2: count possible qube games - in pure Bash
It's going to be a really minor thing, but a review is a review and thus doesn't belong in the comments.
I've learned that calling files solve_day2_part2 in an &...

Mast♦
- 13.1k
3
votes
Accepted
Advent of code 2023 day 1: count trebuchet calibration numbers - mostly in Bash
For me, bash solution would rather be something like this:
Part 1
...
0
votes
Print a hollow Rhombus
Imagine you know someone beginning Java three years after writing this.
You show them the code presented: Can they easily find out from looking at the code what it is to do?
Whether it is correct? Do ...
1
vote
HackerRank Algorithm Problem: Climbing the Leaderboard (Python)
My approach, described below, should definitely be an improvement. I have named my version climbing_leaderboard so as to not conflict with your name (I have ...
1
vote
Trailing Digits
finally I found a link with a lot of examples. I found trailingdigits.py with a much more elegant approach github.com/RussellDash332/kattis/blob/main/src/… and another webpage that shows more detail ...
1
vote
Accepted
Given an array, remove zero or more elements to maximize the reduction where you add odd values and subtract even values
You could simply use this pattern:
[greatest value, smallest value, greatest value, smallest value, ...]
local maximum, local minimum, ...
That means, go until ...
2
votes
Trailing Digits
Picture yourself coming back to "V1 code" a decade from now:
You can read it, you can run it.
Do you know what does, and to what end?
Name things for what they are good for.
...
2
votes
Project Euler 60: Prime Pair Sets
Eliminate 2 and 5 from your sieve!
Any 2+ digit prime cannot end in a 2 or a 5, as these will be multiples of ...
4
votes
HackerRank Project Euler 12 (Python) | Highly Divisible Triangular Numbers
Inaccuracy
Many Project Euler problems deal with BIG numbers. These often are large enough that int(number**0.5) will give you the incorrect result!
Mathematically,...
2
votes
Project Euler 10(Python) | Summation of Primes
It was clarified that this problem is the Hacker Rank version: https://www.hackerrank.com/contests/projecteuler/challenges/euler010/problem
This problem has the format of multiple test cases being ...
Top 50 recent answers are included
Related Tags
programming-challenge × 3335python × 1005
algorithm × 655
performance × 637
java × 635
time-limit-exceeded × 500
c++ × 480
python-3.x × 438
beginner × 425
c# × 303
javascript × 291
strings × 212
primes × 182
c × 152
functional-programming × 115
array × 105
haskell × 98
python-2.x × 92
interview-questions × 91
dynamic-programming × 85
recursion × 77
object-oriented × 76
ruby × 76
palindrome × 73
combinatorics × 70