instruction stringlengths 71 95.1k |
|---|
I'm using this API to get information on sports-betting odds. I am then processing it in Python to discard the irrelevant information.
Here's what the response looks like:
[
{
"id": "9eec062ad8ed334517ab3a4be8362739",
"sport_key": "americanfootball_nfl",
"sport_title": "NFL",
"commen... |
I built a class in C#, DiscountManager, which is responsible for calculating a customer discount based on years of loyalty. I want to refactor it and am seeking any suggestions for conciseness and efficiency.
public class DiscountManager
{
public decimal Calculate(decimal amount, int type, int years)
{
decimal ... |
I have a simple program that matches words with descriptions. The program should do the following.
Allow a user to enter a set of inputs: keys and descriptions.
When the user clicks generate html a textarea should be created with html to be rendered in the word matching exercise.
When the user clicks show answer the p... |
I inserted this code snippet in the functions.php of my child theme, to create the woocommerce single product page in the hook woocommerce_after_single_variation of the custom icons in line centered on the text, without using css, everything works, but I ask you much more experienced if that's okay, or could you do bet... |
Saw this question and though I wanted to try.
So my version of reading Mine Sweeper: For the Online Judge
Some Utilities Classes
#include <memory>
#include <iostream>
#include <vector>
// Each member of the grid is either a mine
// which is printed as a '*' or empty which is represented by a number.
struct MineCount
... |
I have a working solution for the problem below. I have the feeling that it could be improved using memoization, but I cannot see how to do it.
The problem:
You are given an array arr of N integers. For each index i, you are required to determine the number of contiguous subarrays that fulfill the following conditions:... |
Motivation
While working on a completely unrelated task, I wanted to share a screenshot of my current Emacs frame, but not of the actual text contents. And while GIMP's pixelate filter did the job, I didn't want to fire up my image manipulation program just to share a picture of a custom theme or some functionality.
I ... |
I'm working on a personal project to build a website that quizzes users on chess opening theory moves. I know my code is not very object-oriented but I am working on refactoring it right now. I just wanted to get the basics of it working before I started to restructure everything.
Here is the link to the repo to see al... |
I do have my code running but again I'm wondering if there is a nicer solution since mine seems to be clumsy and I'm wondering if there is a better way like chaining (but I can't work out how to do that)
What I want to do is: for each element in data.lines replace properties "from" and "to" with an array of the "x" and... |
I primarily work with C#, and when working with an array of arrays, I can sum the length of the sub arrays using Linq:
var myArray = new int[2][] {
new int[3] { 1, 2, 3 },
new int[4] { 1, 2, 3, 4 }
};
myArray.Sum(s => s.Length);
Printing the result of that sum to a console should produce a 7. With that in mind... |
The task is to read in a data file containing a representation of a rectangular array with '*' signifying a mine and '.' signifying the absence of one. Each such array is preceded by a row and column count. The file is terminated with an entry that has zero for both the row and column counts. The expected output cou... |
I have a directory that includes a number of subdirectories. Each subdirectories contains subdirectories of its own. I'd like to construct a list of all sub-subdirectories in python. Here is my attempt:
import os
list_of_lists = [[sub_dir + '/' + sub_subdir for sub_subdir in os.listdir(my_dir + '/' + sub_dir)] for su... |
I'm writing a task list tracker with VueJS. Each task has a Frequency label (How often it needs to be done), Last completed date label (When the task was completed last) and a Due Date label which tells the user when a particular task needs to be done.
The code below is used to update the Due Date field by accepting 2 ... |
Here is my take at a lightweight interface implementation, where I focus on discoverability of suitable classes from strings (for simplicity, class name is used as an id). Each interface has it's own "registry" of implementations.
My choice of abc module is due to presence of registration method there, better support f... |
I have a function which takes one argument, a fraction, and returns two numbers - an integer and a power of two.
So, when you divide the the integer by 2 raised to power power of two, you get the original number. For example, When I run get_whole_number(Math.PI), I get 884279719003555 and 48 since 884279719003555/(2**... |
I came upon this Youtube video and the problem they discussed piqued my interest, so I decided to take a stab at it. Below is the question:
Given an array of unique characters arr and a string str, implement a function, getShortestUniqueSubstring that finds the smallest substring of str containing all the characters ... |
After finally having enough of the hacky batch-based workflow for a project, I tried "porting" it to Maven. This is my first time using a build tool for Java, so there's probably a lot of room for improvement.
General setup
B:\WORKSPACE\COM.MSGPROGRAMS.AUDIRAS
│ .classpath
│ .project
│ icon.ico // icon used for t... |
I am attempting to write a light script to deal with multiple package installation in Octave. The available packages can be checked in Octave Forge or wikipedia. For example, if the packages data-smoothing, fuzzy-logic toolkit, image, image-acquisition, parallel, statistics and video are needed to be installed, list th... |
The sep function separates string by the characters of seps, but it escapes the separates that are in quotes, like:
>>> sep("a b c d 'e f' g h", ' ')
['a', 'b', 'c', "'e f'", 'g', 'h']
def sep(string: str, *seps: str):
res = []
cur = ""
s = False
for c in string:
if c == "'": s = not s # Q
... |
In my application, I'm using std::wstring_convert to convert std::string into std::u32string. As this is very frequently done, I want to use a custom allocator to improve performance (and to learn more about C++).
Therefore, I wrote a custom allocator which allocates 2 blocks of memory with a fixed size of 300 (seems s... |
I was trying to emulate python's timeit in C++. My main aim for this is to measure the performance of small functions of C++ code that I write and print some basic stats like avg., min, max.
Code:
ctimeit.h:
#ifndef CTIMEIT_H
#define CTIMEIT_H
#include <chrono>
#include <cmath>
#include <iostream>
#include <limits>
n... |
I am not a Ruby developer but cold-reading existing Jekyll plugins I implemented one to bundle files in a zip archive and open sourced it on GitHub.
What do I need to fix to make it look more Ruby-native and/or Jekyll-native?
# Copyright 2021 by Philipp Hasper
# MIT License
# https://github.com/PhilLab/jekyll-zip-bundl... |
The query below already has indexes based its execution plan but it is still under performant with larger datasets. Are the additional null checks needed and why? Do you see anything that can be done to optimize the overall execution time? The execution plans shows clustered index seeks and no additional indexes are re... |
Features:
messages formatted with clear borders
errors sent to stderr
colour handling
colours can be included in other strings echoed to the screen without having to use the -e option
the desired colour can be either a string or a function
colours can be issued as commands before echoing text
Limitations:
If the mes... |
Overview
I've created an asynchronous and recursive method of generating word squares, of any size (known as the order of the square), from a known word list. If you're unfamiliar with word squares:
A word square is a special type of acrostic. It consists of a set of words written out in a square grid, such that the s... |
I have written a function that gives the number of hashes present in a Merkle Mountain Range proof. Using Solidity, this function can be written as:
function getMmrProofSize(uint32 index, uint32 n) private pure returns (uint8) {
// if n is a power of 2
if (n & (n - 1) == 0) {
return ceiledLog2(n);
}... |
I’m new to coding, and for my first project I’m working on a calculator that takes coordinate labels and metric components as input and outputs non-zero components of a number of other tensors (technically Christoffel symbols aren’t components of a tensor, they’re just elements of an array disguised as a tensor).
I pos... |
I created a computer program which takes a list of names and dishes chosen. The program then counts how many dishes and which dish are ordered. The result is then returned from a function. The algorithm is currently a brute force O(N*M) where N is the number of dishes and M is the number of people. Below is the code.
... |
function postFetch(data) {
let element = document.getElementById('placetoputlist');
element.innerHTML = "";
for (let priority of data.priority_list) {
element.innerHTML += "<h1>" + priority + "</h1>";
element.innerHTML += "<ul>";
for (let item of data[priority]) {
element.innerHTML += "<li>"... |
I have a bunch of code that adds the string representation of members in a class to a List.
using System.Collections.Generic;
using System.Linq.Expressions;
...
//Note: AuthModel is a custom class containing Id, Name, UserName, email, etc...
var someProperties = new List<string>();
someProperties.Add(GetMemberName((Aut... |
Classic pointer jumping algorithm summarizing values from an array adapted to run on a GPU instead of a PRAM.
Read about openCL and Aparapi yesterday for the first time, so this is my first trial: please let me know if I use Aparapi correctly and if something can be improved.
I've tested the code on my integrated intel... |
I'm new to using JS for anything other than DOM manipulation, so I'm not sure if the following code is taking full advantage of the Async concept in JS.
This is an example of a function I'm writing in my Discord.js bot project. The function checks for new RSS feed items from a given URL and then calls another function ... |
I have the following problem. I want to write a class that handles events and passes it through but reduce its number if there recently was an event. Basically it is debounce. However there is a slight change that if we don't receive events for a while and the latest event was skipped we want to emit this event.
I wrot... |
I'm creating a schema design for a user profile and transactions.
I am very new in data modeling and currently this is my design. The schema has multiple deposit table because the application I'm working on will use different payment gateways for money transfer and their transaction details is different.
SET @OLD_UNIQ... |
import math
num_rows = int(input())
if num_rows % 2 != 0:
upper_mid = math.ceil(num_rows/2)
lower_mid = num_rows//2
#prints upper normal triangle
for row in range(0, upper_mid):
for col in range(upper_mid-1, row, -1):
print(end=" ") ... |
I wrote a program that takes a string as standard input and checks if the words in the string are in the scrabble dictionary, then checks each letter of the words and gives back the the score of the words based off of what they would be worth in scrabble. The program is supposed to be written using various STL containe... |
I am playing with a custom-built SQLite library intending to access it from VBA via the C-language API. I keep the library within the project folder, so I load it via the LoadLibrary API. To make the load/unload process more robust, I created the DllManager class wrapping the LoadLibrary, FreeLibrary, and SetDllDirecto... |
This is LeetCode question 118 Pascal's triangle.
Given an integer numRows, return the first numRows of Pascal's triangle.
There is an example.
Input: numRows = 5
Output: [[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]]
I am interested to know the time complexity of my solution, and how I can further improve it. I am think... |
I have made a tiny Android-project to familiarize myself with user input validation.
The app just has an EditText-control for user input, a button "Compute Result" and a TextView, which shows the result. As input is an integer expected.
The essential part of the code:
buttonCompute.setOnClickListener {
val strInput =... |
I wired up a Gear Shift Indicator for my dad's car to display what gear it is currently in, and showing changes with animations (sliding up and down as appropriate, with a few bonus ones for fun at car shows).
Security is not really a concern due to its localised nature, but I'd like to release the code for others to u... |
I am trying to create a code for the Basic evapotranspiration equation by Hargreaves. I have attached a screenshot of the equation to be replicated.
I want to create a class wherein I can input data which consists of tmin, tmax, tmean, day and lat.
I have written the code below based on what I can understand from the ... |
I want to check with Javascript if a week number (with year) is within two other week numbers.
Example data: Year-Week startDate: 2020-32 endDate: 2021-52 checkDate: 2021-30.
In this case checkDate is within the two years.
How do I make Javascript know this too? I figured I should check if the date is bigger than start... |
I am writing a function that will retrieve the name of a certain record defined as a u32, I wanted to make the function filter the record code first in macro classes and descending to the string value I am looking for.
I wrote the code as below and it works, but I would like to know if there was a more efficient way to... |
I made a generic decorator in C++20 with concept for specialization. The idea is to be able to define only one function in the decorator to decorate all functions in a class.
You may try it (it's a bit long to insert here and it's better to see it work). Please, read it at the same time while reading this post.
This de... |
The main objective of this bot to make fast and reliable automatic subscriptions to email newsletter for people, who filled the website form(submissions go to google sheet)
I had too many requests to google docs.(rate limit error) -> so i added sleep 5 after every subscription. Also added break into email-check loop.(t... |
I have put together this small application that uses the JSONPlaceholder API and Vue.js.
The application crosses users and posts and displays the posts by user (author):
var app = new Vue({
el: "#app",
data: {
base_url: "https://jsonplaceholder.typicode.com",
uid: 1,
currentUser: null,
userData: n... |
Problem Description
I am building a library that helps me building TUI Apps more faster, for example printing TUI Menus and other components. I would like to get feedback on my design decisions to see if I'm properly following SOLID principles.
To solve this scenario while trying to follow the principles I created a cl... |
I have been working on a series of posts about a library to connect to databases but most of the scenarios I have to resort to some "JOIN" the problem arose when two or more tables had some columns with the same name causing the last one to prevail.
I understand that the problem may lie in a bad database design, but I ... |
Question Link
Consider a money system consisting of n coins. Each coin has a positive integer value. Your task is to calculate the number of distinct ordered ways you can produce a money sum x using the available coins.
For example, if the coins are {2,3,5} and the desired sum is 9, there are 3 ways:
2+2+5
3+3+3
2+2+2... |
I've just created a small script to clone all projects within a Gitlab Group and all Subgroups inside it.
As I am trying to level up my Go skills, I would welcome any reviews and enhancement on my code.
clone.go
package gl
import (
"fmt"
"io/ioutil"
"log"
"os"
"os/user"
"strconv"
"sync"
... |
I'm quite new to C++, so as a beginner's project I decided to create a program that can solve second degree polynomials and (some) cubics using this lengthy formula I had found online.
I would love to receive some advice in regards to the code as I am eager to improve my code in any way possible and take away some less... |
I'm posting this here mostly as I posted it over at stackoverflow because the user that answered me recommended it:
I'm learning to code with The Odin Project. So far, I've been doing every project without any major problems: some difficulty here and there, but after some thinking I was able to solve them successfully... |
I'm building a small Delphi application where a user can input a file or directory manually by typing it or by selecting it from a dialog . Since it can be input manually, I want to ensure that I save that path as it is on the file system. For example: the user input c:\program files, the path is updated to C:\Program ... |
For generating a list of characters, I currently use a static list, 2 components and some unclear conditional renders.
export const chars = [
'#',
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'... |
I am looking to get any type of improvement, I want to be able to hash a list of 'blocks' aka strings and check if hashes match per block, if you can help me with that, currently reading and writing is optimized as I am writing direct bytes, any type of improvement in performance is appreciated!
I am also looking to us... |
I am working on an e-commerce website.
The home page has 2 inputs: Looking for and Location. The user would enter their desired product and location and click on Search as shown below:
The first input (i.e. Looking for) has autocomplete functionality and when the user clicks on it, it opens a list of suggestions. I am... |
I created a text-based RPG.
game.py
import random
import os
import items
from maps import mappa
import pickle
class Player:
def __init__(self, name):
self.name = name
self.lvl = 1
self.points = 5
self.attributepoints = 2
self.str = 5
self.agy = 5
self.vit = ... |
I am seeking a general code review.
Task:
Write a program that takes JSON-formatted opening hours of a restaurant as an input and outputs hours in more human readable format.
Input:
Input JSON sconsist of keys indicating days of a week and corresponding opening hours as values. One JSON file includes data for one rest... |
I have implemented the classical Hoare's algorithm, but I think that the implementation is not readable enough. I have tried to refactor it in the way that I used to use in C#. But now I have got compiler errors.
Let me show some details. This is the first implementation:
pub fn quicksort<T>(array: &mut Vec<T>) where T... |
I am trying to create the algorithm described in the image from this link
Simply put any two adjacent nodes must not share tuples and if they do they are colored with the same color. If there's a possibility to supress tuples that make two adjacent nodes disjoint then we do that (after exploring all possibilities) and... |
I've written some code that is yielding the desired results but it seems verbose. The code gets the distinct objects from an array of objects when looking at only a subset of the keys. Is there a more concise way to write the code to get the same output?
const source = [
{"id":"1","department":"grocery","storeL... |
https://kdevcalculator.web.app/
Code: https://github.com/AmishBaztard/Calculator/blob/main/script.js
Just looking for a code review on this. I used ESLint Air BnB Style.
const calculatorButtons = document.querySelector('.calculator__buttons');
const currentView = document.querySelector('#currentResult');
const operator... |
The purpose
This code is intended to achieve the following goals:-
Create a hard coded list of lifts, this is pretty static and I add some extra info so I'm ok with this being in the code but I may move it to configuration or an external store eventually
Every minute (or so) hit the source data URL, grab the current l... |
I'm relatively new to C++, and have attempted a Rock Paper Scissors game, and it works. Here and there I added some countdowns so that the program doesn't run instantly. Any tips for improving the program even further, or maybe even something to add a further level of complexity to the game to make it better?
#include ... |
I have written the following function to read multiple CSV files into pandas dataframes. Depending on the use case, the user can pass optional resampling (frequency and method) and/or a date range (start/end). For both options I'd like to check if both keywords were given and raise errors if not.
My issue is that readi... |
I am writing a program that asks questions, takes the user's input, and responds according to whether the answer they gave is correct or not.
I am looking to improve my code with respect to cleanliness and readability.
const readline = require('readline');
const rl = readline.createInterface({ input: process.stdin, ou... |
I am currently finalising the class for a trading strategy and wanted to know if the below could be re-written in a shorter way that will let it run faster?
This is PCA1 df:
USDJPY EURUSD GBPUSD AUDUSD GBPAUD
date pca_component
2019-10-08 weights_2 0... |
So my friend told me he just did 1 while and a bunch of if-else with only using 3 arrays to get the same output as mine code does.
So I wonder if I just make this unnecessarily complicated. I have created 5 arrays here.
What's your opinion on this?
#include <stdio.h>
#include <fcntl.h> //for open
#include <unistd.h> //... |
I am a self taught python developer and I trying to write clean code as mush as possible. Since I do not have any environment that can give me constructive criticism, I would like to hear your opinions, so, here it is a python password generator, I know that something like that can be made with single function, but thi... |
My program displays the price of a movie ticket. The price is based on the customer’s age. If the user enters a negative number, the program displays the “Invalid age” message.
#include<iostream>
using namespace std;
int main(){
int age = 0;
int price = 0;
cout << " What is your age?: ";
... |
Problem Statement:
Given the root of a binary tree, return the maximum width of the given
tree.
The maximum width of a tree is the maximum width among all levels.
The width of one level is defined as the length between the end-nodes
(the leftmost and rightmost non-null nodes), where the null nodes
between the end-node... |
Problem
I have a project in which I implemented variants of the Sieve of Eratosthenes as well as benchmarking and profiling harnesses for these (which can be ran with ./run.sh benchmark and ./run.sh profile, respectively; the results can then be accessed from the "./target/criterion/" directory). I'd like some assistan... |
I'm starting out on a project that will standardise some increasingly complex webcomponents. In a final version the goal is to support multiple different design systems (as the components might be used for different brands, which require different color schemes, border radiuses, margins, etc.). This is my attempt at cr... |
I am learning about hooks, so I try to write code that display current time.
I had comment in each line of code the reason I write it. So:
Am I understand right?
Is there any bad practice?
What need to be improved?
import * as React from 'react'
function App() {
// Define a state for keeping track of time
const ... |
If I formatted my question wrong, feel free to notify me or update, this is my first question on this subforum
This is literally my first ever Go project, decided to make a Tic Tac Toe (ironically I came up with that idea myself, turns out a lot of people use this as a beginner project heheh), requiring me to use User ... |
This would seem obvious, but there is a lot that can go wrong. What happens is the user enters alpha values etc.
I have come up with this function and would appreciate any suggestions or comments on how to handle this better:
#include <iostream>
#include <string>
#include <cstdlib>
#include <limits>
bool readNumber(in... |
I've just wrote my first real C program. It calculates the dimensions of a circle or a sphere based on the user input.
The program asks the user which dimension they are entering and then prints the values of the remaining dimensions.
#include <stdio.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<stdlib.h>
dou... |
The code I have below is currently what I am wanting to see if I can shorten. The code works as-is right now but I don't like the face that each IF statement has its own $each loop in it. I was wanting to see if I can condensed this down to allow only one call to the $each loop.
switch (input.Type.toLowerCase()) {
... |
To get the Firefox default profile, I am using the following program.
import glob
from pathlib import Path
import re
x = glob.glob(str(Path.home()) + '/.mozilla/firefox/*/')
r = re.compile(".*default-release.*")
firefox_default_profile = list(filter(r.match, x))[0]
print(firefox_default_profile)
The logic is simple. ... |
I'm new here. I recently found myself in charge of a large PHP-based system. The guy that wrote it produced some of the worst code I've ever seen. I've never been in charge and have had the luxury of working under some very good programmers who took the time to "groom" me - but with stricter languages like python, insi... |
My program calculates the user's age in years and months. It takes the user's birth year and month and then the current year and month as input.
#include <iostream>
using namespace std;
int main ()
{
int y1 , m1 , y2 , m2 ;
cout<<"Enter Your year of birth"<<endl;
cin>> y1;
cout<<"Enter Your month of... |
I am looking for ways to improve this little utility function:
(defun break-down (taste sequence)
"Break down a list SEQUENCE into consecutive lists of constant TASTE.
The TASTE argument is a function which is applied on sequence elements to
taste them. Taste values are
The answer is an alist whose terms have the f... |
Learning Bash using hunt and peck method. Following code was put together from results of many "How do I ..." searches. Thus styling may be inconsistent. See code for my motivation. Any advice gratefully accepted.
#!/bin/bash
# Motivation:
# To ease the process of examining large quantities
# of files for metadata... |
This is my very basic Weather App. Would appreciate your opinion mainly about style, writing code etc. I know there is not much functionality to this app, but I have created it just to practice and to share with you guys so you could possibly point weak points I need to focus on as a programmer. As I am learning mainly... |
For my first Rust exercise I decided to re-implement a project I wrote in C++ for my data structures class a few years ago, plus make it generic. I am looking for all suggestions, but I am primarily concerned about writing more idiomatic Rust.
use bitvec::prelude::*;
use counter::Counter;
use std::cmp::Ordering;
use st... |
I'm looking to highlight some words on a webpage, I've grouped them now, but changed the css and html slightly and this seems to have broken it.
For context, looking to add a list of words in JS which would then apply formatting to those words. I changed the p to a span because I wanted them to be an inline-block, whic... |
I wrote a program that uses stat() to find some details of all the files in a current directory. I then store all that information into a string using sprintf() and keep adding to the size to prevent my string from being overwritten and then I copy the string into a char**. This code seems to work but I was wondering i... |
I have written a Python 3 program that can encrypt and decrypt Playfair cipher, though I know it has been implemented countless times, none of the scripts I have seen so far(e.g. https://codegolf.stackexchange.com/a/23363) is as performant as mine, and many of them only do the encryption part and not the decryption par... |
Given the code:
async getData() {
const response = await handleRequest(…);
return response;
}
Many of static code analyzers mark this code with an issue "Local variables should not be declared and then immediately returned or thrown".
Formally, yes, const response is not mandatory here but in my opinion, th... |
I have completed my hangman project in C++.
I would like your thoughts and improvements on my implementation.
Here is the code:
#include <iostream>
#include <ctime>
#include <string>
#include <vector>
std::string get_random_word(std::vector<std::string>& words);
void play();
std::vector<std::string> words = {"program... |
This function has 16 repeated calls to the same function, passing in the same handles to each:
// Create all 16 colors
void fill_color_gcs(xcb_connection_t *c, xcb_window_t w, xcb_screen_t *s,
xcb_gcontext_t *col) {
col[0] = color_gc(c, w, s, 0, 0, 0);
col[1] = color_gc(c, w, s, 1, 1, 1)... |
My bot is fully functional and I would love some feedback. Thanks!
Main loop for keep it running (main.py)
from functions import RunBot, InitPraw
reddit_handler = InitPraw()
doctor_who_subreddit_handler = reddit_handler.subreddit("doctorwho")
while(True):
RunBot(doctor_who_subreddit_handler)
Functions that make it... |
I am learning C and doing challenges like those found on exercism.io and the various data structure & algorithm sites.
I have a sense that while this works and it makes sense to me that it can be improved and probably isn't how a professional C programmer would have solved it.
Interested if this would pass a code revie... |
Let's say I have a number set like below
// 1,2,3,4,5,6,7,8
Now I want to go from 2 to 5. To go from 2 to 5 there are two ways: one is forwards and another is backwards
forwards: +3
backwards: -5
Backwards is basically going to backside from 2 and reaching 5 from end of numbers
ex
-5 goes like this: 2 -> 1 -> 8 -> 7 ... |
In question "Dictionary based non-local mean implementation in Matlab", the Manhattan distance between two three-dimensional structures can be calculated by ManhattanDistance function. In this post, besides Manhattan distance, the functions for calculating Euclidean distance, squared Euclidean distance and maximum dist... |
I have completed my Python project which calculates and outputs the number densities of dozens of different species (over 11 chemical elements total) in a model atmosphere of the Sun. The code reads in a file that contains mass and temperature for a given depth in the Sun.
I would like your thoughts and improvements on... |
The code runs fine and was manageable without any error handling.
Once I started to handle errors and build out the code the if/elif/else branches quickly became too much. How can I route the view function conditionally based on the button that sent the request without all the conditionals? I tried refactoring the get ... |
I'm solving the Longest Palindromic Substring problem on LeetCode.
And here's my final submission:
public static String longestPalindrome(String s)
{
// to avoid TLE
char [] sChars = s.toCharArray();
StringBuilder tempSb = new StringBuilder();
StringBuilder sbForCompPalindrome = new StringBuilder();
... |
Here is my starting point for a laravel CRUD controller.
I would appreciate it if someone could do a review and show me how an experienced developer would approach this.
I do not want to progress with my app if I am not using the best practices.
I am using Laravel 8
<?php
namespace App\Http\Controllers;
use App\Model... |
It took me a while to compute this script, it works perfectly, but I think that it is very raw and long.
The goal of the script is to produce a graph of cumulated rainfall with 3 lines:
Cumulated rainfall of the rainiest year
Cumulated rainfall in the current year (for example from 1st January until April)
Cumulated r... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.