Are you asking for help in changing the code to work with for i in 0..arr.count, or are you mostly looking to get a review of the parts you have that work correctly? — Phrancis21 secs ago
This is an assembler for the Hack assembly language as described in "The Elements of Computing Systems" by Nisan and Schocken, MIT Press. The details of the Hack computer and its assembly language can be found at http://www.nand2tetris.org/ if anybody is interested.
I am aware that I am not doi...
Maybe this is a little large for a simple code review, but I think it included a lot of different needs and how I tried to meet them. Pick a section and let me know where I went wrong.
The code is for a nand gate simulator and takes an input file with wiring pairs. Like variable to gate or gate t...
Well, I have a drink, and Friday night is movie night.... and tomorrow I have to go and renovate my brother's bomb shelter.... so it won't be needed for a while ;-)
As it is, I just have some chicken on the BBQ and I am between flips.
I am learning clean code, now TDD. Now I want to test my AutoLoader class, what needs to do the next job:
do a check is the namespace is string
do a check, is the path to directory parameter is a string
do a check is the path to directory what I want to load is exists, directory and readable.
...
I know it's not that bad, but I can't help but wonder if there is a way to make this DRY-er.
s = self.start
e = self.end
if s.x > e.x:
s.x, e.x = e.x, s.x
if s.y > e.y:
s.y, e.y = e.y, s.y
You might be right, i never used 'code review stack exchange', thanks for letting me know. I do need to use custom pagination as paginate() method won't work with having keyword. There is dynamic distance variable inside of SQL and is not seen when using default paginator from Laravel. This is quite common error - im not alone with this one. (SQLSTATE[42S22]: Column not found: 1054 Unknown column 'distance' in 'having clause') — rk.dev37 secs ago
Hello I am a fairly new at python and programming. I created this simple calculator inspired on my physics class; however, I feel this code could have been done more efficient. Are there any advice for efficiency? here's the code:
import math
#calculates vector x component
#x = side length y = ...
As a simple programming exercise, I wrote a piece of Node.JS code which generates random poems. It is based on a list of articles (kind of), nouns, linking verbs, and adjectives. It then combines them into lines, and eventually stanzas.
var articles = "The,All of the,Most of the,Some of the,My,Y...
NOTE: I am not familiar with a lot of terminology. If I am naming things incorrectly, please correct me!
Making small game engine for the heck of learning. Mostly using inheritance, but the more my project grows, the more I feel like objects are inheriting to much.
Example of inheriting classe...
I have created some c++ code that is supposed to check to see if a users input is correct but it isn't quite working how I wan't it too.
After long hours searching over the internet I couldn't find anything to help so that is why I am asking for suggestions here.
What I really need is suggest...
I'm using haversine formula to count distance from selected post-code to desired destination.
I have following scope in App\Models\Business.php
public function scopeDistance($query, $latitude, $longitude, $radius)
{
$query->getQuery()->orders = [];
return $query->select('*')
...
I wrote a review for Check consistency of a list of statements, with fuzzy rhyme matching, which basically required me to try writing my own solution to fully understand the challenge. So, I thought that I should put my solution up for review.
I'll paraphrase the "MÃ¥rten's Theorem" challenge on...
I'm new to sql and very novice with this package. SQL is running in Watson DashDB.
For the past few hours I've been struggling to find the correct code. I'm trying to accomplish a few things.
1. Create a new view called SENTIMENT
2. Join two tables together
3. Have the new table show 4 columns...
Problem statement
KnightL is a chess piece that moves in an L shape. We define the possible moves of KnightL(a,b) as any movement from some position (x1, y1) to some (x2, y2) satisfying either of the following:
• x2 = x1 ± a and y2 = y1 ± b or
• x2 = x1 ± b and y2 = y1 ± a or
N...
I have provided a problem which states like this
| 7
| 4 8
| 2 5 9
| 1 3 6 10
Each cell can be represented as points (x,y)
At (1,1) value is 1 ,at (3,2) value is 9, at (2,3) value is 8. This pattern of numbering continues indefinitely.
From function answer(x,y) we have to return the value...
This is the first app I've made for Android, I decided to make it so I could have a schedule for myself that was (hopefully) light weight and because I was recently converted from iOS to Android and wanted to learn the API. Right now it just has the bare essential function of saving text for a ce...
I just did some online programming application test thing for a job interview, they 'skipped' the technical interview due to how well I did on the programming questions.
I am following the book Programming from the Ground Up and as an answer to a question in the Use the Concepts section of chapter 4:
Convert the maximum program given in the Section called Finding a Maximum
Value in Chapter 3 so that it is a function which takes a pointer to several value...
Problem statement
The city of Gridland is represented as an n X m matrix where the rows are numbered from 1 to n and the columns are numbered from 1 to m.
Gridland has a network of train tracks that always run in straight horizontal lines along a row. In other words, the start and end po...
i want to buy a python chat bot which uses artificial intellegence for my final year project.plz help me.i want it as soon as possible.i tried to make it my self but there is a little problem in implementing AI in chatbot
I wrote a program in c what looks for integer solutions of different formulas. The program asks the user for a dimension which defines the formula. For example, the formula of the third dimension has three variables, the formula of the second dimension has two variables. The formulas look similar...
The following function determines the amount of indentation of a string. It returns two values. The first is an effective indentation where tabs are expanded such that their end aligns with 4 spaces steps. The second is just the amount of spaces and tabs before the first non-tab/space character.
...
I'm trying an OpenSource web panel, with a PHP backend...
But I encounter some issues when I try to center a form on page :
When page height is normal :
When using a smaller height, this happens :
And I don't want the page to 'eat' the top of the form(and the logo), I wan't to ma...
Woud that be a practicable way for a kind of 'finally' block in VBA?
This sample is taken from
http://stackoverflow.com/questions/42492590/can-i-return-from-the-current-event-stack-in-microsoft-access-vba
I reworked it a bit to show the idea I got from reading the mentioned article.
Sure, usua...
today I understood that compiling a compiler in a debug mode is a pretty bad idea. I got my compilation time slowed down on average ~80x. Then when I wanted to try to compile it using itself in a release build ... well, it took around 2 hours to reach 20%. Then I messed with update-alternatives and cmake for around 2 hours, but I believe I got it working now
I am just getting started with python. I wanted to make a folder transfer tool to get familiar with python sockets.
import socket, os, sys
print"[*]Enter the IP[*]"
ip = sys.stdin.readline().rstrip()
port = 9999
# A file sender first
def file_sender(location, client_socket):
f = open(locat...
I am writing a program to count only the partitions of a number with distinct parts.
I am using a bottom-up approach to dynamic programming to generate partition lists from previously obtained partition lists. I think my program runs correctly, as I have tested for some inputs and verified from O...
Am developing a app using swift 2.2 in my app am using collection view with pinterest style so that am followed a method: https://github.com/chiahsien/CHTCollectionViewWaterfallLayout.
Am getting a data from the server which contains image that is
{"success":1,"error":0,"subcategory_value":"tr...
So I've made a snake game with object-oriented approach. I would be glad if you could take a look at the code and give me any advices/tips/point out errors/etc. :)
main.cpp:
#include "SnakeGame.hpp"
int main(int argc, char **argv)
{
srand(time(0));
int borderSize = 15;
CSnakeGame...
I wrote a deque implementation in C for storing char *. It uses a doubly linked list, but I'm calling it a deque since it can only push/pop from the head and tail of the list.
I don't have much experience writing C (I'm more of a Python guy) so please let me know what can be improved! I am alrea...
This is a basic name generator I just wrote and want some feedback.
It basically chooses between a vowel or a consonant and appends it to a string. Note that it never puts two vowels or two cononants directly together, as it checks for that.
import random
vowels = ['a', 'e', 'i', 'o', 'u']
cons...
I am looking for some comments on an implementation of a singly-linked list in Python. What could I do to make it more reliable and readable?
Also, how could I unit test this implementation? That is, what particular tests should I implement to cover the use cases of the linked list?
class Linke...
I want to simulatetransportation of passengers by ship from station A to station B.
First of all, arrival of passengers to each station is simulated by poisson process with given lambdas(for each station different lambda)
Here is the code for simulation of arrivals time in interval [0,end]:
p...
Here is a vanilla JS module that I wrote for sorting and searching an array.
I would appreciate feedback of the design of the module as I'm new to writing javascript in modules and don't know if I'm missing the point.
"use strict";
/**
* Find is an outer function
* @param {int} needle ...
I need a function that hashes a list of different inputs (integral datatypes, strings, bytearrays) in a recursive manner
def RecHash(v):
isSingleElementOfList = False
if type(v) is list and len(v) == 1:
isSingleElementList = True
if type(v) is not list or isSingleEl...
I have a 2 classes Armor and Weapon in my game, that inherit from the abstract class Gear
Then I have a class GearButton which it is nothing more than a button, with a piece of gear associated. I inherit from this class to create Buttons to Buy, Equip or Upgrade this items, for instance.
This i...
What do you think about this code? I'm learning Python and I made this tool to code a plain text or decode it!
inp = input('Input the text you want to code:\n')
inp = inp.lower()
key = int(input('Input the key you want to use from 2 to 25:\n'))
def rot13(input,key): #Function to code a text wit...
I'm downvoting this question because you haven't given any pure description about how your code works. No class summary, no nothing! — Simon Forsberg ♦1 min ago
Your question doesn't look interesting to me at all. You say that you have implemented "Storing databases" but haven't described at all your approach to do so.
I have a class in which I am populating a map liveSocketsByDatacenter from a single background thread every 30 seconds inside updateLiveSockets() method and then I have a method getNextSocket which will be called by multiple reader threads to get a live socket available which uses the same map to...
On the other hand, I doubt it's blocking reviewers, if we actually had reviewers who were interested in such questions one would've answered by now (with the added bounty too)
It's probably not terribly written as then someone would've pointed it out, but I cannot say it's well-written just because it lacks response
You might want to take this question to [Code Riview](codereview.stackexchange.com). — rbellamy7 secs ago
A couple of code review points: 1) the inner loop might be clearer if it were for (int j = i+1; j<i+3; j++), then use j instead of j+1 in the loop; 2) what if there aren't a multiple of 3 parts? The inner loop would get an AIOOBE. — Andy Turner55 secs ago
Code review handles improvements of working code. Since it's homework, I don't want to say too much, but how about a counting sort followed by checking the neighborhood with a hamming distance of 1? — Kenny Ostrom40 secs ago
Background
I came up with this solution to a question that I posted on stackoverflow. It uses Tkinter to create a file select dialog window and raise it to the topmost position from jupyter notebook.
Questions
1) Is there some kind of built in or canonical way to do this in jupyter notebook t...
Seems a reasonable use of subroutines, although I've never seen Close raise an error so On Error Resume Next / GoTo 0 in the CleanFinally subroutine doesn't seem warranted. What's the question? If you have real code using this, Code Review would probably be a better place to get feedback. As is stands though, it would probably be closed as "hypothetical code" given it's pretty much boiled-down. — Mat's Mug1 min ago
There is nothing special in the mapping. The NHttpModule has a flaw, it tries to use the session after a failure for logging. It should log with a new session instead. But that is probably irrelevant to your question. The SessionProvider is an exception eater and conflicts with NHttpModule on transaction handling. No wonder strange things occur. And it let me think you may use Update as if it where corresponding to SQL updatestatement. I think you need to have someone to review your application code, but It will not be me. Maybe go on codereview.stackexchange.com. — Frédéric25 secs ago
I am attempting to solve the kattis problem Recount. My program will pass all of the tests except the very last one where it "times out". Any input I can get on this will be greatly appreciated. This code does compile and run in VS and here -> cpp.sh/8l3b
To get this to run on cpp.sh I did have...
Having only had experience with programming in Matlab I started this project to learn a real programing language, object-oriented programming and a proper coding style.
I wanted to implement a numerical version of how I would solve a sudoku and stay away from the plenty of solutions using backtr...
I was given a test to write a class that calculates a vehicles average and expected milage without using a database or framework.
The milages were to be calculated given some different types of events, which I've decided to implement in a flat way, as this is how I would store them in the DB.
T...
I'm making a simple todo list app with ES6. I'm looking for some feedback on the code, I feel like there is some improvement possible. Maybe there is a way to better way to attach eventListeners to input and button, but to keep in mind they have to be set not just when a new element is added but ...
@Mast Have you tried printing the exception to see why it fails?
I don't know as much about SQLite, but normally in SQL you'd do a conditional statement like IF NOT EXISTS (SELECT 1 FROM BookAuthors WHERE AuthorId = 42) INSERT INTO ...
OFC you could also write the conditional SQL query with Python, but that would require two separate queries so it may not be best for performance
If you have a table called memos that has two columns id and text you should be able to do like this:
INSERT INTO memos(id,text)
SELECT 5, 'text to insert'
WHERE NOT EXISTS(SELECT 1 FROM memos WHERE id = 5 AND text = 'text to insert');
If a record already contains a row where text is equal t...
For all you know, it could be a simple SQL syntax error that causes the exception
@rolfl I installed ESLint, I tried JSLint but its support of ECMAScript 6 is flaky, ESLint supports it just fine and seems more configurable too
Also, you can set it to "no semicolons" as the expected code style ;)
The objective of this piece of code is to get a message from a cryptocurrency daemon through RPC and extract the transactions object to pass it to the view.
Is there a simpler / less ugly way of doing this?
$transaction_pool = json_decode($rpc->getTransactionPool(), false);
if(isset($transactio...
I am looking for a review on the below code, which is a simple static webserver, with a small bit of error handling. It's feeling a bit "messy" / "imperative" at the minute, so advice would be welcome.
import Network.Socket hiding (send, sendTo, recv, recvFrom)
import Network.Socket.ByteString
i...
Heh, today I wired up....: - new 120V plug - relocated a cable-modem (including extending cable) - created 3 custom Cat6 network cables for the new lengths of components. - split an existing Cat5e cable in half, terminated the cut ends - relocated a carbon monoxide detector - relocated a telephone junction box - added a new telephone hard-point - relocated a internet phone box to use new hard point - neatened the whole lot up
I do this sort of thing occasionally, and although I had to reference my notes the first time, by the end of the day I was adding RJ45 connectors to cables without even having to check the wiring...
This is not a very good duplicate, but I think the question should be put on hold anyway, because this is not a code review site. The code is good, though, so there's nothing to review :-) — dasblinkenlight19 secs ago
@rolfl I have a dilemma, what do you think? This Node.js book I'm going through has a chapter on using DBMS with Node, the exercises use MySQL; my dilemma is this: I don't have MySQL installed and have no need for it, but I do have SQL Server installed, and there exist npm packages for that DBMS, so I could either adapt the examples to a different DBMS and save the hassle of having to setup MySQL, or install MySQL like the book says to do...