instruction_seed stringlengths 71 95.1k | _source stringclasses 1
value |
|---|---|
I've tried to make a portable way of ensuring endian-specific code gets generated at compile time using C++11, however I only have a computer with Windows on it to test at the moment. Because of this, I'm a bit limited in the amount of places where I can test my code. Also, would anyone be able to offer some best-pract... | stackexchange/codereview |
I'm not sure if this is the correct place for an optimization question like this, but I'm not even sure where to start looking. So here it goes.
There's this game I play that has very simple rules. You start with some of a resource and a single worker. This worker collects said resource and you can buy one of two upgra... | stackexchange/codereview |
I am working on a Nagios Scraper in Python3. I have Github set to automatically run checks (i.e. Python Linter) to make sure the code is good. It is currently failing that check, although the code works.
When I check with a PEP8 checker online, I am getting constant warnings about `line break before binary operator. Th... | stackexchange/codereview |
I was bored the other day and decided to have a crack at Project Euler Problem 54 for some fun. Given a file containing one thousand poker hands dealt to two players, the task is to count the number of hands won by Player 1.
This is the first project Euler problem i have completed and thought it would be good to get s... | stackexchange/codereview |
This sorts a linked list using mergegort. Can you please critique my code and provide your thoughts on where I should improve my code?
import java.util.Iterator;
import java.util.NoSuchElementException;
public class LinkedList<T extends Comparable<T>> implements Iterable<T> {
private Node<T> head;
public Lin... | stackexchange/codereview |
I am a newcomer to design patterns. I read some articles about the abstract factory pattern, and wrote the following simple example:
public interface ParserFactory {
List<ITransport> getBusList();
List<ITransport> getTrainList();
List<ITransport> getPlaneList();
}
public abstract class XMLParserFactory im... | stackexchange/codereview |
I have grid N × M in which each cell is coloured with one colour.
When the player clicks on any cell of the grid of colour α, the cell in the top-leftmost corner of the grid, of colour β, receives the colour α, but not only it: all those cells which are connected to the source by paths which use only the colours α or ... | stackexchange/codereview |
I'm pretty sure this code can be optimized, but I'm not talented enough in Linq to do it myself. Here's what I'm trying to do: I have an XML file that needs to be converted into a .csv file. The XML looks like this:
<Inventory>
<Item>
<Name>Super Mario Bros</Name>
<Count>14</Count>
<Price>29... | stackexchange/codereview |
How is this designed so far?
#ifndef LINKEDLIST_H
#define LINKEDLIST_H
#include <memory>
#include <iostream>
template <typename T> using ptr = std::shared_ptr<T>;
template <typename V>
class LinkedList
{
private:
class Node
{
private:
V data;
ptr<Node> next;
public:
Node() : n... | stackexchange/codereview |
I just created a naming convention analyzer + code fix based on the Roslyn platform. The implemented naming conventions are the following:
If you're interested in seeing all the test scenarios that have been covered, you can take a look here.
Some notes about the implementation:
Analyzers and code fixes cannot share ... | stackexchange/codereview |
I have written a function to take some shorthand input and expand it into the full form, for example a-z0-9 becomes abcd...789. I added protection from buffer overflow exploits (knocks on wood), and have covered (or think I have) all and any edge cases that the user could throw at it.
Are there any ways in which my cod... | stackexchange/codereview |
My below solution to the following problem is exceeding the maximum recursion depth. I am looking for any improvements which i can make.
Problem
Alice and Bob need to send secret messages to each other and are
discussing ways to encode their messages:
Alice: “Let’s just use a very simple code: We’ll assign ‘A’ the ... | stackexchange/codereview |
I am styling my react native component according to some conditions, here the code, The question is how do I make this cleaner? functional style?
const configColors = (isSingle, isDarkMode) => {
let colors = {};
if (isDarkMode){
colors = {
...colors,
configAxisLabelColor : Colors.white,
confi... | stackexchange/codereview |
I am trying to parse the command line arguments using argparse, and if the user specifies a yaml file for the config-file, add those arguments to the args from argparse
import argparse
import yaml
from pprint import pprint
class CLI(object):
def execute(self):
self.create_parser()
self.options = ... | stackexchange/codereview |
This is my first year at university, and I'm trying to learn everything about fundamentals. I've coded a snake game recently in C.
This is a programming-challenge that I've given to myself to practice arrays and pointers. I don't need a solution to my code because it works the way I want. I create a snake and its body ... | stackexchange/codereview |
I wrote a function to convert, without loss of precision, a mpfr - class value to a gmp bigq value. (This particular operation is not available in the R libraries Rmpfr and gmp, tho' there are functions to convert in the other direction). My code works but feels clumsy to me. Any suggestions to optimize?
mpfr2bigq <- ... | stackexchange/codereview |
As a second exercise with Scala I tried to solve another puzzle.
In this puzzle, we have to find the highest speed that allows a driver to cross all the traffic lights when they are green, without committing speeding.
Each traffic light is defined by its distance from the start and its duration. All the lights start gr... | stackexchange/codereview |
New Scala dev here. Is there a more idiomatic or efficient way to accomplish this in Scala?
Given a list of the following strings, I need to obtain the unique 'main parts' once any parts including and after a "-" have been removed.
The output should be a list of sorted strings. Also note both ";" and "," have been use... | stackexchange/codereview |
I want to simplify this process of creating map, putting markers on it according to Place objects from my database, creating info windows. Using egeloen/ivory-google-map library, I've written a facade for this proccess.
class PlaceMap
{
protected $map;
protected $templating;
protected $places = [];
p... | stackexchange/codereview |
So, I am learning Swift and as a little exercise I tried to implement a BruteForce algorithm. That algorithm is pretty simple however it is a bit slow too... Well, I am new to Swift, so maybe some optimisations are possible ?
Let's start with some useful prerequisites:
extension String {
var digits: String { r... | stackexchange/codereview |
I'm writing a tool, to manage our application, specifically to store passwords in encrypted view. I made a class which is based on two posts:
https://stackoverflow.com/questions/20852664/python-pycrypto-encrypt-decrypt-text-files-with-aes
and:
https://stackoverflow.com/questions/4102761/python-config-parser-cache-to-re... | stackexchange/codereview |
I am attempting to write up a program in Python that will find the shortest path between two nodes in 3D space. The actual domain is the EVE-Online Universe, which is composed of systems connected by stargates.
The input to my program is a list of systems, represented as Python dicts (JSON). I am trying to use the phys... | stackexchange/codereview |
In my Rails app, I have a form. The form has radio buttons for entity type and has a text field for SSN and another for EIN. Based on the radio button selected, one of the text fields will be disabled and the other enabled (disabled = false).
If the user selects the radio button for entity_type_i, it should disable th... | stackexchange/codereview |
I am supposed to take this code (that I made):
public void showUpdatedStatus()
{
if(((itsUsersNumber - itsSecretNumber) <= 2) && ((itsUsersNumber - itsSecretNumber) >= -2))
JOptionPane.showMessageDialog(null, "You're hot!");
if (((itsUsersNumber - itsSecretNumber) <= 6) && ((itsUsersNumber - itsSecretNu... | stackexchange/codereview |
Suppose path string are encoded in this way:
2T3T5: means move 2 steps, turn right, move 3 steps, turn right, and move 5 steps
32T: which better read as 3(2T), and it means do the following operation 3 times => (move 2 steps, turn right), if written in a complete word, it means move 2 steps, turn right, move 2 steps, ... | stackexchange/codereview |
Edit: the project was submitted, and I got a good grade! :D
I am finishing up a project for my computer science class. The project is a space invaders clone that uses the JavaFX library to provide graphics. The program itself is complete and functional, but I wanted to make sure that the code itself is readable and pro... | stackexchange/codereview |
To learn some PowerShell I made a tool, I've made before in bash. It pings the subnet for arp values and checks if there is no weird behaviour.
function IPv4toBin ($i){
$b = $i -split '\.' | ForEach-Object {[System.Convert]::ToString($_,2).PadLeft(8,'0')}
return $b -join ""
}
function Get-IPs($subnet)
{ ... | stackexchange/codereview |
I implemented two versions of a Fibonacci heap one using a unordered map (mapping keys to their nodes) so that the client can call decrease in \$O(1)\$ average and amortized time. The other one with a dynamic array of nodes and a maximum size for the same reason but in \$O(1)\$ amortize only. Both seem to be working fi... | stackexchange/codereview |
How can I simplify this code:
Public Class Form1
Private Sub BtnPositions_Click(sender As Object, e As EventArgs) Handles BtnPositions.Click
' 'txtSentence.Text = "The cat sat on the mat" ' Temp for testing
If TxtAddSentence.Text = "" Then
MsgBox("The text you are searching is empty, so there are no ma... | stackexchange/codereview |
I'm working in C# using PrincipalContext to do a check if user is part of security group for access to the site. Site is asp.net MVC and part of an internal network with security groups set up via active directory.
Currently load times for pages are about 2.5-3 seconds on first load and then about 1.4-1.5 seconds on su... | stackexchange/codereview |
I am trying to write a method that takes in a String and returns an Object. The catch is I want to parse it to one of a few different data-types, and if that fails, return the original String. I currently have the code below. Is this the best way to handle what I want or is there something obvious that I'm missing?
pri... | stackexchange/codereview |
I am very new to Selenium, and for my current project, I had the task of creating the automated test scripts for our website. I am the only one on my team who had any experience with Selenium, but not any in depth experience. I also didn't have a lot of time to spend on this, as I had other work to do, so I didn't spen... | stackexchange/codereview |
I've made the Game of Fifteen in Unity this is how it looks :
The code is rather short there's one class for the pieces and one for the game logic :
MovablePiece : MonoBehaviour
public class MovablePiece : MonoBehaviour
{
public PuzzleGrid.SlotPosition CurrentSlotPosition { get; set; }
private void Start()
... | stackexchange/codereview |
function transformXCoordinate(x, xOrigin, y, yOrigin, theta) {
return xOrigin + (x - xOrigin) * Math.cos(theta) - (y - yOrigin) * Math.sin(theta);
}
function transformYCoordinate(x, xOrigin, y, yOrigin, theta) {
return yOrigin - (x - xOrigin) * Math.sin(theta) + (y - yOrigin) * Math.cos(theta);
}
function compute... | stackexchange/codereview |
Below is my code. This is a function that will be applied as a sorting method to a grid based data set. The data in the column to be sorted can be stuff like: 123456, 123456:123444, and 12345:12359:139943. So far, I have tested it and it works, but I want to know in which situations might it not work, or if there is a ... | stackexchange/codereview |
I'm new to Python and want to develop good habits at the beginning. This class takes a string, and then counts the number of vowels and consonants in the word(s). Any advice on how to improve?
class CntVowels:
def __init__(self,string):
self.string = string
self.vowels = [ "a", "e", "i", "o", "u"... | stackexchange/codereview |
I have a bunch of functions that return promises and need to chain them together. However, it's currently difficult to read and I would expect it to be even harder to maintain.
I have a function that performs the following actions:
Logs off any inactive users.
Verifies a user's credentials.
Creates a session and logs ... | stackexchange/codereview |
I've written a function which takes as an input:
a string to be modified
a vector of regular expressions on which to match
a vector of replacements
option to ignore case in the match statements
The function will then, from the users perspective, simultaneously perform all replacements in a 'safe' fashion. By 'safe' I... | stackexchange/codereview |
Below is the code for my login page. I haven't really used MySQL (especially OOP) before, so I'd like to know if I'm doing something inherently wrong. The code is working as expected, but I don't trust my knowledge of SQL so much that I'd use this code publicly before asking someone to review it.
So please, tell me any... | stackexchange/codereview |
I want to create a factory to return all Source instances that match given entry parameters- that is, I want to iterate through some Collection of objects and for each entry check boolean method.
I thought about enum, as I'm guaranteed to iterate through them all.
I came up with something like this:
simple interface
p... | stackexchange/codereview |
So Stackoverflow Documentation has added "Contributor Breakdown". For any given topic (and example) people can display who contributed in which way.
That page is only available if you know the link though. And it's not linked publicly in any way. Since I like these hidden pages, but I keep forgetting the correct URLs ... | stackexchange/codereview |
I do a fair amount of scraping but I am by no way a good PHP programmer. I always struggle to get the innerhtml of elements using PHP, domdocument and XPath.
I have cobbled together a couple of functions that appear to do what I need but my question is are there any major holes in my logic or how can it be improved.
D... | stackexchange/codereview |
Given an unsigned integer \$N\$, I want to return \$P\$ with \$P\$ being a power of two such that \$P \ge N\$.
Examples:
1 -> 1
2 -> 2
3 -> 4
5 -> 8
The goal is to provide a very fast implementation. This code is supposed to target a specific platform and we can make the assumption that the intrinsics used are suppor... | stackexchange/codereview |
The task is relatively simple and until now it was always performed by some poor admin soul. There is a large table that needs to be filtered based on a simple criteria and each view has to be saved as a new spreadsheet.
The code is as simple as the task (and as my coding skills) so I would love to get some feedback a... | stackexchange/codereview |
I want to choose the implementation of an abstract class based on settings from a config file. Is this the proper way of doing that?
I am asking because I am having doubts about using std::make_unique inside the if scope. Will the object created with std::make_unique still be valid outside of the if scope?
#include ... | stackexchange/codereview |
I've got a complex object tree that I need to instantiate. The object tree is a bunch of specialized classes that don't have a common root object (other than Object) and has generic objects (that I need to configure), and custom objects (all the "My" classes in the example code).
I've created the factory below to encap... | stackexchange/codereview |
I've created a Timecode class. The "timecode" that I'm trying to represent is a timecode that is used in video editing quite often, and is seen displayed in the format "hh:mm:ss:ff", or 10:00:05:24, for example ("ff" = frames").
/// <summary>
/// Immutable timecode.
/// </summary>
/// <remarks>
/// Rep... | stackexchange/codereview |
This is my first attempt at Python. I started with some code from https://github.com/peliot/XIRR-and-XNPV (which aims to mimic the Excel function XIRR) and tried to 'improve' on it (and the Excel version). But I would like to know if in these few lines I already made beginner's mistakes. I'm particularly interested to ... | stackexchange/codereview |
What could I do better in my code or logic?
Wikipedia Search
$(function(){
$('.search-input').keyup(function(data){
var pesquisar = $('.search-input').val();
$('.box-logo').fadeOut(500, function(){
$('header').css('padding','12px 0');
});
$.getJSON('https://en.wikipedia.org/w/api.php?format=json&actio... | stackexchange/codereview |
I have a list of objects. These objects have a processname, amount and a date. I need every object to have all dates (if it doesnt exist add a new one with amount 0). So if I have 2 processnames: 'Inflate' and 'Deflate' and they have different dates: 'Inflate':12-01-2017 and 'Deflate': 13-01-2017. I need them to have t... | stackexchange/codereview |
I'm trying to retrieve a certain amount of data from a socket, both Unix domain and TCP, but I've no control over its format or length.
I discussed this with someone who told me to set my receiving buffer to a specific length, use async_read_some to read the first few bytes off the socket and then loop until the OS buf... | stackexchange/codereview |
I'm working on a tool to import data from one database to another. One requirement is that I have to split a string from one source field into three (shorter) fields at the target. If possible the string should be split at a space character. If the string doesn't fit completely into the target fields, the rest can be o... | stackexchange/codereview |
I started following Harvard's CS50 (Introduction to Computer Science) on edX, and as part of their Hacker edition set 1 was the following assignment:
I am supposed to write a program (in C), that takes as input a long long int from the user and proceeds to check whether the entered number is a valid credit card number.... | stackexchange/codereview |
I'm working on an RPG so of course I have to have some dungeons. I've got the dungeon generation working, with the output being a DungeonTileType[][].
Now I wanted to create the code for the player to be able to enter the dungeon. To do so, I created a Dungeon class that will hold all of the information necessary for... | stackexchange/codereview |
This is what I came up with when trying to make my first console game. I think it turned out quite okay so I wanted to know what you think about it.
If there is anything to improve, may it be coding style, readability, efficiency or anything else, please let me know.
main.cpp
#include <iostream>
#include <stdlib.h>
#in... | stackexchange/codereview |
I have a set of classes that have similar funcionality but very different interfaces. I created two interface classes with polymorphic methods so I can operate over then. When creating calling the methods, I have to pass a set of parameters, in this case a JSON file, that is also different for each class. Is there a wa... | stackexchange/codereview |
I'm working on a string manipulation code in C++ for my internship project, where I have to find a substring within a string and essentially replace it and some characters following it with a newly computed sequence based on other inputs (here, the string vector 'patterns'). I have been trying to find a better way to m... | stackexchange/codereview |
I'm currently working on an Android app and I need to translate keys of type String to Integers which are determined at compile time of R.raw.
Right now I have found two ways of creating such a Map that holds all (needed) values of R.raw:
private static final Map<String, Integer> map = ImmutableMap.<String, Integer>b... | stackexchange/codereview |
I have created this first-timer implementation of Merge Sort
and I got confused by the C++ syntax once or twice.
So I have some questions about this code:
#include <iostream>
#include <thread>
#include <cstdlib>
#include <vector>
#define NUM 1048576*2
int sort(std::vector<int>* vec);
void run(std::vector<int>* vec, i... | stackexchange/codereview |
So I need to update some certain values within text file based on actual values there. Any advice on making it more effective or just readable is appreciated.
Example text file:
Lalala
There is tons of text in this file log-12345sr
And somewhere within
There are log file names log-23456sr
Some more text here
I want ... | stackexchange/codereview |
I'm new to unit testing so maybe I have this all wrong, but it seems kind of useless. I want to reduce bugs and integrate some tests with a build process however I'm not seeing the benefit at the moment. How can I improve the quality of tests, like the one below?
/* script */
SetAttributes = function(el, attrs) {
/... | stackexchange/codereview |
I have tried to solve the following problem in C# with LINQ:
Given an integer array, find the most frequent number and it's count in the array. If multiple numbers have the same highest frequency return the smallest number.
One requirement here is also to make the code execute in O(1) space complexity.
public struct ... | stackexchange/codereview |
Today I tackled this coding challenge:
Given a circular linked list, implement a method to delete its head node. Return the list's new head node.
I would appreciate any feedback.
public ListNode deleteAtHead(ListNode head) {
if(head == null){
return head;
}
ListNode temp = head;
while(te... | stackexchange/codereview |
I'm filling a list of items from the database, which is taking extremly long time to run (Approx 60 seconds)
Here is the code with the relevant breakdown
97% of the performance issues come in the foreach loop at the bottom. Is there a better way to match list items on the nested object.
private List<ROPSetting> TestM... | stackexchange/codereview |
#define WIN32_LEAN_AND_MEAN
#include <stdio.h>
#include <string.h>
#include <windows.h>
#include <wininet.h>
const char thisVersionDate[] = "2024-01-05";
bool isMostRecentVersion(HINTERNET* hInternet, HINTERNET* hConnection, HINTERNET* hData) {
char currentVersionDate[sizeof(thisVersionDate)] = {};
*hIntern... | stackexchange/codereview |
I've got server running to make serial data available on a TCP/IP port. My goal is to collect data coming from a realtime device connected to the serial port and deliver it to web clients connected to an express server using socket.io as the data is collected from a backend socket. I want the backend socket to reconnec... | stackexchange/codereview |
On an Internet forum a person came with their homework, to write Arkanoid in a console - it seemed they wanted someone to do their homework for them so I did not respond. However, I found the task interesting, especially when I broadened the scope of the assignment - so I wrote such arkanoid for my own entertainment. H... | stackexchange/codereview |
I'm learning javascript objects and ES6 and made this dark mode toggle for TailwindCSS. I'd like to know what can I improve with this code below
'use strict';
document.addEventListener('DOMContentLoaded', event => {
// --------------------------------------------------------------------------
// App
let a... | stackexchange/codereview |
I have written a server-side and the client-side of a chat application. I would like to improve it and I am unsure about my server construct and have absolutely no idea if there is a better way to do it. I haven't found anything on Google, therefor I ask you. The construct I have used is from a tutorial from Oracle I f... | stackexchange/codereview |
I've written a method to check if a directory already exists on an FTP server. The only way I could see to make this work was to return a different result from the method if an exception is thrown - very bad practice in my opinion. Is there a better way to write this?
public bool DirectoryExists(string directory)
{
... | stackexchange/codereview |
I wrote a small program to address some assignment tasks related to making a game called 'Dice on a Yacht'. I sent the code to be reviewed by a company I was applying for, and I have not gotten the job (as I had expected shortly after submitting code and thinking over it further). I realize that I need to start prepari... | stackexchange/codereview |
I have a dataframe of cases that score 0-1 on a group of binary attributes.
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 attributes.
Usin... | stackexchange/codereview |
Please review for performance. and also naming convention
https://leetcode.com/problems/binary-tree-level-order-traversal/
Given a binary tree, return the level order traversal of its nodes'
values. (ie, from left to right, level by level).
For example:
Given binary tree [3,9,20,null,null,15,7],
3
/ \
9 20... | stackexchange/codereview |
Inverse transform sampling is a method to generate random values that follow an arbitrary distribution. For some reason this method was never implemented in any popular scientific libraries. And as I often need to use it, instead of calculating it by hands every time, I decided to implement the function doing it for me... | stackexchange/codereview |
I decided to try a hand at writing a simple state machine. The StateMachine class accepts any number of classes as template arguments, along with a base class. The classes act as states (a class so it can have permanent data), which have enter, exit and tick functions. The tick function can return nullptr to stay on t... | stackexchange/codereview |
The following code is a controller spec used in a Rails 4.2 application with RSpec 3.5. I would greatly appreciate your suggestions on how to improve it (e.g., efficiency, readability, maintainability, DRYness).
# spec/controllers/authors_controller_spec.rb
require "rails_helper"
RSpec.describe AuthorsController, :foc... | stackexchange/codereview |
I have a spinner in my activity that upon selection of one of it's options needs to handle the addition of a new object to my Sqlite database. the following solution works but everything in it looks like one big hack.
My layout:
<Spinner
android:id="@+id/spnMachineManufacturer"
android:layout_width="@dimen/et_p... | stackexchange/codereview |
I recently made a boggle solver in Rust to compensate for the fact that I'm really bad at boggle. This has also been a good Rust learning experience. The code does what it's supposed to quite well but it is a bit slow, even when compiling with the -O flag. Since I'm new to Rust, I'm not sure where the slow spots could... | stackexchange/codereview |
I needed to create a method that would sanitize DOM IDs based on the HTML 4 criteria (yeah, HTML 5 is a lot looser). Does this make sense? Did I get too cute with making it concise? Am I totally misinterpreting what a DOM id is? I presumed it meant something like <p id="annoying_paragraph"></p>.
def sanitize_dom_id(can... | stackexchange/codereview |
I made a simple routing class that I like to get reviews for, mostly because I do not know how to make it SOLID, since I even made this class separate from the HTTP response/request for the sake of SRP.
All this class does is route-specific, which seems like solid enough to me.
The actual library can be found at fastp... | stackexchange/codereview |
I am building a cypher program which uses a matrix of numbers and letters. A message is encoded according to the row and column each letter of the message is found in the matrix.
I am trying to find a nice way of iterating over the 2D matrix (6*6).
for char in range (0, len(message), 1):
for i in range(0, len(rows),... | stackexchange/codereview |
My question has to do with :
(a) Can this be made more secure?
(b) Are there best practices in relation to setting timezone?
(c) What best approach should be taken defining use of utf8?
$my_success = 0;
$my_message = '';
$my_id = 0;
try {
# declare & set variabl... | stackexchange/codereview |
I am totally new to PHP. I just wrote a PHP script for google oauth to pull the data and insert into my database. I don't know if my code is vulnerable to SQL injection. Should I have used prepared statements and should I rewrite the code?
index.php
<?php ini_set('display_errors', 1);
error_reporting(E_ALL ^ E_NOT... | stackexchange/codereview |
private String sort(String word) {
char[] content = word.toCharArray();
Arrays.sort(content);
return new String(content);
}
private boolean isPermutation(String s1, String s2) {
s2 = s2.toLowerCase();
if (s1.length() != s2.length()) {
return false;
}
if (s1.equals(s2)) {
r... | stackexchange/codereview |
I wrote an encryption/decryption algorithm for the Caesar Cipher. It works fine, but I'm curious if there are any constructive critiques, tips, tricks, comments, or advice anyone may have on how the code operates, performs, looks, etc.
# Caesar Cipher
def chooseMode():
while True:
mode = raw_input("\nChoose... | stackexchange/codereview |
This may seem a little small, but it's actually a self-contained crate in my project.
This crate contains definitions for the source tokens in the language I'm working on, Nafi. As of current, it's definitely quite minimal, because I learned from an earlier attempt that I want to move in small chunks up the full tree t... | stackexchange/codereview |
Problem: User inputs a word or phrase as command-line argument and a new word is printed with some vowels replaced by numbers.
Question: How do I improve my code design and style? Is it possible to not have to repeat x[i] == '…' in my if statement?
#include <cs50.h>
#include <stdio.h>
#include <string.h>
string replac... | stackexchange/codereview |
I made this piece of code as first step for a bigger project to iterate and manage bookmarks: open, rename, place in new folder structure, or delete each one of them. This first step is a parser to get a useful json file with the structure and data of each bookmark and folder. I've usex regex instead of beautifulsoup t... | stackexchange/codereview |
I want to construct a form builder for an internal project in mvc4. I am using partial views to load the various controls. However I feel that having ten or 20 action-results in my HomeController would not be the best way to go.
So I am wondering how I could do the following more efficiently.
As you see here I have thr... | stackexchange/codereview |
Practicing Prototypal Code
I'm focusing on practicing a very prototypal structure with my code (non library oriented) to begin learning to reuse large portions of my application infrastructures where applicable in future projects. With this in mind, I don't have experience with prototypal programming before now, and wo... | stackexchange/codereview |
I am solving problem GRAVITY on SPOJ. Each test case is a rectangular ASCII grid of dimensions m × n, and you have to determine whether it is possible to find a path from the 'S' square to the 'T' square, moving using the space squares and avoiding '#' obstacles, in at most O steps (diagonal steps allowed).
I am using ... | stackexchange/codereview |
From a sorted vector of indices (toRemove), I would like to remove from another vector (v) the elements at these indices. Note that I need to preserve the order of the remaining elements in v. toRemove can be modified at will however.
An easy way to do it would be to start with the last element of toRemove and remove t... | stackexchange/codereview |
I am coding on codingame.com, where one of the 'easy' challenges is to assign MIME type strings to input strings of file names based on their extensions.
My code passes four out of five of the test cases, and the last one is an optimization test. A big data set is inputted, and my approach times out.
I started coding ... | stackexchange/codereview |
I've made a function to print all paths from root to all leaves in a binary search tree. I already have an insert function, which I haven't included in the code here as I felt it was irrelevant to the question. However, assume that it works. The code provided does produce the correct results. However, is it optimal? Is... | stackexchange/codereview |
I have been trying to find defects (brown/copper parts) on this sample using PyQt, OpenCV and Python:
And I can find defects, too. My problem is, I have nobody to ask, get feedback etc. I need some feedback about my code. Of course, I don't want someone to review my code line-by-line, but even a simple reviewing would... | stackexchange/codereview |
I would like to do the following:
I have a list data of 3-tuples that I need to go through, for each tuple base_tuple I want to know the index index_max of the maximum value held in base_tuple and replace base_tuple with a new 3-tuple new_tuple that only holds 0s except for the value at index index_max which is set at ... | stackexchange/codereview |
I have written code using Python for Fully Constrained Least Squares (FCLS) Linear Spectral Mixture Analysis, which could be applied for unmixing multispectral image successfully.
However, the operation efficiency is very low, taking about 2 hours for each MODIS image (rows: 1620, columns: 3024, bands:7, blocksize: 512... | stackexchange/codereview |
This is a very simple clone of Flappy Bird using Kivy, to be used for programming class for teens. The game consists of 3 classes: Bird, Game, and ResetBtn.
Q: How to make it more efficient, clean, and clear for the students? (without using kv file)
Code Explanation:
The Bird class inherits from Image class, a Clock... | stackexchange/codereview |
I've written a tiny function for asking questions intended for my POSIX shell scripts, where I often need user input.
The function takes 2+ arguments, where:
Is a string containing the question.
, 3., ... = arguments containing the right answers (case insensitive)
I also changed my style by a bit, no longer use ${var... | stackexchange/codereview |
I've been playing around with writing a simple static blog generator in Haskell (mostly for experience, since there's probably more than a few already made choices that fit my needs). I don't have very much experience with functional programming, but I've been doing a lot of C++ lately, so using typeclasses as "interfa... | stackexchange/codereview |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.