body
stringlengths
25
86.7k
comments
list
answers
list
meta_data
dict
question_id
stringlengths
1
6
<p>I have a dataset of video frames in a folder with the directory structure looking like this:</p> <pre><code>-parent -video_id -frame0 -frame1 -... </code></pre> <p>My code, gathering frames into a Pytorch dataset and splitting them up into patches is quite slow in the <code>__init__</code> method/phase when s...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-17T06:09:23.950", "Id": "266115", "Score": "0", "Tags": [ "performance", "image", "video", "pytorch" ], "Title": "Pytorch Video Frames Dataset Implementation" }
266115
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>let array = [1,7,2,2,3,7,4]; while(array.length){ // get last item let item = array.pop() ...
[]
[ { "body": "<p><strong>Time complexity is calculated as the worst case condition:</strong></p>\n<p>Here the while loop <strong>can loop &quot;n&quot; times max</strong> ( case where there are no repeating elements )</p>\n<p>each statement inside while loop <strong>expect array.filter has complexity of 0(1)</stro...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-17T09:12:20.757", "Id": "266120", "Score": "-2", "Tags": [ "javascript", "performance", "functional-programming", "ecmascript-6", "complexity" ], "Title": "Getting items that...
266120
<p>I have multiples measurements and I want to render it into tables like this</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Measurements</th> <th></th> <th></th> <th>Operator</th> <th>browsings</th> <th></th> <th></th> <th>FTP DL</th> <th></th> <th></th> <th>FTP UL</th> <th></th> <th></t...
[]
[ { "body": "<p>there is many way to refactor this</p>\n<p>first change operator into integer/enum instead string, or change operator to become an object/table instead with a <code>name</code> and <code>order</code> column</p>\n<p>so that we can sort the browsings/ftpdl/ftp ul using <code>operator</code> column m...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-17T10:29:23.137", "Id": "266122", "Score": "1", "Tags": [ "ruby", "ruby-on-rails", "database", "postgresql" ], "Title": "Querying and rendering an HTML table of ISP performance s...
266122
<p><strong>Description</strong></p> <p>It is valid to say, this work started and evolved from a standalone DQN implementation, which I included in an old <a href="https://codereview.stackexchange.com/questions/253886/playing-pong-atari-game-using-a-dqn-agent">question</a>, to a mini-library <a href="https://github.com/...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-23T09:17:35.947", "Id": "526080", "Score": "0", "body": "anyone interested in reviewing this?" } ]
[]
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-17T11:08:42.423", "Id": "266124", "Score": "2", "Tags": [ "python", "python-3.x", "library", "machine-learning", "tensorflow" ], "Title": "xagents - implementations of reinfo...
266124
<p>I'm working on a GPyT (generative python transformer) project and I have written the below script to download lots of Python files from github.com to train my model. It works fine, but there is a problem I guess because it becomes slower with every file it downloads. It takes more time to download new files and whil...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-17T11:44:14.730", "Id": "266126", "Score": "3", "Tags": [ "python", "api" ], "Title": "Generative Python transformer hitting Github API" }
266126
<p>I'm implementing a function called <code>is_proper_integer</code> that will check the string whether it is a valid integer literal by borrowing the idea from C++ grammar.</p> <p>Function signature:</p> <pre class="lang-cpp prettyprint-override"><code>constexpr bool is_proper_integer(std::string_view str, ...
[]
[ { "body": "<blockquote>\n<p>the function is declared as constexpr so that the function is usable at compile-time.</p>\n</blockquote>\n<p><strong>good</strong>!</p>\n<blockquote>\n<p>str has the plain type std::string_view so that I could modify it by calling remove_prefix and remove_suffix within the definition...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-17T13:29:38.957", "Id": "266127", "Score": "1", "Tags": [ "c++", "strings", "integer", "c++20" ], "Title": "Validating an integer with affixes in compile-time or runtime" }
266127
<p>This is my third version of building a simple Python calculator. The first two versions only operate on two inputs to perform calculation, this version allows multiple inputs. However, the result will leave a <code>.0</code>. Other than that, is there any way I can further improve this program? I've also included do...
[]
[ { "body": "<h1>Doc test</h1>\n<p>It looks like you've intended to include &quot;doctests&quot; in your <code>&quot;&quot;&quot;docstrings&quot;&quot;&quot;</code>, but it doesn't appear that you've used them.</p>\n<p>Running the tests ...</p>\n<pre class=\"lang-py prettyprint-override\"><code>&gt;&gt;&gt; impor...
{ "AcceptedAnswerId": "266173", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-17T14:13:57.257", "Id": "266129", "Score": "4", "Tags": [ "python", "python-3.x", "calculator" ], "Title": "Simple Calculator Program That Operates On Multiple Inputs" }
266129
<blockquote> <p>I have array [1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4] so I want to move all duplicates at the end of the array [1, 2, 3, 4,1, 2, 2, 3, 3, 4, 4, 4]. is there is another best way to do the same <em><strong>Go</strong></em> Time O(n) and space O(1)</p> </blockquote> <pre><code>package main import &quot;fmt&q...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-19T05:27:04.667", "Id": "525826", "Score": "0", "body": "But your solution is not `O(1)` space. You use additional memory for `key` map, and `original`/`duplicate` slices." }, { "ContentLicense": "CC BY-SA 4.0", "CreationDa...
[ { "body": "<p>the full program available <a href=\"https://play.golang.org/p/a8mCEj36ddR\" rel=\"nofollow noreferrer\">here</a> outputs</p>\n<pre><code> original []int{1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4}\n sorted orig []int{1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4}\n withMap []int{1, 2,...
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-17T14:36:38.793", "Id": "266131", "Score": "1", "Tags": [ "array", "go" ], "Title": "move duplicate items at the end of the array" }
266131
<p>I have a dataframe of cases that score 0-1 on a group of binary attributes.</p> <p>What I want to do is extract all possible ombinations of attribute triplets (e.g. A/B/C, A/B/D... out of A-E) and then sum for each possible combination triplet the number of times a case in the original dataframe matched those attrib...
[]
[ { "body": "<p>Maybe something like this, with <code>base</code> functions:</p>\n<pre><code>rez &lt;- apply(test_matrix[, c('T1', 'T2', 'T3')], 1, function(x) {\n y &lt;- test_df[, x]\n sum(rowSums(y) == 3)\n}, simplify = T)\nrez # vector\n\ntest_matrix$Size &lt;- rez\ntest_matrix\n</code></pre>\n", "comme...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-17T14:36:56.833", "Id": "266132", "Score": "0", "Tags": [ "combinatorics", "r" ], "Title": "Increase speed of lapply function identifying the sum of all existing combinations" }
266132
<p>Here I have a multidimensional list in python. Suppose I take an input, how do I find the number of adjacent elements of that input which are alphabets other than itself? If there are multiple indices at which the element is placed, then we have to print the maximum of all possibility. For example, the number of adj...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-17T21:09:06.563", "Id": "525712", "Score": "2", "body": "Can you provide extra examples of expected input and output?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-18T13:01:00.000", "Id": "525752", ...
[ { "body": "<ul>\n<li>To be honest, I can't quite confirm what you actually want. Since you ask in <code>Code Review</code>, I assume you want someone to review your code and give some advice.</li>\n</ul>\n<h3>advice</h3>\n<ol>\n<li>Please always use meaningful name to variable and function name, don't use somet...
{ "AcceptedAnswerId": "266153", "CommentCount": "5", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-17T14:57:58.870", "Id": "266135", "Score": "-4", "Tags": [ "python" ], "Title": "How to find adjacent elements in multidimensional list in Python?" }
266135
<p>I have this class</p> <pre><code>export class CurrentLanguageService { currentLanguage(loggedUser: User): string { if (sessionStorage.getItem(LanguageStorageKey) !== null) { if (Object.keys(Languages).includes(sessionStorage.getItem(LanguageStorageKey))) { return sessionStorage.getItem(LanguageSt...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-17T16:05:36.537", "Id": "525693", "Score": "5", "body": "The current question title, which states your concerns about the code, is too general to be useful here. Please [edit] to the site standard, which is for the title to simply stat...
[ { "body": "<p>I don't think the logic is correct. Why return the default language if there is a language corresponding to the language storage key but not contained in <code>Object.keys</code>? I'd think the language of the logged user to be the better alternative.</p>\n<pre><code>var language = sessionStorage....
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-17T16:00:57.023", "Id": "266140", "Score": "-2", "Tags": [ "c#", "typescript" ], "Title": "So many if and else conditions" }
266140
<p>I've been doing project euler problems in Haskell, and often I've found the need to get the value that gives the maximum of a function.</p> <p>For example,</p> <pre><code>answer = argmaximum $ map collatzLength [1..10^6] </code></pre> <p>Where collatzLength is a previously defined function.</p> <p>I came up with thi...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-18T09:47:33.853", "Id": "525743", "Score": "3", "body": "I believe you are looking for `maxmimumBy (comparing collatzLength) [1..10^6]` or `maximumBy (compare \\`on\\` collatzLength) [1..10^6]`. I’m not sure I understand how your funct...
[ { "body": "<p>What you have implemented here is strictly speaking not argmaximum, but finding a maximum index in a list. The difference is that your argmaximum will not return the correct value for invocations that don't <code>map</code> from <code>[1..?]</code></p>\n<p>Instead of that, you probably wanted some...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-18T01:00:20.400", "Id": "266148", "Score": "1", "Tags": [ "haskell" ], "Title": "Finding the argmaximum of a list in Haskell" }
266148
<p>I created a simple Unicode-based markup language called <em>Incipit</em> and an <code>awk(1)</code> script to convert a text written in Incipit into html or troff -ms.</p> <p>A example of text in incipit is below, the result of which, converted to troff -ms and then to ps and pdf is <a href="https://raw.githubuserco...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-18T04:30:58.650", "Id": "525723", "Score": "0", "body": "Also on [github](https://raw.githubusercontent.com/phillbush/incipit/master/README.pdf)." } ]
[]
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-18T04:29:14.620", "Id": "266151", "Score": "0", "Tags": [ "awk" ], "Title": "awk script to convert simple markup language to troff or html" }
266151
<p>I have this doubly-linked list data structure that runs all the single-element operations in <span class="math-container">\$\Theta(\sqrt{n})\$</span> time (refer to <a href="http://coderodde.github.io/weblog/#eill" rel="nofollow noreferrer">this post</a> and <a href="https://github.com/coderodde/LinkedList" rel="nof...
[]
[ { "body": "<p>After 24 days being asked, just a tiny review, as I actually cannot spend time. It is sad noone found time to do a thorough review on something promising. Probably because of the effort.</p>\n<p>Use <a href=\"https://docs.oracle.com/javase/10/docs/api/java/util/Objects.html#equals(java.lang.Object...
{ "AcceptedAnswerId": "267901", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-18T06:12:05.377", "Id": "266152", "Score": "2", "Tags": [ "java", "performance", "linked-list", "heuristic" ], "Title": "Faster, indexed, heuristic doubly-linked list data st...
266152
<p>I have this benchmark program for my <a href="https://codereview.stackexchange.com/questions/266152/indexed-heuristic-doubly-linked-list-data-in-java-implementation">indexed linked list</a>.</p> <p>It looks like this:</p> <p><code>com.github.coderodde.util.benchmark.LinkedListBenchmarkRunner</code></p> <pre><code>pa...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-12T15:18:54.663", "Id": "528277", "Score": "0", "body": "I see a lot of redundancy. Why would you have class that handles *all* methods at once? That doesn't look like a good *strategy* to me. Maybe you want to just compare *two* list ...
[ { "body": "<p>There's a lot of scope for consolidating the benchmark code. Reducing some of the duplication can make it easier to update the code and help focus on core functionality of some of the methods. With that in mind, here's a few suggested refactorings...</p>\n<h2>A List is a List</h2>\n<p>You've got f...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-18T07:32:58.703", "Id": "266154", "Score": "2", "Tags": [ "java", "performance", "linked-list", "benchmarking" ], "Title": "Faster, indexed, heuristic doubly-linked list data str...
266154
<p>Here I have the unit tests for the <a href="https://codereview.stackexchange.com/questions/266152/indexed-heuristic-doubly-linked-list-data-in-java-implementation">indexed doubly-linked list</a>.</p> <p>It goes like this:</p> <pre><code>package com.github.coderodde.util; import java.io.File; import java.io.FileInpu...
[]
[ { "body": "<p>A few things to consider...</p>\n<h2>Naming</h2>\n<p>Naming is important, code is read a lot more than it is written and anything that makes the code easier to read helps. One element of that is consistency, which is something that your test names don't have. Some of them start with <code>test</c...
{ "AcceptedAnswerId": "268201", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-18T07:38:14.817", "Id": "266155", "Score": "0", "Tags": [ "java", "linked-list", "unit-testing" ], "Title": "Faster, indexed, heuristic doubly-linked list data structure in Java:...
266155
<p>So I've made a button in the right-bottom corner of my HTML-page, but I was wondering since it's the first time I've made this, if there is another better way to do this, or if you guys can see anything funky about the way I did this?</p> <p>This post is mostly to learn how to do things the right way, since I'm a be...
[]
[ { "body": "<h2>Some JS points</h2>\n<ul>\n<li><p><a href=\"https://developer.mozilla.org/en-US/docs/Web/API/window\" rel=\"nofollow noreferrer\" title=\"MDN Web API's window\">window</a> is the default object. You seldom need to use it. eg <code>window.scrollTo</code> is the same as <code>scrollTo</code> as is ...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-18T08:53:51.783", "Id": "266156", "Score": "1", "Tags": [ "javascript", "html", "css" ], "Title": "Best way to make a scroll top/bottom button" }
266156
<p>The <a href="https://en.wikipedia.org/wiki/Assignment_problem" rel="nofollow noreferrer">assignment problem</a> is about assigning tasks to workers, where each pair (worker, task) has a cost. The <a href="https://en.wikipedia.org/wiki/Hungarian_algorithm" rel="nofollow noreferrer">Hungarian algorithm</a> builds an o...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-21T19:33:14.960", "Id": "528911", "Score": "0", "body": "You still use Solver on line 35 of HungarianSolver." }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-21T20:06:39.773", "Id": "528915", "Score"...
[ { "body": "<p>Your nose is correct. What you smell is the effect of voids that mutate the state of the class, so you need to expose the internals.</p>\n<p>First step would be to split initialization into a factory.</p>\n<pre><code>public class HungarianSolverFactory\n{\n public static HungarianSolver hungari...
{ "AcceptedAnswerId": "268235", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-18T09:08:04.777", "Id": "266157", "Score": "5", "Tags": [ "java", "unit-testing", "junit" ], "Title": "Hungarian algorithm for optimal assignment" }
266157
<p>I have created two simple classes: <code>resource</code> and <code>container</code>. below is the full code. actually container keeps resources. and in the beganing it will get all the resources and store them in datalist of resources. The other function is simply prints out all the resources in container. Please re...
[]
[ { "body": "<p>Your code is a weird mix of C and C++. It's essentially C with classes (which is to say, it's not very good C++ code).</p>\n<hr />\n<ol>\n<li><p>Use <code>constexpr</code> instead of <code>#define</code> to define constants. <code>constexpr</code> retains type information.</p>\n</li>\n<li><p>Use <...
{ "AcceptedAnswerId": "266171", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-18T10:25:40.230", "Id": "266159", "Score": "0", "Tags": [ "c++" ], "Title": "Class using resource pointer- Resource class with copy constructor and copy assignment operator" }
266159
<p>I have written the following function which works as expected but I still see there is some room for improving its readability</p> <pre><code>def get_claims_to_search(): claims = [] database_priority = DatabasePriority.objects.first() low_priority_claims_databases = ClaimsDatabase.objects.filter( ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-18T15:17:16.473", "Id": "525767", "Score": "4", "body": "Please provide sufficient context for reviewers to understand how that code is used. Please [**follow the tour**](https://CodeReview.StackExchange.com/tour), and read [**\"What t...
[ { "body": "<p>The function seems to be inconsistent; I don't know what is it intended to do, so if you say it works as expected, probably you can lose some functionality on unnecessary &quot;beautification&quot; of the code.</p>\n<p>What inconsistency am I talking about: the central (and the longest) part of th...
{ "AcceptedAnswerId": "266169", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-18T12:19:45.867", "Id": "266162", "Score": "6", "Tags": [ "python", "django" ], "Title": "Get list of claims based on priorities" }
266162
<p>I recently posted a bunch of code of my to-do list application and after getting some very helpful and good suggestions on how to improve, I took a shot at it! Here's a link to the former post I made -&gt; <a href="https://codereview.stackexchange.com/questions/266001/a-to-do-list-application-written-with-java">A to...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-23T14:10:46.177", "Id": "526103", "Score": "0", "body": "Do you have all of these classes inside one file or did you copy everything into the same code block?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08...
[ { "body": "<p>You improved the program by a lot but then misunderstood some of @TorbenPutkonen's suggestions. As it turns out, the program runs just as fine when you change all <code>StorageInstance</code>s to <code>Storage</code> and remove the interfaces you added.</p>\n<h3>The Storage instance</h3>\n<p>Let's...
{ "AcceptedAnswerId": "266351", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-18T13:09:40.157", "Id": "266165", "Score": "1", "Tags": [ "java", "beginner", "object-oriented", "design-patterns" ], "Title": "Java dependency injection and hiding details o...
266165
<p><a href="https://pchemguy.github.io/SQLiteDB-VBA-Library/" rel="nofollow noreferrer">SQLiteDB VBA Library</a> is a set of VBA helper functions for the SQLite engine. The primary motivation behind this project is to provide convenient access to extended introspection features. Because of its generality, ADODB/ADOX li...
[]
[ { "body": "<p>Micro-review:</p>\n<pre><code>'@IgnoreModule ProcedureNotUsed\n</code></pre>\n<p>I used to sprinkle this around too, however there are a few reasons not to use it:</p>\n<ol>\n<li>It indicates your integration tests - if held in the same project files - do not hit this code path, which should be fi...
{ "AcceptedAnswerId": "266174", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-18T14:03:53.053", "Id": "266166", "Score": "3", "Tags": [ "sql", "vba", "excel", "database", "sqlite" ], "Title": "VBA introspection library for SQLite" }
266166
<p>I'm attempting to integrate with a rather dated API (for work so I can't disclose actual naming, endpoints, etc), and their data models for POST endpoints, very clearly implement an interface that looks similar to:</p> <pre><code>public interface IExternalData { int CallerId { get; set; } string CallerName {...
[]
[ { "body": "<p><strong>UPDATE</strong></p>\n<p>Thank you for adding more clarifications. Since you're working with a web service. There are some questions that I've asked myself with your solution.</p>\n<p>If the Web API provider updated their endpoints with new keys, do you need to add them to the current solut...
{ "AcceptedAnswerId": "266177", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-18T15:26:12.967", "Id": "266168", "Score": "1", "Tags": [ "c#" ], "Title": "Adding structure to a flattened data model instead of using an interface?" }
266168
<p>What I'm trying to do is quite simple: my table has pagination. So if I have 12 items to show and my max items per page is 10, I will have 2 pages, one with 10 records and another with just 2. I created a code that works just fine, but it seems rather dirty. What is the best way to have the same outcome as the code ...
[]
[ { "body": "<h1>Working with your code</h1>\n<h2>Refactor</h2>\n<p>First of all, let's extract clear &amp; separate function</p>\n<pre><code>function getPaged(items, itemsPerPage) {\n let pagesContainer = [];\n let page = [];\n let i = 0;\n for (const content of items) {\n if (i &lt; itemsPerP...
{ "AcceptedAnswerId": "266181", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-18T15:38:11.007", "Id": "266170", "Score": "2", "Tags": [ "javascript", "algorithm", "array", "pagination" ], "Title": "table pagination" }
266170
<p><a href="https://pchemguy.github.io/ContactEditor/" rel="nofollow noreferrer">ContactEditor</a> uses Excel VBA as a prototyping platform for a personal information manager combining the &quot;Model, View, Presenter&quot; (MVP) pattern and a persistent storage manager.</p> <p><strong>Fig. 1. Data manager application<...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-18T17:41:22.173", "Id": "525789", "Score": "0", "body": "You're using ADODB to Excel. This begs the question: \"Why aren't you using MSAccess to hold the data?\"" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021...
[]
{ "AcceptedAnswerId": null, "CommentCount": "7", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-18T16:17:47.003", "Id": "266172", "Score": "1", "Tags": [ "sql", "vba", "excel", "database", "adodb" ], "Title": "ContactEditor - Excel VBA db app: Storage Library" }
266172
<p>I've created simple sorting visualizer in c++ using SFML. I'd love some feedback on how can I improve the code and OOP design.<br> Whole project: <a href="https://github.com/AwesomeHunter/Sorting-visualizer/" rel="nofollow noreferrer">GitHub</a><br><br> <strong>main.cpp</strong></p> <pre class="lang-cpp prettyprint-...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-19T12:54:11.783", "Id": "525853", "Score": "2", "body": "In the future it would be better to add a follow up question with a link back to the original question rather than editing the question. Changing the question may cause answer in...
[ { "body": "<pre><code> const unsigned MIN_DELAY = 0;\n const unsigned MAX_DELAY = 100;\n\n</code></pre>\n<p>You don't need to make instance variables since these are the same in any/every instance. So also make them <code>static</code>. But, today use <code>constexpr</code> instead. The adage is <em>constexp...
{ "AcceptedAnswerId": "266186", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-18T17:27:09.777", "Id": "266175", "Score": "4", "Tags": [ "c++" ], "Title": "Sorting visualizer" }
266175
<p>In the <a href="https://codereview.stackexchange.com/questions/266172">previous post</a>, I presented my Storage Library. Here, I would like to focus on the integration of the library with the MVP component.</p> <p><strong>Functional class mapping</strong></p> <p><img src="https://raw.githubusercontent.com/pchemguy/...
[]
[ { "body": "<p>I have realized that it would be preferable to place all operations involving the <em>DataCompositeManager</em> instance within one module (Presenter). I recall that the reason I also kept such operations within <em>CONTROL_Change</em> handlers in the form code-behind was that I thought it would r...
{ "AcceptedAnswerId": "266182", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-18T20:35:50.443", "Id": "266178", "Score": "1", "Tags": [ "vba", "excel", "database", "mvp" ], "Title": "ContactEditor - Excel VBA db app: Storage Library and MVP" }
266178
<p>I wanted to make a blackjack game to use while bored, but it turned out to be far more complicated than I thought.</p> <pre class="lang-py prettyprint-override"><code>from random import choice, randint MASTER_DECK = [&quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;2&quot;, &quot;2&q...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-20T11:54:37.097", "Id": "525945", "Score": "0", "body": "Just a note; you don't seem to be handling the card suits in this, unless it's my mis-understanding of the source. It might therefore be better, as in a more complete game, if th...
[ { "body": "<p>A couple of things that I've noticed; for a better player experience, it might be worth allocating a suit per card, the easiest way to do this would be to modify the <code>MASTER_DECK</code> array as follows (with the correct character encoding, you could also have <code>♡♤♧♢</code> but I'm not su...
{ "AcceptedAnswerId": "267642", "CommentCount": "4", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-18T20:36:20.630", "Id": "266179", "Score": "5", "Tags": [ "python", "python-3.x", "playing-cards" ], "Title": "Text Based Blackjack" }
266179
<p>So I have done a little program where the goal is trying to teach some cars (red and blue rectangles) to &quot;drive&quot; through genetic algorithm. It works well and I haven't seen any bugs, but the program is painfully slow. As I am pretty much a begginner, I am sure there are tons of things that could be improve...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-02T23:28:04.357", "Id": "527790", "Score": "0", "body": "In your testing, do the red cars ever make it around the bottom-most turn?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-04T16:05:29.893", "Id"...
[]
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-18T20:44:27.447", "Id": "266180", "Score": "2", "Tags": [ "python", "performance", "genetic-algorithm" ], "Title": "AI learning to drive (simplistic) needing optimisation" }
266180
<p>I am currently creating a Java console program for a text-based Monopoly game as a personal project. Since this is my first project that I have worked on, I would like to know what kind of object oriented programming principles and designs that I am not following. Specifically, I am wondering if I am not creating en...
[]
[ { "body": "<p>Kudos for this decent-sized, non-trivial project. The general code quality is pretty good. Still, I have some suggestions for what could be done better, in my opinion.</p>\n<p>I will base my code review on the GitHub repository at this commit hash: 2a8709d</p>\n<p>I will make the suggestions for t...
{ "AcceptedAnswerId": "267751", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-19T00:17:30.250", "Id": "266188", "Score": "5", "Tags": [ "java" ], "Title": "Text-based Monopoly in Java" }
266188
<p>I wrote <a href="https://github.com/albert10jp/deep-learning/blob/main/logistic_regression_for_fashion_mnist.ipynb" rel="nofollow noreferrer">a Logistic Regression for Fashion MNIST</a> to classify T-shirt vs. Shirt.</p> <p>here is the class</p> <pre><code>import numpy as np import time class LogisticRegression: ...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-19T00:49:01.237", "Id": "266189", "Score": "1", "Tags": [ "python", "machine-learning" ], "Title": "Logistic Regression for Fashion MNIST T-shirt vs. Shirt" }
266189
<p>I am writing library code to help other developers send messages to a pub-sub event broker.</p> <p>In many cases, the message source will not be &quot;stream-like&quot;. Specifically, most messages are coming from SQL Server change data capture, and are therefore much more efficiently read in sets (batches).</p> <p>...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-19T01:39:56.020", "Id": "266190", "Score": "1", "Tags": [ "c#", "concurrency", "async-await", "tpl-dataflow" ], "Title": "\"streaming\" messages to a broker from a batch-like sou...
266190
<p>I was given the problem (called &quot;car plate problem&quot;) to write all the values that go from AAA0001 to ZZZ9999 with the following premises:</p> <ol> <li>Create all the possibilities from AAA0001 to ZZZ9999;</li> <li>Skip all the 0000, ie: AAB0000, AAC0000... ZZZ0000.</li> <li>No repetitions. Once a value is ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-19T14:07:08.637", "Id": "525860", "Score": "2", "body": "Could you clarify the exact problem definition? Does your code need to return the next increment for one given plate? Does it need to return all the increments? Or does it simply...
[ { "body": "<p>Your problem statement is to create all of the possibilities, not necessarily to support increment from an existing possibility. The difference is very important. It's slow to parse out a position in the license plate space, increment it and format it again.</p>\n<p>Instead, consider</p>\n<ul>\n<l...
{ "AcceptedAnswerId": null, "CommentCount": "10", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-19T02:20:54.687", "Id": "266191", "Score": "19", "Tags": [ "java", "performance" ], "Title": "The car plate problem: generate from AAA0001 to ZZZ9999 skipping the 0000" }
266191
<p>The question was on Leetcode <a href="https://leetcode.com/problems/min-cost-to-connect-all-points/" rel="nofollow noreferrer">1584. Min Cost to Connect All Points.</a> My answer to this question is:</p> <pre><code>class Solution { public int minCostConnectPoints(int[][] points) { List&lt;int[]&gt; list ...
[]
[ { "body": "<p>Your solution already seems to be implemented (rather) efficiently. My only advice is to rename <code>Find</code> and <code>Union</code> to <code>find</code> and <code>union</code>, respectively (Java style prefers lowercase chars at the first verb of a method name).</p>\n<p>In <code>UnionFindSet<...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-19T04:45:51.387", "Id": "266194", "Score": "2", "Tags": [ "java", "algorithm", "union-find" ], "Title": "Leetcode 1584. How to make my Kruskal&Union Find algorithm faster?" }
266194
<p>Which approach to creating repeating Runnables is better?</p> <pre class="lang-java prettyprint-override"><code> private final Handler handler = new Handler(Looper.getMainLooper()); private final Runnable runnable = new Runnable() { @Override public void run() { Timber.d(&quot;Repe...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-19T07:47:01.050", "Id": "266196", "Score": "0", "Tags": [ "java", "comparative-review", "android", "lambda" ], "Title": "Chain the same Runnable using Handler in Android" }
266196
<p>I want to check client's browser version, and if it's too old, display a message that the user should update their browser in order to use the website. The website is built using ASP.NET MVC.</p> <p>I have implemented 2 different solutions:</p> <p><strong>Solution 1 - Server side checking:</strong></p> <p>I have cre...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-19T12:20:19.280", "Id": "525850", "Score": "0", "body": "I can't speak to which would be the best, but I can point out that your switch statement could be its own function and instead of doing `if (version < 57) { isOutdated = true; } ...
[ { "body": "<p>I always go with the version that would be a best fit to the project.</p>\n<p>This means, you need to consider the overall project coding syntax, and how much code in the client side, to know where to focus more.</p>\n<p>Some projects focuses on server side more than using the client side handling...
{ "AcceptedAnswerId": "266246", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-19T10:18:09.663", "Id": "266201", "Score": "1", "Tags": [ "c#", "javascript", "html", "asp.net-mvc", "cross-browser" ], "Title": "Detecting supported browsers in ASP.NET ...
266201
<p>I created a watchdog/notifier in C++ and wanted to make it better so it could be used by multiple people. The idea is that there is a timer class and event. client create events and pass a lambda function, timeout in seconds and repeat mode i.e. whether to keep the event active after a timeout or deactivate once the...
[]
[ { "body": "<h1>Move <code>Event</code> and <code>TimeEvent</code> inside <code>class Timer</code></h1>\n<p>These types are just implementation details of your <code>Timer</code> class, and are not part of the public API. So by moving them into <code>class Timer</code>, you avoid polluting the global namespace. ...
{ "AcceptedAnswerId": "266212", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-19T12:07:02.103", "Id": "266202", "Score": "2", "Tags": [ "c++11", "timer" ], "Title": "watchdog for c++11" }
266202
<p><em>This is my very first time here, I am coming from stackoverflow.com thanks to @r2evans. So I apologize in advance if I don't follow all the rules.</em></p> <p>I wrote a code in <code>data.table</code>, doing what I am expected of it. It is not so complicated : mainly sum, group by, or some basic calculations.</p...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-19T13:33:08.263", "Id": "266204", "Score": "1", "Tags": [ "r" ], "Title": "Combine several calculations on several variables" }
266204
<p>A newbie here. I have done this assignment that my university gave.</p> <p><strong>Requirements</strong></p> <ul> <li><p>Participants may enter the tournament as individuals or as part of a team**</p> </li> <li><p>It is expected that will be 4 teams each with 5 members and there will be 20 spaces for individual comp...
[]
[ { "body": "<p>Java is an object-oriented language. If I were teaching a Java course and marking an assignment, one of the things I'd be looking at would be whether the student has applied object-oriented principles to their program.</p>\n<p>As it's written, your code is entirely procedural with all the program ...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-19T14:35:37.950", "Id": "266206", "Score": "1", "Tags": [ "java", "beginner" ], "Title": "Scoring system for events" }
266206
<p>I am using below code which is comparing three columns values and copy pasting the 4th column data into other column.</p> <p>My code is working fine but it is slow to perform the processing and takes much time and sometimes Not Responding window appears.</p> <p>Any help to fix the problem will be appreciated</p> <pr...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-20T04:58:15.670", "Id": "525915", "Score": "0", "body": "What's the size of data?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-20T05:32:36.053", "Id": "525917", "Score": "0", "body": "Its mor...
[ { "body": "<h3>Indents</h3>\n<p>Always keep the code properly indented. You'll spend much more time fixing some stupid error caused by improperly indented code then you'll save on not indenting it.\nThis code looks like the only line in <code>For i</code> loop is <code>a = ws.Cells(i, 14).Value</code>, but in f...
{ "AcceptedAnswerId": "268397", "CommentCount": "5", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-19T14:41:50.997", "Id": "266207", "Score": "3", "Tags": [ "performance", "vba", "excel" ], "Title": "Comparing Three Columns and Copy Pasting data" }
266207
<p>I am currently using a <code>ThreadedConnectionPool</code> from <code>psycopg2</code> to lease transactions to a PostgreSQL database and would like a review of my current implementation.</p> <h3>Code</h3> <pre class="lang-py prettyprint-override"><code>from __future__ import annotations import logging import thread...
[]
[ { "body": "<ul>\n<li><code>Counter</code> should not inherit from <code>object</code> in Python 3</li>\n<li>Add PEP484 type-hinting to <code>name</code>, as well as all of your return values</li>\n<li>I'm not sure what you were hoping to accomplish with a field width of 2 in <code>{id(self):#02x}</code>. IDs wi...
{ "AcceptedAnswerId": "266221", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-19T14:44:52.240", "Id": "266209", "Score": "1", "Tags": [ "python", "python-3.x" ], "Title": "psycopg2 ThreadedConnectionPool implementation" }
266209
<p>I am trying to solve a challenge in which I have to write a function that takes in two numbers as arguments and returns an array containing numbers between them which are prime and their reverse is also prime in JavaScript. This doesn't return numbers which are palindrome such as <code>101</code>.</p> <pre class="la...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-20T15:21:16.733", "Id": "525964", "Score": "0", "body": "Just for fun: https://stackblitz.com/edit/js-3olwhn?file=index.js" } ]
[ { "body": "<blockquote>\n<pre><code> let arr = [];\n</code></pre>\n</blockquote>\n<p>This isn't a generic array, so why not name it <code>primes</code>?</p>\n<blockquote>\n<pre><code> for (let i = start; i &lt;= stop; i++) {\n</code></pre>\n</blockquote>\n<p>Why are you incrementing by one here? There is...
{ "AcceptedAnswerId": "266223", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-19T16:20:43.443", "Id": "266211", "Score": "1", "Tags": [ "javascript", "node.js", "time-limit-exceeded", "primes" ], "Title": "A function to find all the primes between two ...
266211
<p>There are 2 persons and their already booked meeting schedule is given and also time bound for both the person is given. Now, we want to schedule a meeting between them in an available time that suits both of them. And at the end we want to return the available time slots for the new meeting. Given input:</p> <pre><...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-20T13:07:40.107", "Id": "525952", "Score": "0", "body": "@Edward I have made some changes in the code and i guess it works fine now. I have tried to run it in several test cases and its giving the output." }, { "ContentLicense"...
[ { "body": "<p>I see a number of things which may help you improve your program.</p>\n<h2>Don't abuse <code>using namespace std</code></h2>\n<p>Putting <code>using namespace std</code> at the top of every program is <a href=\"http://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-pr...
{ "AcceptedAnswerId": null, "CommentCount": "5", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-19T17:55:00.093", "Id": "266215", "Score": "5", "Tags": [ "c++", "strings", "vectors" ], "Title": "Algo to return a vector of available time slots for scheduling a meeting between tw...
266215
<p>I created a function that returns the next prime number greater or equal to the number given as an argument. My code works well, but I find it is very slow.</p> <p>The test suite take almost 60s and I want less than 10s. Can the code be optimised to achieve this?</p> <h1>Code</h1> <pre><code>#include &lt;stdio.h&gt...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-20T15:03:21.923", "Id": "525961", "Score": "2", "body": "I'm not well known in the C language, but that `main` method looks like it should be made into real automated tests, instead of a long `main`." }, { "ContentLicense": "CC...
[ { "body": "<p>You was calling <code>ft_is_prime</code> function two times, try:</p>\n<pre><code>int ft_is_prime(int nb)\n{\n int i;\n\n // Validate arguments.\n if (nb &lt;= 1)\n return 0;\n\n for (i = nb - 1; i &gt; 1; --i) {\n if (nb % i == 0)\n return (0);\n }\n ret...
{ "AcceptedAnswerId": "266251", "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-19T18:10:12.727", "Id": "266216", "Score": "0", "Tags": [ "performance", "c" ], "Title": "Find the next prime at/after a given integer" }
266216
<p>I'm looking to rework and make it easier to read this handleFilterChange function</p> <p>This is helper being used in the function</p> <pre><code> const getTestableValue = (val: any) =&gt; val?.toString().trim(); </code></pre> <p>Sample for the filter value</p> <pre><code>{ &quot;clock.props.children&quot;: [],...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-19T22:54:01.157", "Id": "525904", "Score": "1", "body": "Is this TS or JS? I only see two typings here, both of which are `any` so if it's TS you seem to be vastly underutilizing the tool. I recommend explaining why. Beyond that, I'm n...
[]
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-19T18:45:42.813", "Id": "266219", "Score": "0", "Tags": [ "javascript", "algorithm", "programming-challenge", "functional-programming", "typescript" ], "Title": "Refactor Jav...
266219
<p>I have this code to go from an array of bytes (arbitrarily long) to a &quot;bigint&quot; string (really, an arbitrarily long string composed of integers 0-9), and go from that long integer string into an array of bytes.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="fals...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-19T21:52:34.407", "Id": "525900", "Score": "3", "body": "Do you have other test cases that need to pass, or some general constraint on how this needs to work? These functions look to me like they're doing something odd (not just a plai...
[]
{ "AcceptedAnswerId": null, "CommentCount": "4", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-19T21:07:42.433", "Id": "266222", "Score": "3", "Tags": [ "javascript", "performance", "mathematics", "bigint" ], "Title": "converting from byte arrays to strings of integers, an...
266222
<p>I have a Python script that runs as a service, like this:</p> <pre class="lang-py prettyprint-override"><code>import time import traceback while True: time.sleep(60) try: main() except Exception: # Print the traceback, but keep running traceback.print_exc() </code></pre> <p>This...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-20T12:12:09.123", "Id": "525947", "Score": "0", "body": "I get an error when running your code `NameError: name 'main' is not defined` before the expected messages `main() is already running - couldn't lock it` appear. I think your cod...
[ { "body": "<p>Your basic code looks fine, but you may encounter one issue if you start doing more complex work.</p>\n<p>Signals are handled in a different context to the context your program is normally executing in - the OS can suspend your program at any time, while it's running or not, to run a signal handle...
{ "AcceptedAnswerId": "266225", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-19T22:58:39.433", "Id": "266224", "Score": "2", "Tags": [ "python", "python-3.x" ], "Title": "Python Service with USR1 kill signal handler" }
266224
<p>I've put together this script to check through various location and pick the next media file to play on an internet radio station:</p> <pre><code>#!/bin/sh dir=/ezstream # processing function play_next() { location=$1 used=$2 last=$3 # check for media available=$(ls -1 $location) if [ -z &quot;$availa...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-20T03:20:28.033", "Id": "266226", "Score": "0", "Tags": [ "linux", "shell" ], "Title": "Where and how can I speed up this config-driven ezstream script?" }
266226
<p>I wrote a program that syncs the lyric of an MP3 song and displays the text as a subtitle when playing the song, but my code for this is too Unprofessional and weak. Is there a way to display it more professionally?<br /> I tried this:</p> <pre><code>Private Sub Button5_Click(sender As Object, e As EventArgs) Handle...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-20T05:14:55.787", "Id": "266228", "Score": "1", "Tags": [ "vb.net" ], "Title": "Showing synced lyrics of mp3 music in vb.net" }
266228
<p>The two list have different structure. The list originalPgs is a list of <code>PGRatingConfig</code> and has this structure:</p> <pre><code>class PGRatingConfig { .... Rating rating; } class Rating { String pgId; String value; } </code></pre> <p>pgLookupTable returns List which is of the form: id and name ...
[]
[ { "body": "<p>For starters you should stop putting stream operations on a single line. They should be formatted so that each stream operation is on their own line. It makes following the code much easier:</p>\n<pre><code>if (! rating.getRating()\n .stream()\n .map(r-&gt;r.getPgId())\n .collect(Collecto...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-20T05:42:00.690", "Id": "266229", "Score": "1", "Tags": [ "java" ], "Title": "Merge in list from another list that are not present in the former list" }
266229
<p>This is my code:</p> <pre><code>from database_function import * from kiteconnect import KiteTicker import pandas as pd from datetime import datetime, timedelta import schedule import time from multiprocessing import Process def tick_A(): #credentials code here tokens = [x[0] for x in db_fetchquery(&quot...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-20T23:00:39.037", "Id": "525969", "Score": "0", "body": "A thing to consider is that threads in CPython are limited by the GIL. Multithreading with the standard implementation is best used only for I/O-heavy uses. For database manipula...
[ { "body": "<p>Yes, in general threads are lighter than process, they consume less memory and less resources. However, you need to measure this in your use case(program or system) and see what works for you. If your program wants to share the same memory space use threads, but bear in mind that you will need to ...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-20T06:21:06.310", "Id": "266230", "Score": "2", "Tags": [ "python", "performance", "python-3.x", "multithreading", "multiprocessing" ], "Title": "Multithread or multiprocess"...
266230
<p>Here is my attempt to output webscraping results to a <code>bibtex</code> file.</p> <p>I would like to use this format as input to the <a href="https://www.zotero.org" rel="nofollow noreferrer">Zotero</a> database.</p> <p>As <a href="https://retorque.re/zotero-better-bibtex/" rel="nofollow noreferrer">BetterBibtex</...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-18T15:32:06.960", "Id": "528699", "Score": "0", "body": "This doesn't load? I get `bad gateway` for the website." }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-19T02:08:03.533", "Id": "528721", "Sc...
[ { "body": "<blockquote>\n<p>The code should be working fine now</p>\n</blockquote>\n<p>It doesn't; the site dies with a 503. Anyway:</p>\n<ul>\n<li><code>articles: Iterable</code> should specify what it's an iterable of</li>\n<li>don't accept a free string for <code>output_format</code>; use an <code>Enum</code...
{ "AcceptedAnswerId": "268157", "CommentCount": "6", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-20T09:53:37.340", "Id": "266236", "Score": "2", "Tags": [ "python", "web-scraping" ], "Title": "Output webscraping results to BibTex file" }
266236
<p>I'm really new to code optimization and JS. I would like to ask for help on optimizing my code. Thank you in advance.</p> <p>Here is my code:</p> <pre><code>if(entity_param_connections_products == &quot;PL&quot;) {       if(pl_flex_l1_label === &quot;&quot;){         document.getElementById(&quot;credit_app-flex_l1&...
[]
[ { "body": "<p>You can use functions and ternary operator logic here to reduce a lot of line and to make it more clear.</p>\n<p>For example</p>\n<pre class=\"lang-js prettyprint-override\"><code>if(pl_flex_t1_label === &quot;&quot;){\n document.getElementById(&quot;credit_app-flex_t1&quot;).style.displa...
{ "AcceptedAnswerId": "266244", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-20T14:12:19.770", "Id": "266240", "Score": "5", "Tags": [ "javascript", "performance", "nested" ], "Title": "Refactor JavaScript nested if-else" }
266240
<p>While working on my demo <a href="https://pchemguy.github.io/ContactEditor/" rel="nofollow noreferrer">database manager app</a>, I have coded a <a href="https://codereview.stackexchange.com/questions/266172/contacteditor-excel-vba-db-app-storage-library">previously presented</a> Storage Library. The structure of the...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-20T16:36:40.023", "Id": "266245", "Score": "1", "Tags": [ "object-oriented", "design-patterns", "vba" ], "Title": "VBA OOP design patterns: factory, constructor, returned interface" ...
266245
<p><a href="https://www.spoj.com/problems/UPDATEIT/" rel="nofollow noreferrer">UPDATEIT on SPOJ</a>:</p> <blockquote> <h5>UPDATEIT - Update the array !</h5> <p><a href="https://www.spoj.com/problems/tag/bitmasks" rel="nofollow noreferrer">#bitmasks</a><br /> You have an array containing n elements initially all 0. You ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-21T07:25:22.370", "Id": "525975", "Score": "0", "body": "Welcome to Code Review@SE. One advice I give and try to follow: code the way you think about a problem. One observation about problems on platforms like SPOJ: the time limits are...
[]
{ "AcceptedAnswerId": null, "CommentCount": "4", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-20T17:08:23.513", "Id": "266247", "Score": "0", "Tags": [ "python", "time-limit-exceeded", "bitwise" ], "Title": "UPDATEIT SPOJ problem using Segment tree" }
266247
<p>I am formatting my TV series archive and can not do one by one. I wrote this code and it's working like what I want. I am a beginner and want to improve my knowledge of algorithm. What can you recommend me? Have a nice day to everyone.</p> <p><strong>Variables</strong></p> <ul> <li>inputStr is contains file name.</l...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-21T09:32:44.723", "Id": "525983", "Score": "1", "body": "Welcome to Code Review@SE. What does `I [am doing something] and can not do one by one` mean?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-22T14:3...
[ { "body": "<blockquote>\n<p>What can you recommend me?</p>\n</blockquote>\n<p>The code you have is quite good already, but the most important thing you can do to improve it is to make use of standard library algorithms.</p>\n<p>These days, it is considered bad practice to write <code>for</code> loops. It probab...
{ "AcceptedAnswerId": "266255", "CommentCount": "4", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-20T17:14:08.123", "Id": "266249", "Score": "1", "Tags": [ "c++", "strings", "file-system" ], "Title": "Replacing a char in the file name" }
266249
<p>I have written a python script that generates random rows with a provided array. To better explain</p> <pre><code>input : [1,2,3,4,5] output : [1,2,3,4,5] [5,3,4,2,1] [1,2,4,5,3] [1,2,5,3,4] [5,4,3,2,1] [4,3,2,1,5] </code></pre> <p>I am sharing the function which generates the unique random placement of item in arra...
[]
[ { "body": "<h2>Performance</h2>\n<p>Since <a href=\"https://stackoverflow.com/q/38722105/9997212\">f-strings are faster than string concatenation</a>, you can replace</p>\n<pre class=\"lang-py prettyprint-override\"><code>score_string = score_string + ',' + str(score_array.pop(i))\n</code></pre>\n<p>with</p>\n<...
{ "AcceptedAnswerId": "266257", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-20T17:41:40.307", "Id": "266250", "Score": "1", "Tags": [ "python-3.x" ], "Title": "create script to convert array to string with array elements uniquely with randomness" }
266250
<p>I recently wrote code to parse lambda expressions written in a lisp like format, using a small hand-rolled parsing library.</p> <h2>The goal</h2> <p>This code was written as a part of <a href="https://codegolf.stackexchange.com/questions/233453/parse-a-lambda-for-correctness">this code-golf challenge</a> not as code...
[]
[ { "body": "<p>Sorry I'm so late to this!</p>\n<blockquote>\n<ul>\n<li>Is <code>do</code> notation a good choice given my goals?</li>\n</ul>\n</blockquote>\n<p>Sure. Anyone who knows monads will understand <code>do</code>. On the other hand, don't assume everyone knows monadic <em>parsers</em>. A simple <a href=...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-20T18:16:11.283", "Id": "266252", "Score": "4", "Tags": [ "parsing", "haskell", "functional-programming" ], "Title": "Small combinator parsing library in Haskell" }
266252
<p>I want to see if I can find a way to have the system work the same way when it runs, but condense it, as if I don't I will be constantly writing a lot of code that I believe I could just write in a more simple and condensed way.</p> <p>Is there a way to simplify and condense this code?</p> <pre><code>import random a...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-20T20:19:34.850", "Id": "525967", "Score": "5", "body": "Welcome to CodeReview. Your title is a little too broad and applicable to everything on this site. The standard is to have the title describe what your code is trying to do. F...
[ { "body": "<h1>PEP 8</h1>\n<p>The <a href=\"https://pep8.org/\" rel=\"noreferrer\">Style Guide for Python Code</a> enumerates a number of rules you should follow.</p>\n<p>Of particular note: variables should be in <code>snake_case</code>, not <code>mixedCase</code>. Therefore, <code>aList</code> should be <cod...
{ "AcceptedAnswerId": null, "CommentCount": "4", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-20T19:53:33.000", "Id": "266253", "Score": "1", "Tags": [ "python", "beginner", "python-3.x" ], "Title": "Select 3 items from list, print different messages based on selection order"...
266253
<p>I finally got this lexer working. How can the <code>parse</code> function be simplified? The goal is to take a tree of indentation-based text, and convert it into parentheses-based opening/closing text, for easier parsing down the road. But the logic is pretty messy and I'm not sure how to make it elegant.</p> <p><d...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-21T07:28:17.867", "Id": "266258", "Score": "2", "Tags": [ "javascript", "parsing", "lexer" ], "Title": "How could this indentation-based lexer be simplified?" }
266258
<p>I am looking for feedback on the function below to load a png image stored as bytes from a MongoDB into numpy arrays.</p> <pre><code>from PIL import Image import numpy as np def bytes_to_matricies(image_bytes): &quot;&quot;&quot;image bytes into Pillow image object image_bytes: image bytes accessed from Mo...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-21T18:00:11.433", "Id": "526015", "Score": "0", "body": "What is the nature of your input image - size in DB, pixel dimensions, content? Is it something like a graph (lots of continuous colour regions) or a photograph? What is the reas...
[]
{ "AcceptedAnswerId": null, "CommentCount": "5", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-21T12:33:42.893", "Id": "266261", "Score": "2", "Tags": [ "python", "numpy", "image" ], "Title": "Python loading image into memory (numpy arrays) from database bytes field fast" }
266261
<p>I am searching for a more efficient way to calculate the so called <strong>vec-trick</strong> used in Tensor algebra, see <a href="https://en.wikipedia.org/wiki/Kronecker_product#Matrix_equations" rel="nofollow noreferrer">Wikipedia</a>.</p> <hr /> <p><strong>Introduction:</strong></p> <p>Suppose you have a matrix v...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-21T16:57:59.277", "Id": "526011", "Score": "0", "body": "You’re using a .cpp extension, which `mex` interprets as C++ code, but setting C compile flags. I would suggest you start by ensuring you are using an optimized build." }, { ...
[ { "body": "<p>I compiled your MEX-file using just <code>mex tensorproduct.c</code> (no OpenMP, no special optimization flags, nothing). Then I compared running time to the &quot;expensive&quot; variant:</p>\n<pre class=\"lang-matlab prettyprint-override\"><code>n = 7;\nm = 7;\np = 7;\nq = 7;\nA = rand(n, m);\nB...
{ "AcceptedAnswerId": "266399", "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-21T12:48:00.847", "Id": "266262", "Score": "3", "Tags": [ "performance", "c", "matlab", "vectorization" ], "Title": "Matlab vs C: Tensorproduct or Vec-trick (multiple times)"...
266262
<p>Hi there I was hoping to get a better grasp of greddy algorithms while trying to solve this problem: <a href="https://codereview.stackexchange.com/questions/156887/hackerrank-gridland-metro">Hackerrank: Gridland Metro</a> and I was trying to apply an algorithm where each grid could be considered a point, and each tr...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-21T14:36:55.480", "Id": "526002", "Score": "0", "body": "Welcome to the Code Review Community, unlike Stack Overflow the more code we see the better review you will get. While reducing code for clarity on Stack Overflow is good, it is ...
[ { "body": "<p>Took me some time - but it had to do with how large the Integers were being handled. I refactored the code to instead count consecutive non-railway cells, rather count the number of cells which had a track in them (using the interval merge method). I further had to break it down row by row to hand...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-21T14:17:41.083", "Id": "266263", "Score": "0", "Tags": [ "javascript", "algorithm", "interview-questions", "interval" ], "Title": "Hackerrank Gridland Metro - using Interval Cov...
266263
<p>This program reads raw pixels from the pipe/stdin in a loop and set the root window background.</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;string.h&gt; #include &lt;X11/Xatom.h&gt; #include &lt;X11/Xlib.h&gt; #include &lt;X11/Xutil.h&gt; int main(int argc, char **argv) { Disp...
[]
[ { "body": "<h1>Complexity</h1>\n<p>The function <code>main()</code> is too complex (does too much). As programs grow in size the use of <code>main()</code> should be limited to calling functions that parse the command line, calling functions that set up for processing, calling functions that execute the desired...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-21T14:18:53.607", "Id": "266264", "Score": "1", "Tags": [ "performance", "c", "error-handling" ], "Title": "Setting Wallpaper with Xlib and ImageMagick cli" }
266264
<p>I though of defining the following module that I could use to govern the dark mode on/off on a website.</p> <p>Probably I would use it only for that in the whole page, but in the case I don't (i.e. I end up wanting to use it in other places), I'd like to be sure it's reusable enough.</p> <p>I tried to make it geomet...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-21T16:21:33.437", "Id": "266267", "Score": "1", "Tags": [ "html", "css", "gui" ], "Title": "Reusable/extensible deisgn of toggle to be used for switching dark mode on/off" }
266267
<p>I made a simple password generator (once again).</p> <pre><code>import random import string import pyperclip class Password: def __init__(self, length, contains_lowercase, contains_uppercase, contains_digits, contains_symbols): self.length = length self.contains_lowercase = contains_lowercase ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-21T17:12:49.903", "Id": "526012", "Score": "0", "body": "I presume your previous attempt is here: https://codereview.stackexchange.com/questions/249921/password-generator-crapcode" }, { "ContentLicense": "CC BY-SA 4.0", "Cr...
[ { "body": "<h2>Complexity</h2>\n<p>First: enforcing specific requirements around character types in an attempt to promote password complexity is outdated and shown to do <a href=\"https://en.wikipedia.org/wiki/Password_strength#Guidelines_for_strong_passwords\" rel=\"nofollow noreferrer\">more harm than help</a...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-21T16:52:03.960", "Id": "266268", "Score": "2", "Tags": [ "python", "python-3.x" ], "Title": "Password generator - different solutions" }
266268
<p>I'm learning <strong>react-typescript</strong> programming.<br /> Developed a sample application, which supports in multi language.</p> <p>github Souce: <a href="https://github.com/phanivaranasi/sownikbackend.git" rel="nofollow noreferrer">https://github.com/phanivaranasi/sownikbackend.git</a><br /> Review the code ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-01T15:38:17.770", "Id": "526699", "Score": "0", "body": "It would benefit reviewers to have a bit more information about the code in the description. From [the help center page _How to ask_](https://codereview.stackexchange.com/help/ho...
[]
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-21T17:56:26.123", "Id": "266272", "Score": "0", "Tags": [ "beginner", "react.js", "typescript", "redux" ], "Title": "Multilingual React Application using typescript" }
266272
<p>I wanted to share actions through different places in the component tree like:</p> <pre class="lang-javascript prettyprint-override"><code>// in one component, listen an action useListener(&quot;DELETE&quot;, (payload) =&gt; { console.log(&quot;DELETE EVENT 1&quot;, payload); }); // in another component, dispat...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-21T19:59:44.017", "Id": "266275", "Score": "1", "Tags": [ "react.js" ], "Title": "Dispatch and Listen Action with Hooks in React (without Redux)" }
266275
<p>I have been working on a very simple code where I am I open a given file file which has a format of:</p> <p><strong>proxies.txt</strong></p> <pre><code>hello:12345 hello:12345:apple:orange test:4125 test:53953:hello:world myserver:1337:usertest:passwordtest </code></pre> <p>what I want to do with these lines is that...
[]
[ { "body": "<h1>Proxy manager to return proxy format</h1>\n<h2>Good points</h2>\n<p>The task of your code is very simple, with main good points:</p>\n<ul>\n<li><p>Using of the <code>typing</code> module</p>\n</li>\n<li><p>Using static methods</p>\n</li>\n<li><p>Using <code>with</code>-statement to operate on a f...
{ "AcceptedAnswerId": "266293", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-21T20:47:48.040", "Id": "266276", "Score": "0", "Tags": [ "python-3.x" ], "Title": "Proxy manager to return proxy format" }
266276
<p>So I'm staying up for 24 hours watching <a href="https://en.wikipedia.org/wiki/24_Hours_of_Le_Mans" rel="nofollow noreferrer">Le Mans</a> and decided to write something fun.</p> <p>I wrote an implementation of Conway's Game of Life (information <a href="https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life" rel="nof...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-22T03:11:43.637", "Id": "526024", "Score": "1", "body": "Your `updateBoard` function is wrong. That's not the way Conway's Game of Life is supposed to behave. You're updating the same board, which is causing problems because the neighb...
[]
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-22T00:44:15.763", "Id": "266280", "Score": "0", "Tags": [ "javascript", "game", "html5", "game-of-life" ], "Title": "Conway's Game of Life written in JavaScript" }
266280
<p>If the log file is not available, then output the log message to the console. Any improvement or suggestion for this implementation for the logger by the template? Any potiencial problem that I should be aware of?</p> <pre><code>#ifndef _LOGGER_HEADER__ #define _LOGGER_HEADER__ #include &lt;iostream&gt; #include &lt...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-24T15:43:20.250", "Id": "526174", "Score": "0", "body": "Can you use [source_location](https://en.cppreference.com/w/cpp/header/source_location) instead of Macros?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "20...
[ { "body": "<ul>\n<li>Having a bunch of global variables grouped by the virtue of spacing in the source file is very rarely a good idea. What you have here is a class in principle (a bunch of data plus methods), not using the class syntax for that is strange.</li>\n<li>Since it is not a class ,there is no notion...
{ "AcceptedAnswerId": "266384", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-22T02:58:12.980", "Id": "266282", "Score": "2", "Tags": [ "c++", "template", "logging" ], "Title": "C++ logger by template" }
266282
<p>Here's my C++ solution for PE 43:</p> <pre class="lang-cpp prettyprint-override"><code>#include &lt;algorithm&gt; #include &lt;iostream&gt; #include &lt;string&gt; int main() { const int PRIMES[] {2, 3, 5, 7, 11, 13, 17}; std::string digits = &quot;0123456789&quot;; unsigned long long sum = 0; do {...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-22T07:30:36.703", "Id": "526032", "Score": "1", "body": "Code looks good. I will suggest minor two changes First, Avoiding use of stol by using number array rather than string type for digits, second use of divisibility rules rather t...
[ { "body": "<p>The choice of algorithm seems good, and <code>std::next_permutation()</code> was exactly how I would implement the search.</p>\n<hr />\n<h1>Style review</h1>\n<p>We could separate the loop from the test for the divisibility property:</p>\n<pre><code>static bool has_euler43_property(const std::stri...
{ "AcceptedAnswerId": "266320", "CommentCount": "5", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-22T03:20:22.877", "Id": "266283", "Score": "3", "Tags": [ "c++", "programming-challenge" ], "Title": "Project Euler #43 (C++)" }
266283
<p>I want to scrape 25000 addresses using Column A cell values as search strings. I'm using the following code, it is working fine but it's too slow to extract 25000 results. Is there any way to speed up the process, like opening multiple addresses at once or something else? I'm pretty new to VBA coding. Any help would...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-22T08:13:05.843", "Id": "526034", "Score": "1", "body": "Since you don't need to interact with the web page - click on things, scroll etc. you don't need to load a full web browser just to grab the html content. A much faster method wo...
[]
{ "AcceptedAnswerId": null, "CommentCount": "4", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-22T07:50:20.577", "Id": "266286", "Score": "2", "Tags": [ "beginner", "vba", "excel", "time-limit-exceeded", "web-scraping" ], "Title": "How to speed up the VBA scraping proc...
266286
<p>I'm new in Ada and made the following Tic Tac Toe implementation. It works as intended.</p> <h2>tictactoe.gpr</h2> <pre><code>project TicTacToe is for Source_Dirs use (&quot;src/**&quot;); for Object_Dir use &quot;obj&quot;; for Exec_Dir use &quot;.&quot;; for Main use (&quot;main.adb&quot;); f...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-22T09:36:49.307", "Id": "266287", "Score": "3", "Tags": [ "beginner", "ada" ], "Title": "Tic Tac Toe in Ada" }
266287
<p>I am asked to implement the following part of code into kernel code. Actually, I have tried but not sure about the <code>std::array</code>.</p> <p>This is the original code for the function.</p> <pre><code>int KNN_classifier(array&lt;array&lt;int, 20&gt;, 4344&gt;&amp; array_X_train, array&lt;int, 4344&gt;&amp; arra...
[]
[ { "body": "<h2>Review</h2>\n<p>Welcome to Code Review. There are some suggestions as follows.</p>\n<h3>Const Definition</h3>\n<p>You already define the value <code>N1</code> and <code>N2</code>, why not use that in the array template parameter directly (e.g. <code>array&lt;float, N1&gt;</code>)? Actually, not s...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-22T09:38:26.850", "Id": "266288", "Score": "0", "Tags": [ "array", "kernel", "opencl" ], "Title": "Implement 2D and 1D std::array in opencl kernel" }
266288
<p>Consider my following code from the <a href="https://www.codewars.com/kata/556deca17c58da83c00002db/train/javascript" rel="nofollow noreferrer">Tribonacci sequence kata</a>.</p> <pre class="lang-javascript prettyprint-override"><code>function tribonacci(signature,n){ if(!n) return []; const sequence = signature;...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-22T14:48:29.090", "Id": "526045", "Score": "1", "body": "A quick check with the Kata shows that the failing case is this one:\n`tribonacci([1,1,1],1)`. If you look carefully in your code you do not handle the case when `sequence.length...
[]
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-22T10:41:43.733", "Id": "266290", "Score": "0", "Tags": [ "javascript", "node.js", "memory-optimization" ], "Title": "Memory Allocation problem in codewars: Improvements to use less ...
266290
<p>This is an implementation of a &quot;string to int&quot; hash table with <a href="https://en.wikipedia.org/wiki/Hash_table#Robin_Hood_hashing" rel="nofollow noreferrer">Robin Hood hashing</a>. I have tested it as thoroughly as I could. It appears to have no bugs/leaks. I would appreciate any comments on correctness/...
[]
[ { "body": "<p><strong>Hashing Weakness</strong></p>\n<p>If <code>initial_buffer_size</code> is a power-of-2, the index becomes nothing more than a mask of the lower bits of the hash as in <code>% map-&gt;buffer_size</code>. When hash is weak, using only a few bits results in poor overall hashing. When <code>....
{ "AcceptedAnswerId": "266295", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-22T11:27:37.697", "Id": "266291", "Score": "2", "Tags": [ "c", "hash-map", "c89" ], "Title": "Robin Hood hashing" }
266291
<p><strong>Problem statement:</strong> Write a function which checks if two triangles intersect or not. Complete containment or tangential contact is not considered intersection.</p> <p><strong>Approach:</strong> I have considered each triangle as collection of three line segments. And then checked if any of the line s...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-22T11:54:25.190", "Id": "526037", "Score": "0", "body": "\"Complete containment or tangential contact is not considered intersection.\" What if it shares an edge, is touching on point intersecting? Do you have more testcases which you ...
[ { "body": "<p>Your code looks mostly good to me. Here are a few comments</p>\n<p><strong>Style details</strong></p>\n<ul>\n<li>Invisible details but there are a few trailing whitespaces that should be cleaned up</li>\n<li>Probably a matter of personal preference but I think that ordinal (&quot;first&quot;, &quo...
{ "AcceptedAnswerId": "266323", "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-22T11:32:11.157", "Id": "266292", "Score": "1", "Tags": [ "python", "computational-geometry" ], "Title": "Check if two triangles intersect" }
266292
<p><strong>Problem statement:</strong> Assume a high resolution (&gt; 3000 x 3000) image is given as input. The image pixels can be classified into one of the three categories namely text, background and drawing. There is library function which takes a pixel and returns its category. Write a function which takes high r...
[]
[ { "body": "<p>To vectorize code like this we need to know what <code>is_drawing_pixel</code> and <code>is_text_pixel</code> do. Can these be called with many pixels as input? If they need to be called for a single pixel, then there is no way to vectorize this, because you must call the two functions for each pi...
{ "AcceptedAnswerId": "266390", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-22T13:02:28.283", "Id": "266294", "Score": "1", "Tags": [ "python", "performance", "image", "opencv" ], "Title": "Update image pixels based on different criteria" }
266294
<p>I made tic-tac-toe (a common practice).</p> <p><strong>board_and_player.py</strong></p> <pre><code>class Board: def __init__(self): self.cells = {&quot;top_l&quot;: ' ', &quot;top_m&quot;: ' ', &quot;top_r&quot;: ' ', &quot;mid_l&quot;: ' ', &quot;mid_m&quot;: ' ', &quot;mid_r&quot;:...
[]
[ { "body": "<h3>Game Board Data Structure Representation</h3>\n<p>Using a dictionary for the board's cells is a little awkward, as you probably realized, particularly in this line:</p>\n<pre><code>board.cells[ list(board.cells.keys())[int(choice_cell_index) - 1] ] = self.symbol\n</code></pre>\n<p>You really want...
{ "AcceptedAnswerId": "266328", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-22T20:13:03.367", "Id": "266297", "Score": "2", "Tags": [ "python", "python-3.x" ], "Title": "tic-tac-toe - alternative ways to make a board, logical and phyiscal lines" }
266297
<p>I'm looking for critiques or different ways I could approach writing a deck builder script. I wrote script to shuffle a deck of cards, then draw cards from the top of deck, drawn cards are then removed from deck and placed into discard.</p> <pre><code>const cardGame = { values: [ 'Ace', 2, 3, 4, 5, 6, 7, 8, 9, 10, '...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-22T21:48:11.447", "Id": "526055", "Score": "2", "body": "Take this question to StackOverflow and with the code working, bring it back here to Code Review. Situations like this is why there are separate forums." }, { "ContentLi...
[]
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-22T20:31:10.157", "Id": "266299", "Score": "0", "Tags": [ "javascript" ], "Title": "JavaScript Deck Builder: Shuffle, Draw Cards" }
266299
<p><strong>Desired output:</strong> Animate the wave forms, but use less resources.</p> <p><strong>Any bugs:</strong> There are no bugs that I know of.</p> <p>I tied searching google for &quot;use less setIntervals in my project&quot; and <a href="https://www.thecodeship.com/web-development/alternative-to-javascript-ev...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-29T07:26:00.050", "Id": "526491", "Score": "1", "body": "[Posting a follow-up](https://codereview.meta.stackexchange.com/q/1065/71574). [What you can and cannot do after receiving answers](https://codereview.meta.stackexchange.com/a/1...
[ { "body": "<h2>CSS Animation</h2>\n<p>Complex CSS animation suffers from a performance problem as it is a general-purpose solution to what often is a very optimization-focused problem.</p>\n<p>You have 100 animated elements. From CSS's view point each element represents a separate uncoordinated animation, each ...
{ "AcceptedAnswerId": "266339", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-22T20:43:03.760", "Id": "266300", "Score": "2", "Tags": [ "javascript", "css" ], "Title": "Create random wave forms using JavaScript and CSS" }
266300
<p>I have previously got a review of something similar (but not the same but its related to proxies) which can be found via: <a href="https://codereview.stackexchange.com/questions/266276/proxy-manager-to-return-proxy-format/266296#266296">proxy-manager-to-return-proxy-format</a></p> <p>What I am now trying to do is th...
[]
[ { "body": "<h1>Availability of proxies</h1>\n<h2>Documentation</h2>\n<p>The <code>threading</code> name refers to the module, the <code>threading.Lock</code> name refers to a class inside that module. Thus, the type of <code>proxy_lock</code> is wrong, since it's an instance of <code>threading.Lock</code>. You ...
{ "AcceptedAnswerId": "266338", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-22T21:12:11.583", "Id": "266301", "Score": "3", "Tags": [ "python-3.x" ], "Title": "Availability of proxies" }
266301
<p>this is similar to another project I did here: <a href="https://codereview.stackexchange.com/questions/266299/javascript-deck-builder-shuffle-draw-cards">JavaScript Deck Builder: Shuffle, Draw Cards</a> Except this script does not shuffle or draw cards from the top of the deck. Instead the script builds a deck, then...
[]
[ { "body": "<h2>General points</h2>\n<ul>\n<li>To empty an array use the length property eg. Rather than use <code>deck.splice(0, 52);</code> use <code>deck.length = 0;</code></li>\n<li>You can simplify the card array and use a number 0 to 51 to represent a card. The card suit is the <code>this.suits[(value / 13...
{ "AcceptedAnswerId": "266307", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-22T21:56:08.657", "Id": "266303", "Score": "0", "Tags": [ "javascript" ], "Title": "JavaScript Deck Builder: Build Deck, Draw Random Card from Deck" }
266303
<p>I am trying to implement a priority-based timer where certain events are fired out based on their expiry and the priority.</p> <p>So if there are 3 timers with the following expiry time and priorities</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Timers</th> <th>Expiry Time (s)</th> <t...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-29T17:04:32.070", "Id": "526531", "Score": "0", "body": "Please do not edit the question, especially the code, after an answer has been posted. Changing the question may cause answer invalidation. Everyone needs to be able to see what ...
[ { "body": "<blockquote>\n<p>any corner cases that I forgot to take into account</p>\n</blockquote>\n<p><strong>No error handling</strong></p>\n<p>e.g.: <code>malloc()</code> may return <code>NULL</code>.</p>\n<hr />\n<blockquote>\n<p>any design approach that would work better.</p>\n</blockquote>\n<p><strong>Imp...
{ "AcceptedAnswerId": null, "CommentCount": "4", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-22T23:01:41.333", "Id": "266304", "Score": "5", "Tags": [ "c", "timer", "embedded", "scheduled-tasks", "pthreads" ], "Title": "A priority based timer using priority queue" }
266304
<p>The following script derives schemas from varied file formats. Can I get this reviewed? What would the improvements look like:</p> <pre><code> def _null_allowed_in_cols(self): for field in self.fields: field[&quot;type&quot;] = self._field_type_converter(field[&quot;type&quot;]) i...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-24T21:22:27.627", "Id": "526206", "Score": "2", "body": "Please do not update the code in your question to incorporate feedback from answers, doing so goes against the Question + Answer style of Code Review. This is not a forum where y...
[ { "body": "<h1><code>_col_type</code></h1>\n<p>You can use a generator expression here to return either the first match or <code>None</code>:</p>\n<pre class=\"lang-py prettyprint-override\"><code> # go from this\n def _col_type(self, column_name):\n for column in self.fields:\n if colum...
{ "AcceptedAnswerId": "266330", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-23T01:51:07.367", "Id": "266308", "Score": "0", "Tags": [ "python", "python-3.x", "json", "apache-kafka" ], "Title": "OOP Refactoring" }
266308
<p>This is an implementation of <a href="https://github.com/ajeetdsouza/zoxide" rel="nofollow noreferrer">zoxide</a> in C, it uses a shell alias to <code>cd</code> between directories it stores(as csv in form of &lt;count,path&gt;) or when the directory is invalid it searches for closest matching directories</p> <pre c...
[]
[ { "body": "<blockquote>\n<pre><code> if(data_home==NULL){perror(&quot;malloc() returned NULL&quot;);}\n strcpy(data_home, homedir);\n</code></pre>\n</blockquote>\n<p>So when <code>data_home</code> is null, we print an error message and then go on to use the null pointer anyway? That's UB.</p>\n<p>We do the s...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-23T03:51:00.100", "Id": "266309", "Score": "1", "Tags": [ "c" ], "Title": "Store all most used directories and query for most used directories containing a string" }
266309
<p>I have below code which is going to copy records from one container in cosmos db to another container in cosmos db. I am just worried on not following the best practices and below code might time out when querying the whole database to get only result with &quot;ClassID&quot;. I would appreciate any suggestion as wh...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-23T07:16:05.683", "Id": "526075", "Score": "1", "body": "Welcome to Stack Review, if you think it can be applied to your question you can add the tag `azure-cosmosdb` or another tag related to databases." }, { "ContentLicense":...
[ { "body": "<p>I'm not familiar with Azure Functions and CosmosDb, so I won't review your code from API consumption perspective.</p>\n<p>Here are my observations:</p>\n<ul>\n<li><code>FunctionNameAttribute</code>: Please prefer <a href=\"https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators...
{ "AcceptedAnswerId": "266324", "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-23T06:29:41.767", "Id": "266313", "Score": "4", "Tags": [ "c#", "azure-cosmosdb" ], "Title": "Enumerating my method to handle any time out issue" }
266313
<h3>description:</h3> <ul> <li>I'm using <code>thrift</code> to save and get data by filter.</li> <li>The data have many types, and the types may increase in the future. So I use <code>switch-case</code> to handle it in <code>save</code>, but it leads to a lot of duplicated code.</li> <li>Then when I wrote <code>getByF...
[]
[ { "body": "<p>Whenever Java code contains this sort of switch statement and large portions of nearly identical code, then it probably (almost certainly) indicates that you've got your object model wrong.</p>\n<p>I don't know anything about Thrift, so can't comment on that aspect, but I'd expect that a good star...
{ "AcceptedAnswerId": "266371", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-23T07:59:23.447", "Id": "266314", "Score": "0", "Tags": [ "java", "generics", "reflection" ], "Title": "How to save/get different type of data with less duplicated code" }
266314
<p>I am a student who wrote logic to theme switcher, but I don't know if everything is ok. I want professionals to estimate my code and will say what is probably mistaken. I accept all recommendations and criticism. Thank you in advance.</p> <p>gitHub: <a href="https://github.com/Alexander-Korniichuk/React_Theme_Switch...
[]
[ { "body": "<ul>\n<li>variable <code>key</code> can relate to anything. I'd just call this variable <code>theme</code></li>\n<li>I'd also avoid naming the function parameter <code>where</code></li>\n<li>If You are using an arrow function and it has one parameter then You can avoid adding <code>()</code> around i...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-23T09:53:40.993", "Id": "266318", "Score": "0", "Tags": [ "javascript", "react.js" ], "Title": "My Theme Switcher App has a need to be criticized" }
266318
<p>I am working on a Data-based application.</p> <p>I wrote a code to filter the table. The table has <code>String</code> and <code>Numbers</code>.</p> <p>I some filter for string, like min word count, max word count, string includes and excludes For Numbers, I also have filters like min, max.</p> <p>This is my code,</...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-24T02:59:18.787", "Id": "526124", "Score": "1", "body": "Thanks for your feedback, I update the question can you please further look at it?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-24T04:43:19.850", ...
[ { "body": "<p>Its seems like you have all the logic to filter the <code>rows</code> centralised, and the use the external <code>filters</code> array to decide which filters to apply. This makes your code kind of complex.</p>\n<p>Why not let each of the entries in <code>filters</code> be a function that takes a ...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-23T14:35:44.500", "Id": "266326", "Score": "2", "Tags": [ "javascript", "performance", "object-oriented", "array" ], "Title": "Complex Filter in one Opration" }
266326
<p>I originally posted this on SO, and I know cross-linking is generally frowned upon. But, I am not sure if this falls under question or code review because the code works where I do not know if it is implemented correctly. Anyways, here it is:</p> <p><a href="https://stackoverflow.com/questions/68868685/need-help-dem...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-23T17:55:11.023", "Id": "266332", "Score": "1", "Tags": [ "c#", "security", "authentication", "active-directory", "azure" ], "Title": "Verify implementing Microsoft Graph 4.0...
266332
<p>I wrote this method which I think is not effective as it doesn't respond to the missing method when I use the PORO Class.</p> <p><strong>BalanceService</strong></p> <pre><code>class BalanceService INITIAL_MULTIPLIER = 1 HUMUS_EFFECT = 1.3 instance_methods.each do |m| undef_method m unless m.to_s =~ /^__|m...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-23T23:39:17.100", "Id": "526119", "Score": "3", "body": "What do you want to accomplish with this code. It's incredible difficult to understand." }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-29T10:46:46.3...
[ { "body": "<p>You balance class does not have a <code>field_data</code> method.</p>\n<pre class=\"lang-rb prettyprint-override\"><code>def fetch_fields\n value = BalanceService.new(field_data) \n value.field_data # this method does not exist\nend\n</code></pre>\n<p>So you could implement a <code>attr_reader ...
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-23T18:40:02.737", "Id": "266333", "Score": "-2", "Tags": [ "ruby" ], "Title": "How can I make BalanceService PORO I wrote better of any code smell?" }
266333
<p>I have this implementation of Grep where I use <code>re.search</code>:</p> <pre class="lang-py prettyprint-override"><code>#!/bin/python &quot;&quot;&quot; A grep implementation on Python &quot;&quot;&quot; from re import search from sys import argv def grep(word, file): for line in file: if search(w...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-24T00:55:16.847", "Id": "526120", "Score": "4", "body": "why would you reinvent grep? And if you want to reinvent grep, why would you avoid it's regular expression support?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationD...
[ { "body": "<p>You should use <code>re.escape(...)</code> in the first version, to match behaviour of the second. Without it, special characters in <code>word</code> could be interpreted as regex patterns.</p>\n<p>Catching <code>IndexError</code> only ensures the user has given enough arguments; it does not pro...
{ "AcceptedAnswerId": "266343", "CommentCount": "6", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-23T22:50:51.027", "Id": "266336", "Score": "1", "Tags": [ "python", "python-3.x", "programming-challenge", "comparative-review", "console" ], "Title": "Search for text in...
266336
<p>I have <a href="http://coderodde.github.io/weblog/" rel="nofollow noreferrer">this blog</a> lurking around in the web. It's just static HTML, but I was interested to keep track of all the views on that blog. Finally, I end up with the following web application:</p> <p>(The Java backend resides entirely <a href="http...
[]
[ { "body": "<p>As you are no beginner, just the terse style I'd also use in my team:</p>\n<ul>\n<li>Singleton anti-pattern in the DAO. Isn't there a DI container around somewhere?</li>\n<li>Too verbose with different exception types. The handling is exactly the same apart from different messages, therefore one e...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-24T05:09:38.833", "Id": "266344", "Score": "0", "Tags": [ "java", "javascript", "mysql", "servlets" ], "Title": "A Java EE7 web application for counting views in a static HTML pa...
266344
<p>PROBLEM: I need to merge the columns by identifying the headernames and they work as desired by using the below code.</p> <p>The code is very inefficient as I am using an eval to accomplish the job and I believe it makes unnecessay multiple passes which is not recommended. Is there a way I can optimize my code to me...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-24T08:34:41.520", "Id": "526146", "Score": "0", "body": "is this a task for university? seems rather unusual and far from a reality case" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-24T08:58:21.227", ...
[]
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-24T08:19:18.357", "Id": "266347", "Score": "2", "Tags": [ "javascript", "array" ], "Title": "Combining columns based on header names of an array" }
266347
<p>I'm writing an app meant to have similar functionality to LucidChart - drawing shapes/diagrams. I'm using React with Typescript (Create React App) and am trying to follow OOP/polymorphic patterns I've been learning about from watching videos by Uncle Bob Martin and elsewhere on the internet - factory, singleton, sta...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-24T09:30:40.260", "Id": "266350", "Score": "0", "Tags": [ "object-oriented", "design-patterns", "react.js", "typescript" ], "Title": "React Typescript Project Using Traditional O...
266350
<p>I recently started programming and chose C# as my first language. After a couple of weeks/month now I tried to make my own Sudoku solver in a console application. I'm happy with the result, and tried to clean up my code.</p> <p>But I'm not sure what I can do better at this point. I was uncertain if I created too man...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-24T22:32:55.573", "Id": "526207", "Score": "2", "body": "You may want to consider storing your puzzle in a single array (size 81), which will make it easier to loop through the all values. Determining the row index is simply cell index...
[ { "body": "<p>Functions are not just about reusing code. I thing the way you &quot;cut&quot; the code using specific functions is quite clean.</p>\n<p>I would strongly suggest using summaries above functions to describe things, even if your function names are quite explicatives</p>\n<p>At last, I would probably...
{ "AcceptedAnswerId": "266357", "CommentCount": "6", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-24T12:14:35.887", "Id": "266353", "Score": "9", "Tags": [ "c#", "beginner", "sudoku" ], "Title": "Criticize my Sudoku solver for improvements (C# beginner)" }
266353
<p>I have this code that generates a random line and a random circle.</p> <pre><code>import numpy as np import matplotlib.pyplot as plt def random_2D_position(c_bx, c_by, r, region_side): while True: v_pt = region_side * np.random.random((2, )) if np.linalg.norm(v_pt - np.array([c_bx, c_by])) &gt; r...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-24T18:13:50.857", "Id": "526180", "Score": "0", "body": "Are you sure this code is working as intended? My editor gives me a bunch of indentation errors and missing brackets." }, { "ContentLicense": "CC BY-SA 4.0", "Creatio...
[ { "body": "<p>Are you asking for feedback on your code, or do you just want someone to fix your two bullet points? Asking for extensions to the code outside of (is there a better algorithm/can this be done in a better way), is outside the scope of this site and is better suited for stack overflow.</p>\n<p>Lets ...
{ "AcceptedAnswerId": null, "CommentCount": "5", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-24T17:43:38.047", "Id": "266358", "Score": "0", "Tags": [ "python", "python-3.x", "numpy" ], "Title": "line-circle intersection" }
266358
<p>I have been looking at the Fisher Yates randomizing suggestions on StackOverflow after ruling out <code>arr.sort(v =&gt; Math.random() - 0.5)</code> due to lack of randomness in the latter.</p> <p>The Fisher Yates functions look OK, but used while loops etc. Alternately, the javascript array functions (map, reduce, ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-24T18:24:33.203", "Id": "526182", "Score": "1", "body": "\"*The Fisher Yates functions look OK*\" - which ones did you look at? It might help to see the code that you started from (or at least links to it)." }, { "ContentLicens...
[ { "body": "<p>This code is overly terse, clever and (in the bottom two examples) broken. The versions with loops are far more readable, correct/verifiable, efficient and intuitive to understand.</p>\n<h3>Don't cache <code>array.length</code></h3>\n<p>I recommend reading Eric Lippert's <a href=\"https://ericlipp...
{ "AcceptedAnswerId": "266389", "CommentCount": "14", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-24T17:54:32.577", "Id": "266359", "Score": "0", "Tags": [ "javascript", "shuffle" ], "Title": "Fisher Yates Shuffle, but using Javascript Array Functions" }
266359