I made a couple of little games and cellular automata in Java. For every new 'game', I used the same code as a base, except for the game logic of course. With every iteration of me customizing my existing code to my new idea, my coding skills have much improved and I added new things that I learn...
I am basically a beginner, so I Wrote some code that implements a zero cost singleton, through it will crash your program if you have a MPU.
use core::cell::UnsafeCell;
use core::mem::{size_of, transmute, MaybeUninit};
/// This type is mean to Static allocation of variables that should life all t...
Is there a way to beautify my code? It works but there repeated blocks and I am not sure that I'm using some functions in the right way. I'm not new to javascript but I want to improve it and get rid of Bad Coding Habits.
Below is my code snippet that I'm using on the server to upload product ima...
Started learning Rust by solving LeetCode problems as they involve all the standard data structures of the language. I have the following standard hash table solution to the two-sum problem:
use std::collections::HashMap;
impl Solution {
pub fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32>...
Does the below TS type still need to be improved? I use actions: any as the more general signatures. Is there any better way?
import { ActionCreator, ActionCreatorsMapObject, bindActionCreators } from 'redux';
import { useDispatch } from 'react-redux';
import { DependencyList, useMemo } from 'rea...
These are what I was working on in the last few days, I wrote a bunch of functions that fill a given region with rectangles of different colors.
The functions can:
Randomly split a region into sub regions recursively based on n random points:
one point (each region is split into four sub regions)...
Problem description:
The sum of the squares of the first ten natural numbers is,
1² + 2² + … + 10² = 385
The square of the sum of the first ten natural numbers is,
(1 + 2 + … + 10)² = 55² = 3025
Hence the difference between the sum of the squares of the first ten natural numbers and the square of...
I have an app which parses data files on the clients browsers and displays a scatter chart. This is an example of a scatter chart with 10,000 data points:
This is an example of a scatter chart with 1.4 million data points:
My algorithm is crude and simple. I get the events in a correct format (...
I am trying out this Leetcode(Difficulty : Hard) Problem and I need your help to asses the code. I am pretty new to this.
Given an array of strings words and a width maxWidth, format the text such that each line has exactly maxWidth characters and is fully (left and right) justified.
You should ...
Still the only option to reduce the clutter and embrace the Zen. It also moved text around, which isn't appreciated (by me). And in code review, testing, and similar situations, it's very clear that it's missing if you turn it off completely, which is good. — Henrik Erlandsson10 secs ago
Been working with python for a couple years on the side, looking to get feedback on this Blackjack game I made for some OOP practice. Code executes as expected (and I know the game is incomplete - no splitting, etc).
https://github.com/josh9730/misc/blob/main/blackjack.py
Code:
from cards import ...
I'm making a timer class in C++. This is the overview:
#include <chrono>
namespace ktp {
class Timer {
using Clock = std::chrono::high_resolution_clock;
using TimePoint = std::chrono::high_resolution_clock::time_point;
public:
Timer(bool start = false) {
if (start) Timer::start...
@CaptainObvious It is tempting to down vote this, there is an excellent answer that states as the first line that the code doesn't work and can't work, then goes into more detail. Because of the answer I don't want to VTC.
I don't know whether to retract my close vote and down vote on this question or not, there is now a very good answer, and @SᴀᴍOnᴇᴌᴀ edit lets me remove my down vote, I still won't up vote it, and there is another VTC besides mine.
I've retracted my VTC, but left my down vote. Also removed my comment about why I VTCed it.
@CaptainObvious All the code to be reviewed is in a GitHub repository. Authorship. The code included is an example of rules, but not specific to any project.
I wrote my own hash function and my own hash table.
My hash function seems to work surprisingly well!
Feel free to comment anything!
Hash function:
#ifndef __CLRS4_HASH_FUNCTION_H__
#define __CLRS4_HASH_FUNCTION_H__
#include <bit>
#include <common.h>
namespace frozenca::hard {
using namespace ...
My goal is to improve my coding skills, I am just looking for feedback specific to encapsulation, the use of static, and any other tips to make this "production quality". I don't feel confident the Solve method has been implemented correctly. By instantiating the object its contained within. Simi...
Here are 2 bubble sort algorithms:
1:
function bubbleSort(array) {
let i = 0;
let startVal = array[i];
let comparingVal = array[i + 1];
let iterations = array.length;
while (iterations > 0) {
if (comparingVal === undefined) {
i = 0;
startVal = array[i]
comparing...
I'm translating the python program video-diet to learn rust. The program is to recursively compress video files in a directory, but here I'm just preparing the ffmpeg command.
I like to follow clean code principles. The problem I usually have is that I don't know how to make some functions smalle...
I'm looking for advice on how to improve the performance and/or style of these two search functions. This is just for fun and for practice: they are already fast enough for any application I would be using them in, and they don't have to meet any specific performance criteria, but I'm intereste...