instruction_seed
stringlengths
71
95.1k
_source
stringclasses
1 value
I'm currently building an application that uses the same models in different controllers. Instead of using the normal way, being loading the model in the controller I've build a "core controller" (Foundation_controller) which can load models all other controllers extend from this controller in a way. In those extended ...
stackexchange/codereview
I've written a simple web scraper in Python. As it is my first venture in Python, I'd like to ask for a code review from more experienced coders. All input is welcome. A little bit of background: I'm a huge fan of video games. In Japan, there is a company called Media Create which tracks all sales of games and consoles...
stackexchange/codereview
Problem I have \$N\$ words. For each valid \$i\$, word \$i\$ is described by a string \$D_i\$ containing only lowercase vowels, i.e. characters 'a', 'e', 'i', 'o', 'u'. We check the number of strings \$D_i\$ and \$D_j\$ which, when concatenated into a new string \$M\$, contain all 5 vowels. What is the total number of...
stackexchange/codereview
from itertools import permutations def next_bigger(n): nlist = list(str(n)) perm = permutations(nlist,len(str(n))) perm = set(perm) listofperm = [] nlist = int("".join(nlist)) for x in perm: form = int("".join(x)) if form < nlist: continue else: li...
stackexchange/codereview
I have been worked on creating a chat tool similar to vk.com. Right now I have done a simple chat which requires only authentication via a PHP website and everyone can chat with each other. I used the NodeSession PHP class to access the PHP session in the node.js application. To implement the application I used Yii1, n...
stackexchange/codereview
I recently posted a program that I wrote that would change a password after being validated, the program can be found here. I have rewritten this program, it has a couple new features: Usernames Decryption Program related errors How it works. At the beginning of the program you asked to make a username, that username...
stackexchange/codereview
There is a string "abcdebfkj", we need to transform this string to the below array: expected o/p:   ["a", "a.b", "a.b.c", "a.b.c.d", "a.b.c.d.e", "a.b.c.d.e.b", "a.b.c.d.e.b.f", "a.b.c.d.e.b.f.k", "a.b.c.d.e.b.f.k.j"] I am able to do that, but was looking for more promising solution if any. I did that in O(n) time com...
stackexchange/codereview
I did this library to help me from one of my projects and decided to publish it on GitHub hoping people might find it useful, convenient and easy to use in their projects too. It's a header-only library. The library design is inspired by some popular Java code conventions, like naming of classes and the popular usage o...
stackexchange/codereview
I have some triggers placing and sizing elements for video controls. It works well enough but mostly through trial and error and I am not sure if there is a better pattern: The full source can be found here and webpage here. My biggest issue I think is when is it appropriate to have an element listen (e.g. on the speci...
stackexchange/codereview
For this equation, I need to count possible solutions: $$ a + b^2 + c^3 + d^4 \le S $$ $$0\le a,b,c,d \le S$$ I tried the following approach: Integer S=Integer.parseInt(br.readLine()); // get maximum possible value of a,b,c,d which satisfy equation int a=S; int b=(int) Math.sqrt(a); ...
stackexchange/codereview
I have this repository: https://github.com/coderodde/ParallelRadixSort.java/tree/main It contains a parallel MSD radix sort presented below: package com.github.coderodde.util; import java.util.ArrayList; import java.util.List; import java.util.Random; /** * This class provides the method for parallel sorting of {@co...
stackexchange/codereview
I have a pandas data frame and I want to calculate some features based on some short_window, long_window and bins values. More specifically, for each different row, I want to calculate some features. In order to do so, I move one row forward the df_long = df.loc[row:long_window+row] such as in the first iteration the p...
stackexchange/codereview
I recently started to learn Python for the purpose of making my life as a network engineer easier when performing repetitive tasks. The script below does parse a huge inventory.xml file I get from a reporting tool to find the ID of ports I want it to and then writes back to the XML file a structure representing a cable...
stackexchange/codereview
I need a lock-free queue which is implemented by doubly linked list. Is my code correct? Are there any errors? Are there any improvements to be made? linkedlist.h /* * linkedlist.h * * Created on: 2014. 5. 10. * Author: dlaru_000 */ #ifndef LINKEDLIST_H_ #define LINKEDLIST_H_ /* * circular doubly linked...
stackexchange/codereview
I've been working on a text-based Zork-style game project for the last couple of months to teach myself Python. I have barely any experience coding prior to this project, but thanks to Stack Exchange and youtube I've made decent progress. About a week ago I posted a version of my code here to Code Review, and I've been...
stackexchange/codereview
I wrote this to be able to compare two different arrays to figure out how many words were in common as a percentage value. The use case is that I have array a which is a list of the most commonly known and used words in a language (normally something like 2000 different words). In array b I have the text. The end resul...
stackexchange/codereview
In Leetcode it states that my runtime is only faster than 38% all of submitted JavaScript solutions. Is there anything I can change to make it more efficient? /** * @param {number} x * @param {number} y * @return {number} */ var hammingDistance = function(x, y) { var resultStr =( x^y); let count =0; whi...
stackexchange/codereview
My code fetches quiz data from a JSON file, displays the questions sequentially and records the user’s answers. It keeps track of the user’s score and at the end displays their result based on a second JSON file. const QUIZ_API = 'quiz.json'; const RESULT_API = 'result.json'; const QUIZ_ID = 12; // Used to identify th...
stackexchange/codereview
I'm developing an ASP.Net web application, using MVC 5. This application authenticates via LDAP and will assign an Identity Role of "Admin" to a designated user. The Admin user will be able to go to an administration page to add users with a role of "Admin", if the admin checkbox is not checked, then the role is "Emplo...
stackexchange/codereview
I wrote this function that will toggle a class of a targeted element. Applying the class js_class_toggle to any element will trigger the function when clicking on it. To define what the target element is and the class you want to toggle is, you have to add data-class-toggle="target_element_id.className" to the element....
stackexchange/codereview
I have implemented an in-memory filesystem - this is a design question from LeetCode. Is there a better OOP approach to represent files and directories? The current code uses a boolean flag isDirectory to distinguish between files and directories and I'm not confident that it is the best approach. See the code below. I...
stackexchange/codereview
I am creating a fluent interface to build user interfaces in the Unity game engine. As a subcomponent of this library, I have a set of objects called Components (e.g. Panel, Button, etc) that I want to map to new instances of View objects that are created by cloning an original "prefab" object. This is converts the obj...
stackexchange/codereview
I've just started doing programming problems. https://icpcarchive.ecs.baylor.edu/external/58/p5880.pdf The code below works fine, but my run time is 2.715 seconds and the time limit is 3 seconds. How can I improve speed of this code? I've already started to use sys.stdin instead of input(). import string import sys w...
stackexchange/codereview
Exercise: Checking if a sentence is considered valid under the following conditions: Numbers less than 13 are only allowed in their written form, e.g "twelve", but "14" is considered valid. Only 1 period marker is allowed and it must be the final character First letter must be uppercase number of quotation marks in th...
stackexchange/codereview
I'm working on a WPF project where a timer with Pause/Resume functionality is required. The standard Windows.Threading.DispatcherTimer doesn't offer that, so I decided to inherit the class and add those features myself. The way it works is pretty simple, there is a Stopwatch running internally, whenever Pause() is call...
stackexchange/codereview
I am managing an OAuth implementation for Puredata (Pd), which is written in C. OAuth can accept RSA keys, but Pd cannot send messages with newlines, so placing private keys will come as a list of strings with spaces acting as separators. Basically this function looks into the different parts of the block and adds eith...
stackexchange/codereview
I've been working on a non-blocking IO library, and wanted to get some feedback on my generic event loop class. The goal is that this class will manage select() calls as well as other "events" which must occur on the same thread that the IO is processing. I'm hoping that this can scale to a relatively large size of...
stackexchange/codereview
I've noticed that whenever a shader program class is implemented (from some questions on this site, as well as more reputable implementations), that: The class tries to do too much. Binding to the current context, setting attribute variable values, and much more. Use the JavaBeans pattern in one form or another, allow...
stackexchange/codereview
I have a registration system, but I really don't know if it is safe, because I don't understand security very well and I'm afraid of compromising my clients' data, I believe that the methods I created are good for security, but I still have doubts if it is safe I created several variables using encapsulation, and then ...
stackexchange/codereview
I wanted to get feedback on the correctness and efficiency of this post order traversal routine that my wife and I find really easy to grasp. def postOrderTraversal(root: TreeNode): curr = root stack = [] while stack or curr: if curr is None: if stack[-1].right is None or popped == stack[-1].right: ...
stackexchange/codereview
I've written a script in python to grab different title and address from different pages of a website. Firstly the script will collect all the property links from the landing page and then go one layer deep to collect the title and address. When I run my script, I get the results accordingly. Should it not be a better...
stackexchange/codereview
I am looking for advice to see if the following code performance could be further improved. This is and example using a 4x3 numpy 2d array: import numpy as np x = np.arange(12).reshape((4,3)) n, m = x.shape y = np.zeros((n, m)) for j in range(m): x_j = x[:, :j+1] y[:,j] = np.linalg.norm(x_j, axis=1) print x ...
stackexchange/codereview
I have a bunch of large XML files that I have to parse and store in Postgres. I have done a lot of procedural code but I want to think in terms of objects and reap the benefits. Any help in that direction is greatly appreciated. The XML itself is fairly straightforward - Each Person object has employer, employer office...
stackexchange/codereview
Because this is my very first attempt to create a data grid with Vue, I would like to know about all misconceptions used in my approach. Whomever points to the most important shortcoming / weakness in my approach will receive 50 points :). var url ='https://api.mockaroo.com/api/b5f38710?count=20&key=cdbbbcd0' new Vue...
stackexchange/codereview
I wrote this code that makes a fairly long function call multiple times using some of the same parameters match key { Key { code: KeyCode::Left, .. } => self.map.move_object_by(PLAYER, -1, 0), Key { code: KeyCode::Right, .. } => self.map.move_object_by(PLAYER, 1, 0), Key { code: KeyCode::Up, .. } => self.ma...
stackexchange/codereview
I made a provably fair 1v1 coin flip game in Laravel and I want to be sure it's safe (cannot be hacked) and that the outcome is random (50/50). At first Player 1 starts the bet and the hash will be created. The hash is a SHA256 of the $secret, which will be revealed to the players after the game. This hash ensures that...
stackexchange/codereview
I created a procedural implementation of the nested set model in JavaScript. The use case for this small library was that the front-end(presented as an MVC) needs to traverse hierarchical data from back-ends. The library that I created satisfies the following: DSL-like architecture, with clear distinction between a t...
stackexchange/codereview
In relation to this question, an upcoming exam (on the 20th May 2019) requires me to carry out this task using Visual Basic, Python or Pascal/Delphi. I am using Python (version 2.7/3.7) since the program is easier to read and write in this language. Here is the pre-release for my exam: An auction company has an intera...
stackexchange/codereview
This function converts a string like: /{?lang(2-5):lowercase}/{page(2+):lowercase}/{article}-{id:integer}*.html* Into the following regular expression: @^(?J)/(?:(?P<lang>[a-z\d\-_\W]{2,5})/)?(?P<page>[a-z\d\-_\W]{2,})/(?P<article>[\w\W]*?)\-(?P<id>[1-9]*?).*?\.html.*?$@ Ready to be used somewhere else, using preg_matc...
stackexchange/codereview
private static List<ConstrDirectedEdge> kruskalConstruct(ConstructionDigraph CG) { int current = CG.srcVertexIndex(); boolean visited[] = new boolean[CG.V()]; visited[current] = true; UF uf = new UF(CG.V()); List<ConstrDirectedEdge> feasibleNeighbours = new ArrayList<ConstrDirectedEdge>(); List...
stackexchange/codereview
This is a follow up to question. I fixed the issues mentioned in the answer as far as my understanding. The union and intersection now return new object instances with new implementation. I also wrote a test, which is below. class MultiSet include Enumerable def initialize enum=[] @members = {} raise Argum...
stackexchange/codereview
Recently I got test task at the project, it is fairly simple: const _ = require('underscore'); // Challenge: // // Write a function that accepts as argument a "function of one variable", and returns a new // function. The returned function should invoke the original parameter function on every "odd" // invocation, r...
stackexchange/codereview
Follow up on this post. I have refactored my code and created a matrix_t struct and implemented various functions to create, delete, modify and perform arithmetic on them. matrix.h #ifndef MATRIX_H #define MATRIX_H typedef struct matrix_t { size_t rows; size_t cols; double *data; } matrix_t; matrix_t *mx_...
stackexchange/codereview
This code merges cells in multiple columns on multiple sheets, and it's too slow. I'm hoping for any help at all to speed this up. Unfortunately, I'm not able to get around the fact that the cells must be merged. I broke up the for statements - it helped a bit, but it's still very, very slow. Also, I turned off screenu...
stackexchange/codereview
This is my first time implementing a merge sort (just getting started with algorithms & data structures). Are there any obvious things I have done wrong? I am also worried that I have overused recursion, as both the merge & the sort function are recursive. function sort(array) { var len = array.length; var middle ...
stackexchange/codereview
So I am working on an x86 Assembly program for Linux using NASM. This program basically asks the user for their name and their favorite color. After doing this and storing the two strings in variables declared in the .bss section, the program prints "No way name of user, favorite color is my favorite color, too! The pr...
stackexchange/codereview
I wrote an implementation of elliptic curve Diffie-Hellman key exchange in python. I would like to know if I could make it faster, cleaner or more secure: def ext_euclidean(a, b): t = u = 1 s = v = 0 while b: a, (q, b) = b, divmod(a, b) u, s = s, u - q * s v, t = t, v - q * t re...
stackexchange/codereview
Recently, I reviewed this question about an LZW decoder. In order to properly review that question, I needed to write my own encoder and decoder to be able to test their program. Someone thought it would be interesting to submit these programs for review, so here they are: encode.c /* * LZW encoder * * - Uses fixe...
stackexchange/codereview
Background: I need to use mutation observers to watch for nodes being added/removed under a specific element. The code below is an attempt to implement something re-usable that uses MutationObservers where available and falls back to mutation events where not available, providing a simple unified interface to both. The...
stackexchange/codereview
Today I created my first simple AJAX application. It works fine, but I am a bit unsure if I did everything correct. I'd like to use the code as template for future projects. function _solve(id) { var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function () { var DONE = 4; // readyState 4 means t...
stackexchange/codereview
At my work, I need to use multiple versions of Java, depending on which project I work on. I've made a batch script to take care of this. There are several different actions that you can perform with the script. You can change the current value of your JAVA_HOME from a version in your file. You can add new Java instal...
stackexchange/codereview
I was trying to emulate python's timeit in C++. My main aim for this is to measure the performance of small functions of C++ code that I write and print some basic stats like avg., min, max. Code: ctimeit.h: #ifndef CTIMEIT_H #define CTIMEIT_H #include <chrono> #include <cmath> #include <iostream> #include <limits> n...
stackexchange/codereview
This is a Python script that generates a grid of random HTML colors. It works by reading random data from /dev/urandom and then encoding it as a hexadecimal string. This string is spit into individual values that will be represented as a color. I am wanting to know if this is the best way to generate random values fo...
stackexchange/codereview
These functions are more or less the same. They are doing the sign in process for a flask application. A user is retrieved from a database (identified through email address) and the password is checked for validity (bcrypt). If either of those failed, an error should be displayed for the user in the template (signin.ht...
stackexchange/codereview
I'm still new in javascript and learning. I want to create a date picker using html and javascript. Below is what I have tried and it's working, so my question is "how can I do it better?" My idea is to create a custom tag in HTML and allow multiple of these tags. The javascript part will then handle the build and func...
stackexchange/codereview
I'm creating an online calculator to get the average grade of different tests my students take. I wonder if you see any problems in the following code or any way to improve it: document.getElementById('calculator').addEventListener('click', function() { var physicsTests = document.getElementById('physics').getEleme...
stackexchange/codereview
I'm new to refactoring and I have just refactored an old Rails project that had bloated controller methods. I spun off the bloated methods into its own separate controller following this logic, since the quiz functionality can be considered a separate resource compared to the vocab controller's responsibilities (Single...
stackexchange/codereview
I'm ultra new to programming. I basically know only IFs, loops, variables. This is first time I used functions in my code and I'm not sure if I understand them correctly. Basically it is a calculator that requests two natural positive numbers on input, and outputs it's addition, subtraction, multiplication, division an...
stackexchange/codereview
I am trying to write a script which gets a research paper from a website by calling their API and then traverse it sentence-wise with some conditions. The paper is accessible in XML format. I am directly using the nltk.sent_tokenize() to break the relevant part of XML document into list of sentences and then searching ...
stackexchange/codereview
I'm trying to write a factory class that essentially provides a user-friendly frontend to creating objects of different kinds depending on keywords. So the user will just have to import this module, and then use module.factory.make_new with the relevant keywords. The directory structure will be pretty flat: this file w...
stackexchange/codereview
I'm trying to write a Exception Handling class in Python so that I can re-use. If you have any ideas on how I can improve this to output more detailed information I would appreciate it: class EHandle: @staticmethod def printit(): exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split(...
stackexchange/codereview
I'm looking for a review on the following classes and the comments I applied (class assignment): package assignment1; /** * Returns a GeneralEmployee object * Sets the name, id for the object when called. * It increments the id that is assigned to a new employee object so that each employee gets a unique id * It c...
stackexchange/codereview
Overview I am attempting to learn Node JS with Express by creating a project. I have seen many examples of setting up an express.js application with functional based programming, like so: // app.js "use strict"; const express = require("express"); const path = require("path"); const mongoose = require("mongoose"); co...
stackexchange/codereview
I'm putting together a basic web app in .NET core 2.1 MVC to try and better understand how it works. Currently I'm working on returning validation to the UI. Once I have this working I then want to use the same service class for a Web API front end too. Currently the Create Action in the Controller calls the service la...
stackexchange/codereview
How to choose the dark mode properly? {isDarkMode ? <ImageBackground source={require('../Images/bgndDark/bgGradient.png')} style={styles.container}> <Charter isDarkMode /> </ImageBackground > : <Charter isDarkMode={false} /> } Just feels wrong to duplicate "Charter"?
stackexchange/codereview
I have multiple long values and I want to calculate their average value using integer arithmetic, without precision loss and using java rounding rules for division, i.e. when N is 10 and sum is +/- 29, then 29/10 == 2 and -29/10 == -2, not -3. The code should handle situations when the sum of all elements overflows the...
stackexchange/codereview
I'm working on a project (it's a language), and for that project, I decided to go with a low-level C++ style, so that means making my own data types. I recently got done making my own string class implementation. This is actually the first time I've made a string class before, so I may be doing a lot of things wrong. A...
stackexchange/codereview
I have written some jQuery that slides open a panel on click, and changes the toggles of the clickable bit from 'Show All' to 'Hide All'. It works, but I'm trying to figure out what would be the most efficient way to do it, as it seems kind of long to me, and some HTML is repeated. This is the working version and a wor...
stackexchange/codereview
Submitting for review by experts. Inspired by this question to color value cell having duplicates with a different color. So "Apple" will have one color for all duplicates. Then "Banana" will have a different color for all its duplicates. What if number of such values exceeds 56 (max number of ColorIndex property ? Wit...
stackexchange/codereview
I'm reading through Algorithms Fourth Edition by Sedgewick and doing some of the practice exercises in C++11 instead of Java. Exercise 1.3.29 is to write a Queue that uses a circular linked list, keeping only one Node instance variable (last). All comments are welcome, but especially ones focusing on advanced C++ techn...
stackexchange/codereview
I've written a lot of (await SomeTask).AsList(); in my project, and it's kind of annoying to keep wrapping it. To fix this I've written a little extension method on Task<IEnumerable<T>> to be able to do this for me. The code is like this: /// <summary> /// Awaits the Task and returns the result as Task as List<T>. /// ...
stackexchange/codereview
I have code which gets data from a POST request (request.form dict), compares with corresponding attribute in object accident and does some action. The code looks needlessly verbose. How can I optimize it? if accident.status == 1: if request.form.get('reason') \ and request.form['reason'] != accident.reaso...
stackexchange/codereview
I just want to train before interview. I googled concurrency interview questions and one of the question was write concurrent ready stack. public interface ConcurrentStack<T> { void put(T t) throws InterruptedException; T poll() throws InterruptedException; } class BlockingConcurrentStack<T> implements Concur...
stackexchange/codereview
I needed a task system that would let me define a cron-like rule in the database, and be able to find the next and the previous time when the task was and is supposed to happen. I am running a web application, so ways like run a scheduled and check for every minute, or other ways around does not work for me, so I had ...
stackexchange/codereview
I've combined some of my own functions with a function I found and I'm curious to know what others think of it. It will be used to upload and resize/crop images that are jpeg, jpg, png. <?php class ImageUploader { var $multiple_file_upload = true; var $max_size = 1024; var $mime_types = array('bmp' => 'imag...
stackexchange/codereview
I'm currently working with a workbook utilized at my work that has the following code. It currently takes about 10 seconds to complete, and needs to be executed several times throughout utilizing the workbook. Is there any way to speed up this process? Right now, the user specifies enters the drop down items needed i...
stackexchange/codereview
I am trying to create a dynamic Treeview in HTML using jQuery with following code, Code with data and working example : https://jsfiddle.net/8jt0crv7/ var Menu = function(data) { this.data = data; }; Menu.prototype.render = function(root) { var ul = $("<ul></ul>"); var li = $("<li></li>"); li.append($...
stackexchange/codereview
I would like someone review this code and tell if it can be done better, or if the code is elegant and simple enough for the task at hand. I used code climate and I got 4/4 and my test coverage is 96%, yet I would like a professional opinion about it. 'use strict'; var PromisePolyfill = require('promise'); var http = ...
stackexchange/codereview
I have a fast producer thread and a slow consumer thread. The consumer processes as many objects as it can and simply ignores the rest in order to not slow down the producer. Therefore, I used a one-element wait-free single-producer single-consumer queue for passing objects to the consumer in a thread-safe manner. Afte...
stackexchange/codereview
I made a Tic Tac Toe game using C. Here two players, player1 and player2, can participate and play. Please rate my code and suggest improvements. #include<stdio.h> #include<conio.h> void board(char t[]); int cheak(char T[]); void main() { int i=0,n,r=100,p=1; char TOT[9]={'1','2','3','4','5','6','7','8','9'}; char a='...
stackexchange/codereview
The code shown below takes the partial derivative of each pixel of the output fused image of a neural network with respect to input image of the neural network using tensorflow's tf.gradients(Y, X) and compute a Jacobian matrix for each of the two input images MRI and PET. However, the code is really slow since I curre...
stackexchange/codereview
I have a Python class for which I'm often going to want an instance with the default arguments, but I want the class to allow creation of instances. For brevity I'd prefer that the default instance be accessible as a property, so that it can be accessed without a method call. However, the code to achieve this in the wa...
stackexchange/codereview
I have a function that makes sure the user wants to actually leave the page. I am not a jQuery expert. Is the code below the most efficient way to do this function? Or can it be simplified much more to run smoother? Any advice is greatly appreciated. $(document).ready(function() { formmodified=0; $('form *').chan...
stackexchange/codereview
I have a list of rule names coming from .xml file. These rule names needs to be validated against rule names in database (Validator.cs). If valid, then Id of these rule names are used to fetch user data from database (ExportService.cs). I am using a Dictionary object to save name, Id pair from database - Validator.cs...
stackexchange/codereview
I wanted to make something for the Community Challenge, so I made a simple permutation and combination calculator. I'd like input on: The overall design - any suboptimal choices that could be improved? Naming - This is hard, I know. But is it confusing to follow? Some names seem repetitive, others seem overly long. An...
stackexchange/codereview
This is a program about finding all the permutations of an string. I want to be able to make it faster and more efficient like eliminating the recursion maybe. Please advise. What is intended is to also find the permutations of the sub-strings of the main string while repetitions should be omitted. public class StrPerm...
stackexchange/codereview
I wrote the following class so that a single object can be shared across many threads. Is using the ReaderWriterLockSlim redundant in this case and only Interlocked.Funcs() can do the job and ensure thread safety? using System.Threading; public class SharedData<T> where T:class { T _data; ReaderWriterLockSlim _lock; ...
stackexchange/codereview
I'm doing an archived MOOC at the moment which introduces Ruby programming. There are some assingments, yet no solutions and since the MOOC is over no one will correct those (+ the forum is down) I'm totally new to Ruby (background in Java) and asking for some hints on my solution to the following task (my solution und...
stackexchange/codereview
I haven't done too many nested statements in MySQL and I was hoping to have the below SQL looked at and let me know if there is a better/more efficient way of doing what I am trying to accomplish. Through all of my tests it appears that everything is working properly, I just want to make sure I am meeting best practice...
stackexchange/codereview
rules UnWordle is a word guessing game in which it shows you a n*n color grid and a base word. The goal of the player is to fill words into the grid such that it follows these rules: a green brick must contain a letter from the base word with correct positioning. a yellow brick must contain a letter from the base wor...
stackexchange/codereview
My application uses a simple Model-View-Presenter architecture and uses the following classes and interface: Presenter: public abstract class Presenter<V> { private V view; public final void setView(V view) { this.view = view; } protected final V getView() { return this.view; } } ...
stackexchange/codereview
The task is taken from leetcode Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. Note that an empty string ...
stackexchange/codereview
I'd like to know if there's any better way to write this query: (from a in Context.Pages join b in Context.Visitors on a.PageID equals b.PageFK join c in Context.Visits on b.VisitorID equals c.VisitorFK join d in Context.Signups on c.VisitID equals d.VisitFK where d.DateOptinUtc.HasValue && a.UserFK == USER_ID group d ...
stackexchange/codereview
A while back I asked a question about my Simon Says game and did well on my assignment! But now we need to go back in a make some modifications to the game to be more advanced. I've done that as well, but I need some tips to make it more pristine and little cleaner, some things I'm still working on, but any help here w...
stackexchange/codereview
I wrote a Brainfuck interpreter in JavaScript, however it is quite buggy and I can't figure out what I'm doing wrong. It works for programs I've written, but fails on most programs I find on the internet. It seems that the while loop doesn't work correctly when it is supposed to skip over. When debugging, the value of ...
stackexchange/codereview
I have this list of at least seven else-if. When their condition is met, I change the same boolean is_attacked to true. This should be simple but I can't figure out in what way I can achieve the same in a more readable way. if(request_is_attacked){ if(as_knight){ if(piece_abs_val==2){//knight is...
stackexchange/codereview
The program can be used to hide an image within another image and later extract the hidden image. This is done by concealing the secret image within the lowest bits of the apparent image. Example of a cat hidden within a tree. I split it into 2 programs to make commandline args parsing easier, Crypt and Decrypt. Info.h...
stackexchange/codereview
I've made a program in C# that generates Mersenne numbers starting from the current largest known Mersenne prime. It then calculates the modulo between those numbers and smaller ones starting from 3 in order to figure out if it is divisible. I've used some math tricks to make the process pretty fast, and so I can check...
stackexchange/codereview
I recently picked up C, because I am getting tired of the hell that is Java Enterprise development. I decided that writing a Huffman compressor will be a great little exercise, and I have always wanted to write a compression algorithm. I want some pointers(get it) on how to make the code more idiomatic, modular and les...
stackexchange/codereview
I'm fairly good at programming python but of course i want to write cleaner code. This is a simple script that scrapes leads off yellowbook. I want to utilize list comprehensions but im comfortable with using for loops, however i can see how it can be repetitive. Any ways i can make this cleaner ? service_name = input...
stackexchange/codereview