I have this method, It takes a list of my individuals (class has public field fitnessValue). I sum all fitnessValue and then draw a random value between 0 and sum of fintessValue. In the end, I check for each individual where cumulative sum of fintessValue passes the point I counted before and re...
If you are reposting your question in CodeReview, please delete this copy immediately. Posting the same question in multiple sites is discouraged. — Stephen C31 secs ago
I'm given N integers. I need to find the maximum number of unique integers among all the possible contiguous subarrays of size M.
My code is this:
Scanner in = new Scanner(System.in);
Deque deque = new ArrayDeque<Integer>();
int n = in.nextInt();
int m = in.nextInt();
in.nextLine();
String s = i...
My coding practices aren't very good. I am trying to work on it, but I'm not sure what to work on. This is one of my recent codes, could you tell me the areas to work on.
The complexity for every query is log2n, or so I think.
It creates binary integer of n. Then uses a multiplicative method to...
After cleaning up & some refactoring, one module of my code became like below.
However, I'm feeling like there's still some unnecessary duplicacy, and it can be improved further and can be neat.
But, can't come up with exactly how to do it.
'use strict';
// === showing the execution context ...
I made this to track my variable changes while I experiment in IPython. I tend to use the same variable names and fit different values to them so it's nice to be able to see what I've tried, especially if I'm constructing a huge code block.
I copy text onto my clipboard before starting this code...
I am writing a script to automate the install and configuration of vim, zsh, ohmyzsh and tmux, on a linux/mac. I'd like to perform all operations in python, rather than using subprocess to streamline some of the operations (e.g. git clone).
I would also like to use this script as an example to ...
I have the following script which works great. The only thing is it takes a lot of time to run on a worksheet with 2000+ rows. Anyone know of a way to speed it up?
The code runs through the workbook and ignores the pages I do not want it to touch. Then, it runs through any pages that I want it t...
I'm writing a Vim plugin to manage and view tag files. There are two primary goals: making Easytags plugin a bit more powerful by instructing it where to search and place tag files, and viewing a tree of tags that exist in a project.
The entire code can be seen here, in a frozen branch review-26...
class csvimport(Base):
__tablename__ = 'csvimport'
id = Column(INTEGER,primary_key=True)
I want to set an autoincrement value for the above code. Please Help
I've got some close votes on this post, but I don't see what is abstract about it. Could you please provide your opinion guys? May be the title is a bit off, but I believe the content is solid.
I'll try to add some more context by describing the operations I implemented
Hello! I wanted to quickly ask about responding to an answer - I wanted to somehow update the user who took his time to respond on what I have done to address his points, but I want to address al his points in particular. Given that some of this is changes to code and others are feedback and clarifications, what is the best way to go about it? comments seems limited so I am unsure on how to proceed.
@user166286 write comments until you get everything clarified. After that post a follow up question if you want to get more review, otherwise I believe posting a self-answer with what's changed is the way to go
@Mast do you have a good example handy of a self answer that is also a good review? And can self answers simply be adjustments based on the answers given so far?
Sorry for my English.
I'm developing programs on Golang.
But now you have to study at the university and have the following task.
Calculate the continued fraction using the function indicators. The number of fractional elements must be specified from the keyboard. 1 + 1 / (1 + 1 / (1 + 1 / (1...
If you have working code that you think could be improved, see Code Review. I would say there are certainly neater ways to write that. — jonrsharpe9 secs ago
This must be about the ugliest python code ever written. I'd appreciate some advice how to tidy it up with better indenting to improve readability and make it easier to maintain.
def do_widgets(ws, col0, col1):
""" Process each widget. """
NO_WDGTS = 5
ENABLE_START_ROW = 6
ENABLE...
Here's a simple LCG that I've made to learn a bit more about pseudo random number generation.
Like the title says, is this implementation correct, if so, how can I improve it further?
The following code is self contained and it should run without problems.
#include <chrono>
#include <iostream>...
/*This Code finds the sum of all multiples of 3 or 5 for a given range of numbers. For example for n=10, no. of the multiple of 3 or 5 below 10 are 3,5,6,9 & their sum is 23.*/
int main(){
int t; //Number of test cases
cin >> t;
for(int a0 = 0; a0 < t; a0++){
int sum=0;
...
I have a huge dataset file and I am thinking to use parallel processing on that file, currently, I have a sample of that file which has many columns, I have written this script to do preprocessing on data like removing the punctuation and tokenise the data, Please review my script and let me know...
Because I don't want to download an entire library for a single function (which I do understand, was made better than I made mine), I decided to implement my own string formatting function.
I am not very proud of it, as I find it pretty ugly and unreadable.
This is only a string formatter with...
Also, I'd recommend also going to codereview with that code, there's a lot that can be improved, e.g. adding some empty lines and comments, helper functions for common label formatting and placement, avoiding if x: return True else return False, mixed return types in getTime, etc. — tobias_k45 secs ago
I'm fresh in the world of unit testing / integration testing. And I have read that, to write good unit tests for methods and classes, you must put yourself in the context that you don't know much about the method implementation, and focus on the method interface and logic
for example methode ...
Suppose I create a file named graph-file.txt, which including data of a
directed graph as the following:
7
{5, 2, 3}, {1,5}, {}, { }, {3}, { }, { }
The first line of the file shows the number of vertices (7 in that case). The second line describes the neighbours N+(v) for each vertex. For exam...
I had an interview with a global company yesterday. They had given me a programming assignment. I shared my screen and I must have finished the task in 1.5 hours.
Task was programming Reverse Polish Notation calculator in Java. I had developed as I shared my code below. I was rejected by not bei...
hola era para ver si me podías ayudar con el juego dots la verdad no tengo idea de como hacerlo y lo necesito con urgencia, si me puedes ayudar muchas gracias.
lo necesito para mañana y nada de lo que he intentado hasta hora a funcionado así que al que me pueda ayudar se lo agradezco.
el juego...
I have a running server but the User/client wont connect even though they are on the same port. Below I have posted my code and can't find whats wrong and not allowing the User/Client to connect. I'm completely and can't find what the issues can be when i have followed the book and videos online ...
I am solving interview questions from here.
Problem : Print concentric rectangular pattern in a 2d matrix. The outermost rectangle is formed by A, then the next outermost is formed by A-1 and so on. You will be given number as an argument to the function you need to implement, and you need to...
A Student Database Program
I've used Abstract classes and static methods wherever they seemed to be convenient.
I've serialized the hashmap entry and Read/Write it from/to a file .
Please review my code and point me to the mistakes I made .. How far away am I from writing production quality co...
I want to distinguish between people who have likes to posts and those who have dislike
And I wrote the following code
I want to find a way to improve my code without thinking it is efficient
<% if current_user.voted_up_on? @post %>
<%= link_to "LIKE #{@post.get_upvotes.size}", like_post_pat...
I want to get familiar with PyTorch and decided to implement a simple neural network that is essentially a logistic regression classifier to solve the Dogs vs. Cats problem.
I move 5000 random examples out of the 25000 in total to the test set, so the train/test split is 80/20.
I was able to ac...
I am currently writing a python file for BigIntegers, and I am having a problem:
from math import *
from numpy import *
def new_big_int (inp):
slots = int(log10(inp))
slots += 10 - slots%10
big_int = []
for n in range(slots+1):
big_int.append(0)
i = slots
j = 0
...
This is the adder method of my binary calculator. I did not cover for the case that someone passes a non binary number into the calculator yet.
I am pretty sure I have covered every other edge case for the calculator. I am trying to learn refactoring and how to look for simpler ways to do thing...