I recently got a prompt when looking for a job. To spare any details, the company decided not to get back to me, so because I did not get a code-review/feedback from them, I was wondering if someone would review this and tell me how i could improve it.
Here is a link to the full prompt (pretty ...
The series, 1 ** 1 + 2 ** 2 + 3 ** 3 + ... + 10 ** 10 = 10405071317.
Find the last ten digits of the series, 11 + 22 + 33 + ... + 1000 ** 1000.
def self_power(n):
"""returns sum of self powers up to n."""
total = 0
for i in range(1, n + 1):
total += i ** i
return str(tot...
If this is about working code that needs improvement code review might be a better fit to ask. Be sure to check out their guidelines before posting. — Luuklag30 secs ago
@Vogel612 Hmmm, increases the likelihood of nobody complaining if we create our own. It isn't particularly hard to outline a logo to a surface and send it to a duckprinter.
Mar 5 UPDATE: This order is proving a bit more laborious to expedite than our vendor had originally anticipated, so these boxes haven't been shipped out yet. Anyone who filled in a form should receive an email with tracking information as soon as their box is shipped. Anyone who didn't catch t...
The arithmetic sequence, 1487, 4817, 8147, in which each of the terms increases by 3330, is unusual
in two ways: (i) each of the three terms are prime, and, (ii) each of the 4-digit numbers are
permutations of one another.
There are no arithmetic sequences made up of three 1-, 2-, or 3-digit pri...
ill be happy to know how i should improve my code in order to be a proper tkinter program. Ill post here only certain parts to show you the main structure. Thank you.
import tkinter as tk
class MenuBar(MyFinanceManager, tk.Frame):
portfolio = None
def __init__(self, parent):
t...
I am doing a group by on a subset of a dataframe.
I am working with 9m+ rows atm, subject to sharp increase.
I tried different approaches already and wanted to know if i could squeeze a bit more juice in performances.
What I tried :
Option 1
df2=df[["ColA","ColB","ColC"]].query("(ColA == 'X') &
For this Code, I am provided a text file that contain several cities. I am suppose to identify the cities mentioned and print their state and country.
Requirements: If a mentioned city is in two or more countries, I ask the user to mention which city they are talking about. In addition if there ...
I have made an OOP-based solution to the Openshift CLI, which I intend to use for a rest API.
I'm wondering if this approach upholds the basic OOP principles, in terms of abstraction, encapsulation and inheritance
Not all the features is implemented, but it's 100% functional as is.
OpenShif...
This is my query:
SELECT DISTINCT type FROM `log` where type LIKE 'group_%'
My DB looks like:
|group_1|
|group_1|
|group_1|
|group_2|
|group_2|
|group_3|
|group_3|
|group_3|
So this query returns me:
group_1, group_2, group_3
But .. in near future this table would have more than a millio...
Hello I'm calculating now the total garnered hours student get in school using php.
(Same concept in getting the total work hours in employee for timesheets)
So I have an array $attendance where the student check in and out in school.
$attendance = [
"2019-07-01 08:03:00",
"2019-07-01 12:1...
I've been working on a a text based game with a very simple battling system. There are way to many questions I can ask to get reviewed about this project, but I'll take small steps at a time (this is my first post).
I'm mostly concerned about how I handle command input and the execution of said ...
I've written a Caesar Cipher in python (a more in-depth explanation is provided in the docstring at the top of the program). At first, it was supposed to just be the cipher, but I expanded it to have the user guess the original string, given the encoded string. I would like feedback on the caesar...
@Mikku no, that is not a candidate for code review because it's not a complete and working sample. Code Review only does complete and working in order to be able to review. — this5 secs ago
The prime 41, can be written as the sum of six consecutive primes:
41 = 2 + 3 + 5 + 7 + 11 + 13
This is the longest sum of consecutive primes that adds to a prime below one-hundred.
The longest sum of consecutive primes below one-thousand that adds to a prime, contains 21 terms, and is equal to...
Could someone share some light and check if this is okay for apache httpd security/good standards? I'm using apache httpd to call my Node.js app that is running with Express and also configuring SSL.
apache2.conf:
DefaultRuntimeDir ${APACHE_RUN_DIR}
PidFile ${APACHE_PID_FILE}
Timeout 300
Kee...
I'm trying to reconstruct all the shortest paths (even multiple paths which are tied for the shortest paths). So, based on the answer here, I've written down the code:
def floyd_warshall(n, edge):
rn = range(n)
dist = [[inf] * n for i in rn]
nxt = [[0] * n for i in rn]
for i ...
I have some code below, it works but it doesn't really seem ideal. Is there a better way to write this using react-router?
<div>
<BrowserRouter>
<Route path="/" exact component={AuthorizeReddit} />
<Route path="/authorize_callback" exact component={Initialization} />
<Route path="...
While Code Review might be a good place to suggest going for this type of question, we should get out of the habit of sending question-askers over there. Please read this meta post for clarification. — Alessio43 secs ago
I have a mutableListOf a sealed class.
I am trying to compare the result coming from the api with the ones saved in the db so I can update my UI base on isSaved attribute. Here is my code :
sealed class MasterList(val type: Type) {
data class FavoriteList(
val list: List<Info>
)...
"Best" and "cleanest" are not objectively measurable quantities and thus are not really good measurements for Stack Overflow questions. Please edit your question to include what you're finding "unclean" or "bad" about the code you have that you'd like to improve, or, if the code is written by yourself, you're willing to share all of it, and would like all parts of it thoroughly reviewed, you could check the help center of Code Review to see if it's on topic over there. — Heretic Monkey16 secs ago
@SebastianMach Since the code is not working as intended it is off topic for Code Review. — 1201ProgramAlarm43 secs ago
Use whatever you feel works. When you have done something more than just written code for the sake of testing, then I would recommend that you post at Code Review. Right now there's really not much to review. Reviewing your whole pong app however, now that would be interesting! — Simon Forsberg27 secs ago
Just starting out trying to do some python for data analysis. I am a total beginner and have figure out how to brute force somethings, but I know it is inefficient but don't know how to do it without messing up what i have.
I have multiple webpages to scrape and then store data in a data frame. ...
I've written below python script just to invoke parallel threads of a command nslookup linux-host01 dns-server, i'm Just trying to flood the DNS Server dns-server with multiple number of queries in parallel way.
As an argument to this script i'm passing a hostlist file example linux-host01 , lin...
I listened to talk3 all the way through, and I have several problems with it. I'm suspecting that his experience predates agile and that everyone he's ever worked with went out of their way to show, by example, how non-agile development can go horribly wrong.
Some of his overly broad generalizations of problems in OO are things that can go wrong in any kind of development, or relate to concepts that he has either never heard or dismissed out of hand.
He said something in OO about method names being a lie. That does happen, and one of the most basic principles of agile is that when the name is wrong, you fix it.
However, in that same section, he mentioned something about the work actually being performed elsewhere, and that often happens when you have an API and some of the features are delegated.
istm the gist of it is he likes separation of data and functionality as a programming style, but you can still do it with oo, and then bashes oo a bit just for good measure
@Hosch250 I would say that functional, OO, and procedural are all different tools appropriate for different things and the use a mixed OO/Functional language so that I have all of the tools and can pick the best one for each individual piece of code.
@overexchange i think the most general example of what he's talking about would be the sort of scenario where you have a Foo class that doesn't really do much besides hold some data, and a FooManager that handles everything you'd wanna do with a Foo
good question, i guess Foo would actually be the datatype, maybe FooManager is the state manager and something else entirely does the logic... i guess we need a better example than Foo
I learned from CS61A, that OOP is needed when a value has multiple states. value I mean business value, not the temporary variables holding the value for computing logic
hmm i mean something like doFooStuff(foo) vs foo.doStuff() ... doFooStuff(foo) is gonna resolve to whatever it resolves to regardless of what foo is, but foo.doStuff and bar.doStuff could do different stuff
C#'s functional pieces make it by far easier to use, but they don't come close to the F# features.
@user11536834 What do you mean by that?
Not sure, but is it more less documentation helping you learn the massive paradigm shift?
Because if you are in the middle of it, I'm happy to talk things through with you--I went through that a couple years ago, and I'm no expert, but I have some familiarity with it.
i'm thinking generally like how something like prolog works, you don't say "do this stuff," you define some state transformations, drop in some initial state, and let it solve for all possible outcomes
@Hosch250 I think switch in most languages is just a convenient way of writing chained ifs. Though some languages do it better - Scala's are very flexible.
so you could think of old java versions as not MP, but just OO (can't have anything that's not attached to an object), but newer javas as MP because you have lambdas and stuff now
I am attempting to create a web application that will allow people to enter certain bands in a list, e.g
Metallica
Megadeth
Tool
and a Spotify playlist ID to allow the program to add 'x' amount of songs per band to a playlist.
The flow of the validation code goes:
public void GeneratePl...
i was thinking old java specifically as being "more OO" than others because of things like no top-level static classes, no functions that aren't methods, etc, basically everything is an object
I am making a simple 2 player pong game(with the canvas element). The game itself works good but I try to send the coordinates of the ball and the paddle-position with 'WebSocket' to the other plyer.
The code(game):
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d...
there aren't any "keywords" in the language per se, it's just checking for tuples in a big list of tuples, binding some free variables on the way, replacing tuples with other tuples
the lines that look like multiply 3 and 16 as B are setting up the initial state (tuples in dataset), everything else is state transition rules
addition is unary is easy, can just concat, but then negatives make it more difficult... if the numbers are encoded like +++ --- can recursively replace -+ and +- with empty string
I have been trying to understand and play around with javascript closures and that is when I came across the below issue.
Am trying to add/remove elements from an array declared inside a function. I have been able to add or remove and access the updated array for the same. But when I access the ...
I often find in codebases something on the order of if (sprockets.Count() > 0) which is easily replaced with LINQ's if (sprockets.Any()). This keeps the entirety of sprockets from having to be iterated over completely (to get the count) then comparing to zero. Further, the business logic often re...
sometimes i wish it were easier to use program entrypoints as library functions
have written code basically identical to this before: ``` extern int main(int, char**);
/* this should be the entry point, i.e. -Wl,-e_main */ int _main(int _argc, char** _argv) { char* argv[] = { "", "some arg" }; return main(2, argv); } ```
I'd warmly recommend putting up your full working code up for review on Code Review; you'd be surprised how a working piece of code can end up after another pair of eyes has gone through it, let alone with everything there is to learn from CR answers. — Mathieu Guindon43 secs ago
I'm stupid... I'm writing TypeScript, and extracting a class to it's own file, but suddenly it can't be compiled.... silly me created a .js file instead of a .ts file so the compiler didn't know that it was TypeScript I wanted to use...
I am traversing two objects that may share a common ancestor. To make the code small enough to show here, I have changed it into two dictionaries with values. As you can see, a_d and b_d are the inverse of each other. The idea is to step into each dictionary step by step until we find an overlapp...
Code review: (a) does not compile (b) useless extra variable counter, you already have two loop variables you could have used one of those (c) poor variable naming (counter - what is it counting?) (d) platform-specific: don't use literal "\r\n" (e) don't answer questions that don't provide an attempt, you're just doing someone else's homework. — iakobski39 secs ago
I currently have an event listener tied to Laravel's Attempting class. The listener is designed to rehash an old password to something newer. The current DB stores the pass in an old crypt format. I'm just silently converting that old hash to a newer one. This works when going to the site to logi...
I have simple class that I want to ask if is there any possible to improve it? I mean, for me it looks poorly. Is there any way to use here try-with-resources, stream or optional?
package bookstore.scraper;
import lombok.extern.slf4j.Slf4j;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Documen...
This question is too broad for StackOverflow, however is on topic for CodeReview as others have suggested. I find this to be a helpful reference in these situations: A guide to Code Review for Stack Overflow users. You'll notice that it clarifies StackOverflow questions require a specific goal (which 'more optimal' doesn't seem to reach), whereas CodeReview is tolerant of open-ended questions and answers. — Tyler Roper9 mins ago
I made a task scheduler to practice allocators and type erasure. With my project, you can delay execution of any callable (functions (using std::ref), lambdas...) in time by inserting it in a TaskScheduler, and by giving a std::chrono::time_point (you can also make a task be called multiple times...
I have a list of 2D matrices. Each matrix is filled using the function “fillMatrices”. This function adds a number of individuals to each day 0 in a matrix and updates the columns “a_M”, “b_M” and “c_M”. The numbers of individuals come from an initial matrix “ind”. The code works but it is slow w...
I've developed a small memory game, the game contains a function to flip cards for every turn. I'm looping thru the array containing the images every time to pick one card. I'm sure there's away to optimize this function so I don't have to loop thru the array every time in order to just turn one ...
Work flow is Copy Previous Year Reports Folder, Update Following Templates, Save, Close. There are 19 workbooks in the Source Folder and in the NewYear Folder. Each Work book has to save the final data from the end of the year(the "YTD ACTUAL" pages) along with resetting and prepping the month sh...
Could someone test my code and tell me if it worked. If you can help me with suggestions or bugs.
This code has a class called rank. Its properties are: toString (), toArray ().
toString (): Returns a custom ranking text.
toArray (): Return an array with the rank.
new Rank (values in an array...