instruction stringlengths 71 71.9k |
|---|
For the sake of training my vanilla JS skills I've decided to make a simple ToDo list with the following features:
Tasks can be added with a priority (higher the number - higher on the list)
Counter tells how many tasks are left to be completed
The "delete" button deletes the according task whether it's completed ... |
This is my implementation of pricing an exotic option (in this case an up-and-in barrier option) using the Monte Carlo simulation in Python. I use NumPy where I can. Any ideas to optimize this code?
################################################
# Exotic Barrier Option (up-and-in) Pricer
# By: DudeWah
##############... |
This is written to find percentages of three subjects. Original HackerRank practice problem is here.
Input Format
The first line contains the integer N, the number of students. The next N lines contains the name and marks obtained by that student separated by a space. The final line contains the name of a particular ... |
I've recently begun a project in digital signal processing and am using C++ as the programming language. In this project, I have implemented several finite impulse response (FIR) filters. Many of these FIR filters have the same interface, but are implemented differently depending on what can be optimized. To remove the... |
I developed a script to transform a Japanese word in Furigana thanks to the jisho website. But the code is very ugly, especially the extractHiraganaFromHTML and filterBetween functions. What kind of improvements are possible?
module Main
where
import Network.HTTP
import Network.URI
import Text.HTML.TagSoup
import Data... |
I'm considering how to refactor code to make it clean & clear.
There are some principles to make code clean; in this case I think it's Single Responsibility and One level of abstraction.
The original code is like this:
for (int i = 0; i < header.length; i++) {
if (header[i].equals(Constant.ID)) {
indexOfID = i;
... |
I am writing a program that reads from DB and outputs to a CSV file. Besides the regular columnar data there are 2 JSON fields data as well. The table layout looks like this (other fields removed for brevity):
+----+--------------+-------------+-----------------------+
| ID | Product_Type | Json_Data | Demographic_Qu... |
I'm new to multithreading in C so I made a toy program that uses a mutex and a conditional variable to communicate between two threads. do_work performs a task every 1 second (task could take longer than 1 second). Is this implementation free from deadlocks and race conditions? Anything else I might be missing?
#inclu... |
This sample code is correct and no error however this only good if you only have few hundreds or thousand datas but if you have million queries this takes time how we can improve this algorithm
namespace :auto_status do
desc "Add Status to the Tracking code Automaticaly"
task make_status: :environment do
... |
I was trying to sort a massive file of successive chars in C. I did some research and found a few file sorting algorithms that look the same. Their main idea is to read an amount of data to memory, sort them using one of classic sort algorithms, write them to a new file, then repeat the process and merge the two files ... |
The problem is from the cracking coding Interview programming book.
The problem is that:
Sort Stack: Write a program to sort a stack such that the smallest
items are on the top. You can use an additional temporary stack, but
you may not copy the elements into any other data structure (such as
an array).
Below ... |
My company is cheap but wanted a way to pinpoint bandwidth on certain computers. Me being a programming guy came up with the following small program. I just wanted some expert opinion on my code. I am especially interested in you opinion on how I usually pull permanent variables. I usually put these variables in a ... |
I'm working on a DSL for web development, similar to sinatra. The git repository is here. I've been attempting to improve this code and write it for 4 months, and as a hobby programmer, I would like to have an evaluation of general readability/maintainability, and any ways I could more logically split up my code into f... |
I made a game in python, where the objective is to catch a 'turtle'. The controls are the arrow keys.
#Catch the turtle
import turtle
import math
import random
score = 0
print ("\n" * 40)
print("Your score is:\n0")
#Title
t=turtle.Pen()
t.pencolor("Blue")
t.hideturtle()
t.penup()
t.setposition(-70,350)
t.write("Catc... |
I have this function that allows the user to supply a number and that many rows are appended to the existing table:
$('#add-row').click(function() {
if($('#insert-rows-amnt').val() < 1) {
alert('Please enter number of rows to insert');
} else {
for(i = 1; i <= $('#insert-rows-amnt').val(); i++) ... |
I've written some code to tokenize a command string into its tokens.
A token is either:
A block of any non-whitespace characters
A block of characters, which may include whitespace, wrapped in quotes
So, for the input:
This is some text "with information" quoted.
I'd expect the tokens:
This
is
some
text
with info... |
I wrote a program to automatically optimize my Brainfuck source files. It works well, but the optimizations are only trivial ones and probably there are still some other points to improve.
def main():
print "Enter the path of a brainfuck source file you want to optimize"
path = raw_input()
if path in ('exi... |
does someone has any opinions about this SafeBox StateMachine?
import java.util.Scanner;
public class SafeBoxStateMachine {
public enum SafeBox {
ACCEPT{
private Scanner scan;
private boolean askPassword(SafeBoxStateMachine safebox){
System.out.println("Pleas... |
I have this plugin that I have finally finished the big pieces of, there's one or two minor details that are not yet implemented do to lack of a decision yet but everything else is there.
I wrote it and can follow fine but I feel it reads very haphazardly. Could someone with fresh eyes help me make this into a more pro... |
From SICP
Exercise 1.45:
We saw in 1.3.3 that attempting to compute square roots
by naively finding a fixed point of x/y does not converge, and that
this can be fixed by average damping.
The same method works for
finding cube roots as fixed points of the average-damped x/y^2.
Unfortunately, the process does no... |
This is a battleship console game I wrote in C++.
#include <string>
#include <iostream>
#include <process.h>
#include <cstdlib>
#include <time.h>
using namespace std;
int const ROW = 3;
int const COL = 3;
int subX, subY;
int guesses = 5;
int board[ROW][COL];
bool hasWon = false;
void winScreen()
{
cou... |
I am very new to coding and really started a few weeks ago for a new job I have. out of necessity, I am slowly learning VBA (which I can't say is very easy...) I started by recording macros in Excel and copy/paste bits of VBA codes from the internet. A good chunk of them came from SO, which prompted me to join and try ... |
It make sense to not allow links to external code hosting, so I restated my question. This is classical cons list in python using Abstract Base Class interface. Constructor is in fact out of the Cons class, but I didn't see the way to put recursive code inside init.
# immutable, cons list and few methods
class Nil:
... |
I'm reading an array (of unknown length) of modules package.json files in order to extract the "style" property and store it in an array of its own:
var gulp = require('gulp')
, path = require('path')
, Promise = require('bluebird')
, fs = Promise.promisifyAll(require('fs-extra'));
let components = [
'comp1'... |
I have recently been getting into the habit of leveraging the revealing module pattern for all my code. I used this guide for inspiration, but my code doesn't feel as elegant.
var styleGuide = (function styleGuideHandler() {
'use strict';
var publicAPI,
intervalId = null,
clipbo... |
I'm solving some puzzles to learn Rust. A problem I faced is to turn a string of 3 integers into 3 integers. I succeeded with the following example:
fn main() {
let mut it = " 455 123 42 ".split_whitespace();
let (a, b, c) = match (it.next(), it.next(), it.next()) {
(Some(a), Some(b), Some(c)) =>... |
I've made a short program to determine if a string is permutation of another string.
Example input/output :
a) 123, 112 <- False
b) 123, 321 <- True
c) 112, 121 <- these don't count as permutations since they have duplicate characters
private static void Main()
{
string a = Console.ReadLine();
... |
In (this) Poker you have 2 hole cards that are combined with 5 shared cards on the board. Each player makes the best 5 card hand from the seven. Believe it or not that is over 2 billion runs to do them all.
I'm trying to create statistics for 2 known hole cards against random boards and random hands for a single oppone... |
I am looking for ways to improve the code that I wrote for this.
Consider a simple vending machine class. The machine accepts tokens
and dispenses cans of refreshing beverages. Write a complete class (on
the next page) as described below:
The class has two instance data fields; one to keep track of the number of ... |
Is this a good solution for FizzBuzz? What can I do better?
for num in range(1, 101):
if num % 3 == 0:
if num % 5 == 0:
print("FizzBuzz")
else:
print("Fizz")
elif num % 5 == 0:
print("Buzz")
else:
print(num)
|
I am quite an experienced developer but I am quite new to JS/frontend/functional programming and I am working with react-native in my day-job now.
I'm trying to do my own flux implementation to better understand redux. My goal is to have a performant data store that will behave predictably. This solution seems to be wo... |
I'm a novice programmer going through the Odin Project. I just finished up building a command line Tic Tac Toe game and I would appreciate some feedback on object-oriented design, methods, verbosity, etc.
Here is the code for the main menu/high level game control:
require "./game.rb"
require "./player.rb"
require "./... |
I need to create a phone directory with given inputs, then I need to
query the dictionary for unknown number of given keys, if not found,
print Not found. Link of Original HackerRank Problem here
I have written this code in Python3, and it's working fine. Please review, and suggest other ways of taking unknown nu... |
Here is the problem, any advice about code improvement, more efficient implementation in terms of time complexity, functional bugs, etc. are appreciated.
Given an unsorted integer array, find the first missing positive
integer.
For example,
Given [1,2,0] return 3,
and [3,4,-1,1] return 2.
Your algorithm should r... |
Problem statement
Given a matrix (up to 300 × 300), rotate each element R steps anti-clockwise along concentric rectangular paths (R up to 109).
The algorithm is rated as hard on HackerRank.
On April, 2016, I wrote the algorithm with a bug, scored 8 out of maximum 80 points. I could not find the bug after hours wor... |
I want to skip validations based on attributes. If certain attributes are not in form so I do not want to validate them.
Currently, if I post them from one form which has 1 field, it still validates other 9 fields and show me errors that it cant be blank.
If I check from big form which has 10 fields, it passes successf... |
I just have started to introduce myself into network programming using C++. So I started with Winsock. The code I made is compiled with MinGW and works perfectly!
As a beginner, the main purpose of code was to do what I wanted. Now it's time to go to next level!
The program will download a webpage source using a given ... |
The code below takes two command line arguments, an absolute folder path and integer, which is the minimum number of qualifying photos in each folder required to return a positive search result.
Saves/prints to screen a dictionary containing the path of the photo containing folders and the paths of the images within ... |
I want to allow anyone that has never coded to make classes depending on my template with little to no knowledge of Python.
These classes need to do 2 things:
Inherit from other classes similar to them.
Contain variables, updating values if they have been changed or keeping them if not.
For the sake of simplicity I d... |
I have gone through all steps to optimize the code, deactivating screenupdate, deactivating calculation, events, and pagebreaks removed the unnecessary selects, adding constants, and etc. However, I don't think my algorithm for coping is the best one, even if it is probably the simplest of them all.
For Each cell In cu... |
A version of CGOL made in Python using the turtle module.
Any suggestions for optimisations or improvement:
import time
import turtle
import threading
wn = turtle.Screen()
t = turtle.Turtle()
t.penup()
t.speed(0)
t.ht()
mode = int(input("What mode do you want to use to get the initial state? (1 - from a .cgol file,2 - ... |
I have written this code in C# and have tested this code to ensure it works well. Any other suggestions for this code would be appreciated as I have a number of users who are sending data on this port.
private Socket serverSocket = null;
private List<EndPoint> clientList = new List<EndPoint>();
private byte[] byteData ... |
This is my implementation of calculating CRCs which supports arbitrary polynomials specified in different representations (according to the explanations given here and here).
My concerns are:
I don't like the weak typing (having to supply the numeric value and its size for both the data and the polynomial; possibility... |
Awhile back, I wrote a quick and dirty webapp to read the remote server's log files, without a user needing to ssh in to view it via command line. It's meant to be a quick and dirty tool since we don't have anything like logstash available.
I am rewriting in Java 8 and have used the Streaming API to remove about 60% of... |
I have this code but it takes over a minute to run. I'm looking at around 400 entries being brought back for the first loop. Any ideas on how it could be improved for speed?
<?php
$context = stream_context_create(array(
'http' => array(
'method' => 'GET',
'header' => "Authorization:... |
I have created a basic login system that asks the user for a password. Here's a list of what it does:
When you run the code it will open an Inputbox asking you for a password.
There is one criteria: You have to enter a password of 8 characters. If you enter a password with less or more, it will give you an error messa... |
I´m working on trying to get the n most frequent items from a pandas dataframe similar to
+----+-----+-------+------+------+------+
| cod| name|sum_vol| date| lat| lon|
+----+-----+-------+------+------+------+
|aggc|23124| 37|201610|-15.42|-32.11|
|aggc|23124| 19|201611|-15.42|-32.11|
| abc| 231| 22... |
I am a beginner with Erlang and currently making my way through the awesome Joe Armstrong's book. The following are my answers to exercises 5 and 6 for the concurrency chapter. The code can probably be much better but at least it seems to work fine after some tests. I'm just happy to be able to understand this language... |
I have some code that I posted as a possible answer on StackOverflow (and the code I post here is almost an exact duplicate of that, but I'd rather include complete information in this post as well so people don't have to jump back and forth between posts to understand the question). I truthfully haven't quite decided ... |
CustomClass.class
Description
The CustomClass is created with init(), which returns a CustomBuilder saving both as static fields.
public class CustomClass {
private static CustomClass customClass;
private static CustomBuilder customBuilder;
public static CustomBuilder init(){
customClass = new Cus... |
I've written a function that searches for the nth occurrence of a character in the given string. A positive value for n will search from left-to-right, while a negative value will search from right-to-left. Zero is not a valid value for n.
Left-to-Right Search
"AABAXYAMN".NthIndexOf('A', 1) -> 0
"AABAXYAMN".NthIndexOf(... |
I am looking for ideas how to improve this cucumber scenario (testing a REST interface) and make it more concise.
Feature: Get list of Logbooks
As a client, I want to get a list of a certain users logbooks so that i can present
the logbooks name and the number of scuba dives to the user.
Scenario: Get a list o... |
I wanted to represent graphs in Python, and wrote the following class. I don't care about values associated with nodes or the weights of the connections between them, simply the connections between nodes.
Is this a good enough implementation? Or is there a significantly better way?
class Graph:
def __init__(self, n... |
While the task at hand is relatively straightforward, it turned out AES in Go is a bit clunky so I was wondering if this seems right. Also, any tips on Go coding in general are more than welcome.
// Package aesjson provides a function to encode an object to JSON and apply
// AES encryption to it.
package aesjson
impor... |
Word Wrap problem in short:
Given n words and a line length, break the words into lines in such a manner that minimizes the sum of the costs of all the lines. Consider the cost of each line being (free space in the line)^2.
I'm supposed to implement an algorithm with \$O(n)\$ time complexity and \$O(n^2)\$ space com... |
I implemented a script for a LinkedIn user to connect with all profiles on a LinkedIn search page and move to the next one automatically.
As I am a new javaScript programmer, could someone look at my code and tell me how to write better code?
// Every 1 second, click all the connect buttons on the result page
window.s... |
I am teaching myself JavaScript and made a little Tic-Tac-Toe web app. I'm not asking anyone to read through it all, but to just tell me what I need or should not do in the future.
var boxes = document.querySelectorAll("td");
var boxtext = document.querySelectorAll("td span");
var player = document.querySelector("#pl... |
Notes:
I know \ are against PEP8; they are for readibility
I created this working through a tutorial
I forgot to add blank lines, so it may be a little squished
''' Tic-Tac-Toe Minimax Program by Peter'''
#Tutorial found at: http://giocc.com/concise-implementation-of-minimax-through-higher-order-functions.html'''
... |
I ask because it seems to be taking waaaay more space/time than it should. Also, I know that if I want to be super efficient I should use Java's BitSet and a Sieve of Eratosthenes, but I wrote it like this to compare to a friend's implementation in C#.
(defn primes-upto [n]
(let [primes (transient [2 3])]
(loop [... |
This is a simple real state based markov chain (I'm using real states instead of a markov matrix to enable making an animated version later).
My goal was to make the markov chain as generic and reusable as possible, while practicing using smart pointers.
What general coding style, performance, semantic, or functional i... |
It is just a simple piece of C code that generates random lenght random HEX srings. Any ideas how this code can be improved?
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define MAX_SIZE 256
int main() {
time_t t;
srand((unsigned) time(&t));
const char* digits = "0123456789ABCDEF";
unsig... |
I have started this project basically for learning perspective and wanted to learn good object oriented design. What I am trying to do is making clone of something like this but this is a command line version.
There are lots of bits and pieces of this application that I would like to be reviewed in detail.
Separating ... |
I am a novice coder and I am very new to algorithms. Something about my code leads me to believe that it is unnecessarily verbose and/or inefficient. I am building a command line Mastermind game, and part of the project is to provide feedback for a user's guess. In the game, the codemaker creates a secret code with fou... |
Problem statement:
https://www.hackerrank.com/contests/ncr-codesprint/challenges/spiral-message
You've intercepted an encoded spy message! The message originated as a
single line of one or more space-separated words, but it was encoded
into an matrix as a clockwise spiral starting in the lower left-hand
corner. Fo... |
It's a very simple question, but I wonder if there is a more pythonic way to add each previous elements in a list like this (for example with a list comprehension maybe) :
input : L = [4, 2, 1, 3]
output : new_L = [4, 6, 7, 10]
Which I've done this way :
def add_one_by_one(L):
new_L = []
for elt in L:
... |
Requirements:
Must convert a double to a string, without losing any digits.
Cannot use scientific notation.
In C#, no format string exists that you can you pass into Double.ToString(format) to accomplish this, because ToString will use only 15 digits, even though a double can have 17. Although R and G17 can use 17 di... |
I have made a program to calculate the amount of flour, eggs, sugar and butter required for making lemon cakes and cupcakes.
import math
cupcake = [4, 0.1, 12, 14]
#[Butter, egg, flour, sugar]
lemon = [80, 4.5, 240, 300]
#[Butter, egg, flour, sugar]
cup_in = int(input('How many cupcakes would you like? '))
lem_in = i... |
Can you just shoot me some ideas on how to better structure the program and also if you notice any big no-nos at first glance? This is certainly not production code, it is my first attempt at a data structure implementation in C, which I am also new to. One thing I am aware of/will structure differently next time is th... |
I'm trying to write a function that returns the number of bits set in a 32-bit integer in VBScript, it's just for practising the language. The function I've written so far looks okay, but I'm wondering if there was a simpler solution.
Function countBits(value)
Dim n : n = 0
Dim mask : mask = 1
Dim i
For i = 0 t... |
This is just a simple median calculator that calculates the median for a given array/list.
def median(lst):
nl = []
nl = sorted(lst)
e = int(len(nl))
if e % 2 != 0: # True if odd # of #'s
ind = int(((e / 2.0) - 0.5)) # index of the median
c = nl[ind]
print c
else: # even # o... |
Problem - The classic puzzle of finding the minimum amount of time required to cross a bridge given that only two people can cross the bridge at any one time.
Since they have only one flashlight (it's dark and they need the flashlight), the two people move at the speed of the slower one.
Constraints - Upto 6 people (al... |
A working example of mine, trying to streamlining my Django views, with absolute inspiration from Laravel:
class BaseController(View):
template_404 = "404.html"
def __call__(self, *args, **kwargs):
return self.view(*args, **kwargs)
def view(self, request, slug=None):
method = request.metho... |
I was told to use the following Rabin algorithm to find the shortest distance between 2 points in 2D:
Randomly choose sqrt(n) and brute force to find the closest distance in this set. Let this distance be delta.
Make a delta grid on top of all n points, which partitions all n points into different bins/buckets.
For ea... |
I'm a beginner C programmer. I want to write a program with the following characteristics:
The program is essentially a 'daemon' or a 'service' that sits in the background doing nothing except maintaining a variable value in memory.
Once a program that queries the saved values is executed, the background program shoul... |
I'm just looking for some feedback:
import javax.swing.JFrame;
import java.awt.Color;
import javax.swing.JComboBox;
import javax.swing.JPanel;
public class Clock extends JFrame {
public Clock () {
setContentPane(new ScreenSaver());
}
public static void main(String[] args) {
Clock clock ... |
I have a list of tuples which may vary in size quite significantly. Typical number of tuples in the list would be somewhere around 100.000. I am trying to perform a down-selection on these tuples to end up with a more workable amount of them.
Each tuple contains (among other insignificant for this example data) an inte... |
This code gives the solution to Part 1 of this question:
http://adventofcode.com/2016/day/9
Summary: You have to find the length of the input string after using the markers to duplicate parts of it. A marker is enclosed in parentheses and contains two numbers separated by an x. The first number is the number of followi... |
There can only be better ways to do this?
create strings for today's directory
strDate is yesterday's date in format ddmmyyyy (e.g. 08122016)
DateStr is yesterday's date in format yymmdd (e.g 161208)
strDate = '{d.year}{d.month:02}{d.day:02}'.format(d=datetime.datetime.now()- timedelta(1))
strDate = str(strDate)
da... |
Google FooBar came up a few days ago and I took it as a challenge to learn python quickly while having fun. However, I ran into one challenge today that has left me stumped, I've come up with a solution that finds the correct result, however it is not fast enough for some test cases. How can I improve upon it?
Queue T... |
Amongst the lesser-known unstable sorting algorithms is the QuickXsort family of algorithms, as described in QuickXsort: Efficient Sorting with n log n - 1.399n +o(n) Comparisons on Average by Stefan Edelkamp and Armin Weiß. This family of sorting algorithms tries to exploit the technique of internal buffering that we ... |
I'm evaluating the security level of a file encryption app, which implements Scrypt and Inferno, in an ECIES context. The encrypted files are either stored on the user's PC/laptop, either sent with gmail. I must reach a security level appropriate for files containing sensitive data like credit card number, medical info... |
I wrote a Chrome extension that lists upcoming concerts for the next seven days, this month, and next month. I had trouble with the nextSeven() method, especially transitioning from dates like Dec. 31st to Jan. 1st, hence the really fugly if-statements. I was wondering if anyone had any advice to make the code more con... |
I'm writing a scripting language and I'm trying to implement a dynamic number type in C++. Right now, I'm only interested in getting long doubles and long longs working right. I was able to get this contraption to work. I would like to know if there's an easier, more organized idea than mine.
I don't want the class to ... |
Can my code be reviewed by common C++ formatting standards, and can it be optimized? My code determines if the number (x) you input is greater then the other number (y) you input, the code then prints out the results.
#include <iostream>
#include <stdio.h>
using namespace std;
int oper();
int main() {
oper(); ... |
I'm just learning functional programming in JavaScript using Ramda.
I took this tutorial and implemented the server core.js component using Ramda.
The idea is that we'll have a collection of things to vote from: Movies, songs, programming languages, Horse JS quotes, anything. The app will put them against each other i... |
This code invokes a function for every 40 seconds inside a loop. I am doubtful about this condition:
if ((time_left <= 0 || time_left > interval))
Is only checking (time_left <= 0) fine? I referred to some websites and they have also added a check for time_left > interval. Is this check required?
int print_timed_op(... |
For the past few weeks, I've been using the wonderful cJSON to add content to my game. But recently, I got tired of JSON's verbosity so I decided to roll my own format called SON (Simple Object Notation). I plan on using this format in all of my future game projects.
rogue
anim
timer 0
brain
typ... |
This program calculates wood length and area of glass required for the window.
I am a beginner in C# and I want to know how professional programmers will write program like this.
double width, height, woodLength, glassArea;
const double MAX_WIDTH = 5.0;
const double MIN_WIDTH = 0.5;
con... |
I started picking up Rust on my free time, and I'm curious about what style errors have I made and where should I improve as a programmer.
The problem is from HackerRank and very simple: there is a fixed-format input of time in 12 hour format (07:05:45PM), and the objective is to convert it to 24 hour format (19:05:45)... |
EDIT 1
Changed code to PEP8
My task is to create custom script to control PTZ (pan-tilt-zoom) cameras. We have an application for video surveillance but problem is that some functions are missing, like speed zoom out. Also, some cameras loses focus etc.
My idea is to create appindicator to control cameras from there.... |
This question is part of a series solving the Rosalind challenges. For the previous question in this series, see Calculating protein mass ruby. The repository with all my up-to-date solutions so far can be found here.
I started the Rosalind challenges roughly a year ago in Ruby. Now I got curious whether I could do th... |
This is my first go at a Go program that's not a variation of "Hello {$name}". It's about twice as long as my previous Python implementation, and perhaps an order of magnitude messier.
The goal is to read in /etc/hosts and combine the various entries I've made over time:
127.0.0.1 host1.test
127.0.0.1 host2.test
111.11... |
I currently have the following code:
unsigned int symToZ(const std::string & sym){
unsigned int atomicNum;
if(sym == "H"){atomicNum = 1;}
else if(sym == "He"){atomicNum = 2;}
else if(sym == "Li"){atomicNum = 3;}
else if(sym == "Be"){atomicNum = 4;}
else if(sym == "B"){atomicNum = 5;}
else if... |
Please check the code to see if there anything I can improve .
Everyting is working as expected.
matrix.h
#ifndef Matrix_h
#define Matrix_h
using namespace std;
class Matrix
{
private:
int rows;
int cols;
int **Mat;
public:
Matrix (const int &rows,const int &cols);
Matrix(const Matrix &other);
~... |
This is a simple tool to parallelize execution of multiple tasks in Bash, since env_parallel can't handle the environment size (or something of the sort - dies for mysterious reasons.) I'd love to hear your critique.
#
# Simple parallel executor. Takes a list of commands and executes each in its own child process. Ass... |
To learn Go I decided to write a vowel/consonant counter. I really need tips/ideas on how I can improve my code.
package main
import (
"os"
"bufio"
"fmt"
)
func isVowel(x string) bool {
vowels := [5]string{"a", "e", "i", "o", "u",}
vowelLookupTable := make(map[string]bool)
for _, v := range vo... |
I have implemented Dijkstra's algorithm using a slightly modified version of the structure and class posted here. Unfortunately, I have ruined the efficiency. I am intent on using this structure. I will NOT use BOOST. Any STL algorithms are acceptable.
#include <iostream>
#include <vector>
#include <map>
#include <stri... |
For part of a project, I was given this directive:
The “ls” command will require you to use directory functions to list
out what the filenames are in the directory. Functions required to
make a “ls” command work are included in the <dirent.h> header file (
man dirent ). You will need to open a directory and iter... |
I have taken advice on board and had a go at a new project, to write a program that lets you play the card/dice game, Machi Koro. The complexity of the game isn't too great, which makes it a good target.
What I would like reviewing is the first "real-world" class I have created, the Establishment. There are many differ... |
Looking for a general review.
pub struct BitVector {
bits: Vec<u8>,
size: usize,
}
impl BitVector {
pub fn new() -> BitVector {
BitVector {
bits: Vec::new(),
size: 0,
}
}
pub fn push(&mut self, bit: bool) {
let leftover = self.size % 8;
if le... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.