I am trying to draw a recursive structure in python using the turtle module. Essentially, the function to draw this structure is drawFrames(d), where d is the 'depth', i.e. a number specifying the complexity of the fractal. d=1 just splits the window into 4 rectangles (no recursion); d=2 splits e...
I decide to open three url tabs in one chrome window with following code:
import subprocess
open_chromes = [
'https://en.wikipedia.org/wiki/Embodied_cognition',
'https://docs.python.org/3.6/index.html',
'https://docs.djangoproject.com/en/1.11/',]
for chrome in open_chromes:
cmd = ['open', '-...
As a fun project with my wife, I decided to make a small text adventure game à la Zork. Instead of using available engines, I decided to roll my own. It won't be that hard since there are no graphics.
The piece of code I submit for review is a class representing a room in the game. The processI...
def euler122():
out=[[1,2]]
out2=[1,2]
count=0
flag=True
while flag:
print len(out)
print "-"*59
for i in out:
for j in [x+y for x in i for y in i]:
if i+[j] not in out and sorted(list(set(i+[j])))==i+[j] and j not in out2:
if count%100==0: print l...
I would have had more incentive to at least gloss over all of this post if it was introduced succinctly. I take this works by and large: consider asking on Code Reviewafter due time (My take: 60 hours, minimum - well, this post had at least 48...). — greybeard44 secs ago
I'm making my first steps in OOP and I'm currently doing some exercises. I've done a simple program with class structure like this (I'll provide only essential parts): Super class: public abstract class Employee { private String lastName; private float salary; public Employee(String lastName, float salary) { this.lastName = lastName; t…
Help me, please. Check my code.Did I do everything right?
There is an assignment:
Implement the function to find the combination of 4 digits in a row which gives the max multiplication. If object is not a string or there are no combinations found - return nil. If combination is found - return i...
error he bsdk program me.errrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr...
Situation:
I am trying to download files, for the latest available month, from the webpage NHS Delayed Transfers of Care. I am unable to locate these files, within the HTML, with confidence that my current code will continue to work over time.
Question:
How do I isolate the latest month with ...
It has been mentioned recently that ~62% of close votes come from the "broken code" or "code not yet written" category. I'm wondering if we could help lower that percentage by detecting certain key phrases in the title (or possibly body) of the question and give a red warning banner before the us...
I have code similar to the one below. It iterates over a 2D grid using smaller sub-regions. Because this is happening in parallel, I use unique_ptr. Now I came across a weird memory-leak that made me think whether using unique_ptr here may me wrong. Is this memory leak free?
#include <thread>
#i...
I am wondering if there's a best practice using this new pattern in javascript and async/await keywords instead of traditional callbacks
Core function:
async function typeWriter(text, n, elementId, waitAfter) {
const el = document.getElementById(elementId);
if (n < (text.length)) {
...
It's been a long time since my last post. I decided to continue this little project and tried to debug the GetBootstrap v2.7. I found out that the progress bar that I create is not working properly when the size of console buffer is changes. so I decide to rewrite it again.
Below, the progress t...
Intersting, here's his answer btw, I'll post a question on code review later about it, and thank you very much for your answer — Robert Andersson22 secs ago
I am trying to get number of times (or sessions) a user re-visited the website.
What I'm trying to find out-
Get the total number of users, number of sessions in the last 30days. I need to a pie chart ultimately where it shows people who revisited-
more than 100 times,
50-100 times,
less than...
I have the following extension method to add themes support to my application:
public static void AddThemes(this IServiceCollection services, Action<ThemesOptions> setupAction) {
services.Configure(setupAction);
}
Where ThemesOptions is defined as:
public class ThemesOptions {
public ...
Input -int arr[] = {3,3,0,0,3,3,3,0,3,3,3,3,0,0,0,3,3,3,3,3};
Ouput should be 5
As the the set of number 3 is repeated maximum time in an array.. Please give me optimized solution
In this chart I'm calling d3.csv everytime I update the data, which if I understand correctly is a bad thing to do.
In this answer on S.O Gerardo explains that d3.csv is asynchronous and the data should only be loaded in once.
I understand why that is, but what I'm wondering now is what is a b...
Today I found myself reinventing output separators for the zillionth time.
I have converged on an approach like the following that seem pretty clean:
Live On Coliru
#include <iostream>
void foo(int a, int b) {
auto sep = [first=true]() mutable { return first? (first = false, "") : ", "; }...
I have created one Background service that execute after every 5 minutes and this service used for sending email after 6 hour,24 hour and 48 hour for user booking order is not confirmed.
for that i have created below method and enums.
public enum Enum_AbandonedCartEmailNotifyHour
{
...
@willlplaya please always try to reduce your code to the minimum before you post it here. I also recommend posting your game on codereview.stackexchange.com/questions/tagged/pygame to get some refactoring tips. On the codereview site you have to post all of your code instead of a minimal example. — skrx50 secs ago
I am given a task to write a program to find the largest palindrome made from product of two 3 digit numbers.
Below is the code :
def check_palindrome(s):
"""Checks whether the given string is palindrome"""
if s == s[::-1]:
return True
product_pal = []
for i in range (9...
First off, this is a legacy project that I inherited, so there are some aspects of it that I will have to explain as "that's just the way it was done and I haven't found a better way". However, I am always open to better ways.
I am working on a scrapbooking product involving a large number of ph...
I've written a function which takes as an input
a string to be modified
a vector of regular expressions on which to match
a vector of replacements
option to ignore case in the match statements
The function will then, from the users perspective, simultaneously perform all replacements in a 'sa...
Thanks, I wasn't familiar with stackexchange codereview until you mentioned it! I did it here so that anyone searching for such a regex would easily find it. — Medievalist30 secs ago
This is a follow-up from Digital clock with many functions
I used the review mentioned above to optimize the code, but the code can still be made better.
I made a digital clock with the use of an RTC (DS3231) and an LCD (16x2).
Current functions:
Display time
Display date (different formats)...
I am trying to work my way on this exercise on HackerRank, using C as an excuse to learn. https://www.hackerrank.com/challenges/sparse-arrays/problem
It's really unclear to me why I don't seem to get the desired output. Any thoughts?
#include <stdio.h>
#include <stdlib.h>
#include <string.h> ...
I'm making a digital clock with ES5 ( no arrow stuff and so ). The location and temperature I'll do later.
How can I improve/refactor the current code that I have with functional programming?
CodePen: https://codepen.io/Aurelian/pen/opaxqx?editors=1010
This is the HTML:
<div class="clock">
<...
This is my implementation for this hacker rank problem.
My first attempt I think is very readable (ignoring the way input and output is handle in hacker rank)
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<long long>...
This is my solution to find the combination of 2 overlapped rectangles implemented in JavaScript.
rectangle is presented by 2 points(x,y).
So do you have a better solution ?
const maxOfX = (rec) => (Math.max(rec.x1, rec.x2));
const maxOfY = (rec) => (Math.max(rec.y1, rec.y2));
const minOfX =...
I am given a task to Create a function that prints a random anagram of a given string
Below is the code:
def anagram(value):
'''Prints random anagram of given value'''
import random
newWord = ''
for i in range(len(value)):
pos = random.randint(0, len(value)-1)
...
An example of the business rules are here.
Does this code implement those rules correctly? Note that you will have to derive the rules from the example.
/*
test number from url
9876543217
other valid numbers
5322369835
7089771195
8108876957
4395667779
6983806917
not valid numbers
2790412845
...
Here is my code that need to process 100*250 000 data in less than 3s (i don't know the exact spec of the running machine)
As i'm quite new to coding, what can i improve or change to make it faster, and more optimized ?
Here is the code chef page to the problem : https://www.codechef.com/problem...
In my program I need to impersonate users on the domain network to perform various tasks. Obviously I can only be one user at a time, and there are multiple threads that would like to be either the same or a different user.
I thought it would be neat to generalize the solution, so if you know o...
Recently, I posted the following question on Code Review:
Convert ES6 yield recursive method to a loop
At beginning, I post a question whith my actual code; asking to know if there is a way to write the same thing as not recursive methods.
I made the error to simplify the code (to my mind to be...
I'm using SAP's Raylight RESTful SDK to get a list of universes from the BusinessObject Enterprise repository.
To get all of the universes, the request needs to be called repeatedly, incrementing the offset parameter until the request returns a Not Found [404] error.
Current approach:
$baseUrl...
Code reviews belong on codereview.stackexchange.com. Check their help page and then consider moving this question over there after ensuring your question meets their standards. — rmaddy42 secs ago
i am saving string input in firebase and updating the front end realtime with firestore. how can i do these same thing in fewer lines of code. Is there a better way to do this?
// Initialize Firebase
var config = {
apiKey: "AIzaSyDZJgaeqMCztZYbBk-83Oiv5HVhioLsyhQ",
authDomain: "my-proje...
I have a JavaScript code that gets the inner text content of certain table cells in a row and displays them as a tooltip on mouseover. However, I am a novice at JavaScript and I do not know how to make the code more efficient and/or secure from exploits. Could please review the following code and...
I am working on ASP.NET application and I would like to get some feedbacks about refactoring ideas, in particular on the WebAPI part.
Spoiler alert: the current design is really rubbish.
Note:
Get: Get all the items (unless some sort of filtering is applied)
Post: Add new item
Put: Update ex...
This program does not quite conform to the previous related question, yet does basically the same thing: given a collection of elements and a collection of indices, return via an iterator collection elements according to the sequence of indices. Here it goes:
#include <exception>
#include <iostream
Hi guys, pretty new on CR SE. What is the best way, when you make a code review question, they give you some input in their answers and you want to "repost" the new code? Update the old code? Post a new question?
I want to create singleton object of a third party caching library (ThirdPartyKVStore). But I don't want to reference this class all over the places from where I want to access the cache. To address this, I created a wrapper CacheManager which is managing the lifecycle of ThirdPartyKVStore. Does ...
Using python's lxml I must read an XML file and print from each "basic" and "expert" tag, the name and email text from it. I've done a script that works but I don't think is the best way of doing this. Is there a better (simpler) way for getting the data of the xml without having to make 2 iterat...
Take a look at this page of the Help Center - What should I do when someone answers my question?
If you only read the text with special markup, as someone would when skimming the page, it reads like so:
What should I do when someone answers my question?
vote
accepting the answer
mark an answer...
Seems like the conclusion is that this should be moved to code review. I'm (obviously) new here... Is there a builtin way to move it, or should I delete this and repost there? — John Aaron13 secs ago
Before I added the if, else it was working fine
Basically, i want to make it so if the sans.db has been modified once in the morning, do not modify it again when the flask page loads, but if it hasn't been modified create the table, is there a better wwy to do this, currently it doesn't work
i...