Ok, I've added another answer cause string.Formatter is probably not the best here. All the "Additional changes not made to the below code" are found in the second answer so you should be able to see my POV on them.
The task:
Determine if a word or phrase is an isogram.
An isogram (also known as a "nonpattern word") is a word or phrase without a repeating letter, however spaces and hyphens are allowed to appear multiple times.
Examples of isograms:
lumberjacks
background
downstream
six-year-old
The word ...
I need to verify what design pattern Is using in this code; I cannot identify wich one from this List is; I leave the link of the project and the List of patterns. if it does not exist leave your opinion in the comments.
Code Style Use Aprox:
https://gist.github.com/ryansechrest/8138375
Desing Pa...
In a game of Tic-TacToe given a gamestate:
game_board = [ [1, 0, 1],
[0, 1, 0],
[0, 1, 0] ]
I have written the following piece of code to display the output of the gamestate in regards to wins:
game_board = [ [1, 1, 1],
[0, 1, 0],
[0, 1...
How can i codify the following to get a proper function - this hack is working but totally in-elegant
i need to select sql with "start_date" GE {date}
select sql with "start_date" between {start_date and end_date}
the DB is Postgres and this is ../api/v1/roster_controller.rb
def show
s...
I’m voting to close this question because it belongs on Code Review. Optimization questions tend to be opinion based, and are outside the scope of SO. — Trenton McKinney32 secs ago
I'm working on a solution to the Following problem on Hackerrank, and I seem to have found a function that works for the purpose.
However, I feel as though this is a very overdesigned solution to a problem that appears, at first glance, to be simple. This is what I've come up with so far:
This co...
I find myself frequently writing code as follows:
void * p = ...;
using sig = ret( __cc * )( args_t... );
auto r = reinterpret_cast< sig >( p )( args... );
I decided I wanted to make something that does the casting for me without any runtime overhead.
function_t f = p;
ret r = f( args... ).call(...
@Vogel612 Experience over education. Experience in teams that is, if you write solo-projects for years without anyone looking at it, it will probably smell like dead animals.
I am creating a monopoly using react hooks and I am using cypress for testing it. The first test I have to create is to check about dice rolls. I have three tests in which I am repeating same kind of code. Kindly help me to refactor
//A funcction to get the rolls of dice in number
function getDic...
This is part of my code
files = os.listdir('/Users/milenko/mario/Json_gzips')
files = [fi for fi in files if fi.endswith(".gz")]
my_dict = {'ticr_calculated_2': 'ticr-2.parquet', 'ticr_calculated_3': 'ticr-3.parquet', \
'ticr_calculated_4': 'ticr-4.parquet', 'tick_calculated_2': 'tick...
For game AI development, I am currently using a slight modification on the DFS "count the islands" problem with the following original specification. This may not be the ideal solution so I am open to any other ideas if you note DFS is not the best approach. Thank you.
Given a 2d grid map of '1'...
I'm an experienced Java developer, however I don't have experience with reflection or Annotation classes. For fun, I tried to develop a CSV Reader class which can parse each row into a particular type.
Here is my code:
package com.richardrobinson;
import java.io.BufferedReader;
import java.lang....
I'm building a dead simple CLI app that parses a RSS feed and prints it to stdout. I needed a simple word wrapping function to, well, wrap lines to an arbitrary length (say 80 or 120 chars).
I ended up using this, as it gets the job done. However, as I'm still new to Go, I was wondering if this c...
It's the first time a write a non-trivial mongodb query, and I came up with one that does work, but is 123 lines long! Surely there must be a way to write it in a more concise way.
The purpose of the query is to return aggregated (average) values, using groups that are determined by the $interval...
This seems like a request for a code-review, which we don't really do here. If the code is working (a hard requirement) then post on the Code Review SE instead. — Some programmer dude5 secs ago
@Amongalen Please take some hints from Some programmer dude's comment. It acknowledges the largest chuck of closed questions (code that doesn't work as intended) and points to the help center so the user can check the rules for themself. It also doesn't say this question is on-topic there, as many recommendations to Code Review are just plain wrong. — Peilonrayz48 secs ago
I am currently learning Java; I could really use some help from more experienced programmers.
How can I clean up my Tic-Tac-Toe code? What mistakes have I made? Can I use more exception handling? I tried to use exception handling, in isValidStepCheck and takenFieldCheck, but I don't think I used ...
I have a simple class to ensure the date entered into a form is a valid date. Where can I improve it, have I missed anything?
public class ValidDate : ValidationAttribute
{
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
{
var dateToP...
You seem to ask two questions: (1) how to improve the working code, as presented in the question (2) solve the problem for larger array sizes. Please note that you should only ask one question, and that (1) is more suitable for Code Review. For (2) please provide the necessary code embedded in the question (use snippet button), to reproduce the problem. — trincot16 secs ago
I am trying to make a visualisation of merge sort using plain JS with HTML canvas.
Consider i have a working code for the two functions -
an iterative merge function
a recursive mergesort function
now i want to be able to draw the condition of the array at every possible step in the form of a h...
I would like to ask if it is ok (and safe) to leave Sub in with statement using first or second sample:
Sub sample1()
With ws
If .Range("cond1").Value <> 1 Then Exit Sub
If .Range("cond2").Value <> 1 Then Exit Sub
If .Range("cond3").Value <> 1 Then Exit Sub
...
Hello and welcome to the site. This site works best if you can make your question very specific. For instance, if you have a particular error message when you run your code and you don't understand it, ask about that. If you want more general feedback on your code, you might want to try codereview.stackexchange.com instead. — Dave Costa5 secs ago
It does sound like a job for the code review stack exchange, but for what it's worth, the code doesn't actually work. So I think there is still a bug that needs to be addressed here. — zeterain29 secs ago
Ah, then that's my bad. I just ran the code snippet and saw the wrong output. Didn't catch the spaces issue. Yeah, you're right- this belongs at the code review. — zeterain36 secs ago
I’m voting to close this question because it has working code and is asking for a better/improved version and therefor belongs on CodeReview — Andreas44 secs ago
OK, Thanks All for the time. Is there anything I need to do or modify here to shift the post to codereview? Or should I re-post it there? — Hari47 secs ago
I'm a solo developer and a friend told me that my code is not very readable, I always write code trying to keep it DRY while not taking longer then it would take doing it in an "easier" way.
Here is the skeleton for My Profile feature which will initially have read-only values and when the user w...
I'm working on a blackjack game to build up my skills for C++. At the moment I am trying to get my values for each card correct. At the moment I will keep Ace as 1. I know the values work on one function but they don't seem to work for the other function when they are the same principle.
#include <...
Second attempt: Don't ask two questions. You have two questions: Question (1) is about improving working code. That question is off-topic here, and Code Review is better suited for that. Question (2) is about a problem that occurs for larger array sizes. It is on topic here, provided that the code is included to reproduce the problem (this has been done in the mean time). — trincot23 secs ago
Hello! Requests for general review and critique of working code are generally considered off-topic on this site. You may wish to post a edited version of this question on Code Review(codereview.stackexchange.com) instead — Brian11 secs ago
I'm just glad I gave up on having any hope for the SE community on the whole to stop acting like a bunch of spoiled, entitled children. I cannot stand computer people anymore.
The code below works as intended but I'm not sure the way I'm passing it to a component is correct. Also, I don't think the way I wrote this function is recommended. It's not a pure function and probably should be split into two functions where one needs the output of the other.
'books' and 'auth...
The code underneath works fine. Only.... my df has only 1200 rows and the code takes quite a well to end.
My question is: do you have any suggestions how to write code that performs the task (much-) faster?
My df has a column ['Naam']. This contains names of all kind of shops, banks, gasstations ...
I am beginner in programing with python. I am going to take a first job in this specialization. Can I use this code for presenting my skills at interview?
import os
import time
import datetime
import sys
from PyQt5 import QtWidgets, QtGui, QtCore
class MainForm(QtWidgets.QMainWindow):
# a...
The question is way too broad/opinion based for SO. Asking for review of working code is on-topic for codereview.stackexchange.com/help/how-to-ask. Note that before doing anything you should search for "When I should use ArrayList in C#" as "how to improve code using ArrayList" may be considered an insult by some. — Alexei Levenkov28 secs ago
@Zeta Also, if you don't understand snippets you've found on the internet, the proper action is to learn what's going on instead of blasting it onto another part of the internet.
If your code works, this question might be a better fit for Code Review. From codereview.stackexchange.com/help/on-topic: If you have a working piece of code from your project and are looking for open-ended feedback in the following areas... Performance... then you are in the right place — dbcjust now
@cglacet On Code Review we tend to say "works as intended". It doesn't matter if it compiles or not, all that matters is the code does what you want it to do. This clearly does not output the correct number so it's broken. — Peilonrayz55 secs ago
If nothing is wrong about a code then why even bother asking for help. The definition you give is very subjective as is depends on what you intend. If I intend to output an integer, this function works perfectly fine. On the other hand you could never ask for improving performances, because as soon as you ask for performances improvements you admit that the code doesn't "work as intended". This is sterile. I was just suggesting that code review questions tends to go to codereview instead of here. — cglacetjust now
@cglacet It's not subjective, if you have a problem with Code Review's rules then please voice this on Meta. The question as is will only get closed on Code Review. — Peilonrayz49 secs ago
But this should be closed on stackoverflow too, so instead of arguing about why this shouldn't belong to codereview give the OP a place to ask for help … — cglacet39 secs ago
I am new to go, and need some pointers on my code style and optimization. I just created this simple code generator:
package main
import (
"fmt"
"strings"
)
// to be formatterd by 'fmt.Sprintf'
var mips_code_base string = `.data
%s
.text
main:
%s
move $2, $0
j $31
`
...
I used random effects on PHOTOMOSH for that one, while others use either effects I intended to use, or effects made with a hacked together Python script
That's pretty cool Morwenn. I've not really seen this kinda art for a couple years now. My bro used to go to an art school so I used to see this every so often. Eating flowers seems so foreign to me now, lol
I had the below problem in a coding test and I got 28/30 tests passes and 2 failed due to a time-out.
Problem You have created a programming language and now you have decided to add hashmap support to it. It was found that in
common programming languages, it is impossible to add a number to all
...
I also noticed how easy it is to get rid of the two background colour prints in print_table you can just change item[c] to f'{item[c]:<{minsize + 1}}' 🤦
Oh, nice. I've never seen it before. classmethod make the method take the class as the first argument, rather than an instance with a normal method or nothing with static method.
That's a good point. I've not heard that before. In Python some indent styles can only be achieved with spaces, and mixing tabs and spaces is a SyntaxError :(
i have this project:
https://github.com/arcanisgk/test-code-style
i have two class that i need enhancement:
class/class-manager.php
And
class/classgen/class-vars.php
I have everything updated so far you can check what was my scope.
all testing with:
Core_App::$obj_class['GEN']['APPMANAGER']->RunI...
I'm solving a knapsack problem here. It works, but gives time limit exceeds on a certain test case.
The input is in the following form:
N W
w1 v1
w2 v2
:
wN vN
N: Number of items.
W: Max weight I can have.
wi: ith weight.
vi: ith value.
Here is my solution to it:
using System;
using System.Colle...
@JuanC when suggesting users post on CR it would be great if there was also a suggestion like "Please read the relevant help center pages like 'What topics can I ask about here?' and 'How do I ask a good question?". In the current form the code above would likely be closed as off-topic because while it may not be difficult for many to see what it does, there is no description of what the code does. — Sᴀᴍ Onᴇᴌᴀ34 secs ago
I've wrote few classical python function in javascript. I would appreciate any kind of feedback as the main goal is to learn about javascript (errors/improvements/existing javascript functions that I missed/challenges that would be interesting to tackle next).
// Lets start with a simple one:
fu...
Javascript: Large Number Scales Names Generator
This JavaScript code generates the full name of the numeral scales for large numbers under the “Short Scale Numeral System” using the Conway-Guy system for forming number prefixes.
Sad to know that Mr. John Horton Conway died two (2) months ago, at ...
so first my code open chrome and navigates to github then if i dont find my solution . i just press (ctrl + t , which opens a new tab) then it goes to stackoverflow and searches then problem over there .
from selenium import webdriver
from selenium.webdriver.common.keys import *
import time
impor...