instruction stringlengths 71 71.9k |
|---|
This problem is taken from the book Introduction to Algorithms, Third Edition
By Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest and Clifford Stein:
We define the Josephus problem as follows. Suppose that n people form
a circle and that we are given a positive integer m <= n. Beginning
with a designated ... |
I'm trying to randomly shuffle an collection of integers within a List and I have came up with two shuffling method that does the job. However, I'm not sure which one works better. Does any one have any comments or suggestions?
public class TheCollectionInterface {
public static <E> void swap(List<E> list1, int i,... |
I have a project that is due for my Intro to Java course which requires me to translate the number range of 1 - 3999 into Roman numeral form. If the number I pick is 0 it will end my program, anything else that is below 0 or above 3999 will result in a loop until the requirements are met. I have completed my code and w... |
Not sure how to make the title smaller. I was reading the question A truly amazing way of making the number 2016 and some of the answers referred to programatically determining the answer set.
What I am doing is related to that in concept. Given a range of number 1 to X determine all possible mathematical expressions ... |
I don't want to use synchronized for sizeof method, any suggestion to implement the method thread safe?
package com.r.collection.adt;
import java.util.concurrent.atomic.AtomicReference;
public class ConcurrentStack<E> implements Stack<E>{
@SuppressWarnings("hiding")
private class Node<E>{
public E ... |
I know my algorithm is very naive and slow for this problem. I would like to learn how to improve upon it?
import java.util.Stack;
/**
* Created by mona on 3/12/16.
*/
public class ValidParanthesis {
public static boolean isValid(String s){
char[] charArr=s.toCharArray();
Stack<Character> s1= new... |
First time posting to Code Review. Just looking to get some advice on how I can write better code.
I found the following exercise for a "Guess my Number" game on DaniWeb, but the linked source code file is no longer active. So while I know my code works, I'm not sure if I've written it in the best way.
"The computer r... |
I've been learning C# for about a month and have a finished game. I would like some constructive feedback on my progress so far.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using... |
I have a page with a few options that the owner of a site needs to be able to set. He's not a coder and I'm trying to make it as user-friendly as possible.
It works, but my implementation feels sloppy and I was wondering if there's a better way to do it.
This first part from my main javascript file will be minified and... |
The Scenario
You are given a matrix of size m x n (width x height) with m*n spots where there are a few obstacles. Spots with obstacles are marked as 1, and those without are marked as 0. You can move vertically or horizontally, but can visit each spot only once. The goal is to cover as much area/spots as possible, avo... |
(See the previous and initial iteration)
Now I have refactored the code in order to conform to the suggestions made in the answers to the first iteration. I have this:
toyvm.h:
#ifndef TOYVM_H
#define TOYVM_H
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
enum {
/* Arithmetics */... |
I will design a list with a Font-Awesome design arrows.
My code already works fine, but I will improve it.
ul.long_arrow_right_red,ul.long_arrow_right_gold {list-style: none;}
ul.long_arrow_right_gold li:before {content:"\f178"; font-family: FontAwesome;display: block;float: left;width: 1.5em;color:gold;}
ul.long... |
I was inspired by a certain recent question to try my hand at this challenge:
Project Euler #34: Digit factorials
\$19!\$ is a curious number, as \$1!+9!=1+362880=362881\$ is divisible
by \$19\$.
Find the sum of all numbers below \$N\$ which divide the sum of the
factorial of their digits. Note: as \$1!,2!,\cdo... |
I want to increase the efficiency and reduce the time complexity for the n-queen problem in n*n matrix chess. I am able to run only still (11*11) in normal time otherwise for the big number it is taking much more time. How can I improve performance?
import time
start_time = time.time()
def queensproblem(rows, columns... |
Indexing a book. Write a program that reads in a text file from
standard input and compiles an alphabetical index of which words
appear on which lines, as in the following input. Ignore case and
punctuation. For each word maintain a list of location on which it
appears. Try to use HashTable and/or HashMap cla... |
I'm taking Harvard's introduction to computer science (CS50) course online, and I've written a program that satisfies a coding challenge but I don't understand what I did or how I can improve it. I'm a very green programmer.
The challenge is to get an int from the user between 0 and 23 and use that to set the line heig... |
I am working on a project that has a Model-View-Presenter structure and use the delegation design pattern that has the following structure/implementation. I would love feedback.
The ViewController will set up the MVP triad:
class BookViewController: UIViewController {
private var bookModel: BookModel!
private ... |
This code is an answer to an exercise I found on the cplusplus forums.
I'm a beginner so any reviews will be appreciated :)
Make a program that outputs a simple grid based gameboard to the screen using either numbers or characters. Allow the user to move either up, down, left, or right each turn. If the player steps ... |
Previously I had been using an array of bool(dead/live) to represent cells. I looked on code review to see how other people have implemented Conway's Game of Life. Someone in the comments of a post suggested using an unordered set to only store live cells. This sounds like it would be more efficient, because only st... |
So I have designed a "type store" in C++ that can hold a single instance of any subclass of a defined type.
Here is an example of how it would be used:
class BaseClass { };
class FirstSubClass : public BaseClass { };
class SecondSubClass : public BaseClass { };
TypeStore<BaseClass> store;
// Each of these returns a p... |
This method find cells that are crossed by line A-B and adds them to one vector.
I have got some duplicates here and some lines of code are very similiar but they differ in one variable. Should this duplicated be fixed or is it fine?
std::vector<Cell> Grid::findCells(int xA,int yA, int xB, int yB) {
vector<Cell> set... |
#include <iostream>
#include <string>
#include <algorithm>
#include <time.h>
int faults = 0;
int hangman();
int i = hangman();
int main(){
srand(time(NULL));
while (i == 1){
std::string words[7]{"Alpha", "Cornwall", "Crepuscular", "Blind", "Steroid", "Plunder", "Talisman"};
std::string word = words[rand() % ... |
I have a simple base class and two derived classes. However, when I'm creating new instances of that class, the line where I instantiate the variables is getting way too long.
I have it on two lines:
private Bot Bot1 = new Bot(10000, AnchorStyles.Left, "Bot 1", 2 (int)UsersProperties.CUser.Bot1, new Point(15, 420), fa... |
I have the following method that is working perfectly. Main problem I see is that I think it can be done just in one line, but I don't know how:
def _animate_display(self, display):
self._timer += 1 / bge.logic.getAverageFrameRate()
symbolic_level = self.battery.get_symbolic_level()
if self._timer >= 5.0:... |
I took some time to create a function, which can validate which keys you input on an element. So far it has two uses:
You call .validate() on the object, but make sure it has a data-match attribute with the regex in it
You call .validate("REGEX") on the object, but replace REGEX with your actual regular expression
He... |
public class MergeSortImplementation {
public static int[] merge(int[] arrayA, int[] arrayB) {
int n = arrayA.length + arrayB.length;
int[] mergedArray = new int[n];
int x = 0;
int y = 0;
int a = 0;
int b = 0;
for (int i = 0; i < mergedArray.length; i++) {... |
I started with this code and modified and expanded it in Python. As an exercise/challenge to myself I decided to covert the original to Haskell. I either write imperatively or functionally. This is the first time I have tried converting from one logic to another. I ran into a lot of little issue along the way. I aimed... |
I came up with an extension method to find a Cartesian product of multiple IEnumerable sets. I was able to achieve lazy enumeration via yield return, but I didn't think of a way to do it non-recursively. The result ended up being a recursive lazy enumeration iterator method, the first of its kind! At least as far as I'... |
Everything works with this program. It takes both Strings and ints, however, I feel like my add method is simply too verbose. Does anyone believe I can implement a shorter version of this, or is it good as is?
Note: Nothing can be changed in any of the method signatures or parameters. The only thing I can change is th... |
Follow up of this question
Changes:
The pop_min function now panics if the tree is empty.
Moved the size attribute to the Tree struct.
Applied most of the suggestions given by the answers.
Added some other functions.
Refactored some functions.
Moved everything to the same file.
extern crate itertools;
use itertools::... |
This is a single page HTML/CSS layout. This is my first ever code and I know it's not perfect, but I would love for someone with a lot more experience to let me know of my mishaps.
<!DOCTYPE HTML>
<html>
<head>
<link type="text/css" rel="stylesheet" href="dereke.css"/>
<title>
</title>
</head>
<body>
... |
This is a dice game where, if you try to get as close as 24 without going over, you are allowed to "hit" three times. If you decide hit, you have the option of rolling one or two more dice. Player and computer alternate turns.
How should I alternate turns without repeating the code?
import java.util.*;
public class Di... |
I am using Webpack to create a sort of loading sequence of the application. I can simply call prepareInfosite().render() and I don't need to care about the hidden async nature of it.
export function prepareInfosite() {
return setupRenderer((resolve) => {
require.ensure(['./infosite'], (require) => resolve(r... |
I try to get into Python and thought I build together my own IDE. Most of it consists of different addons for vim and changes in the vimrc (which of course I simply copied of google), but I also needed a way of executing the main.py file, even when I am working on some other file of the same project. So, since I learne... |
This function replaces some XML tag values. The tags appear in the XML exactly once.I want to know if this can be done in a better way.
sub editConnConfig{
my ($DOMAIN,$rscDir,$walletDir,$DEFAULTPORT)=@_;
`perl -pi -e 's!<trustStore>.*?</trustStore>!<trustStore>$walletDir/fctrust.jks</trustStore>!sg' "$rscDir/Connectio... |
For some reason declaring ApiResult before checking if the answer is in a correct status doesn't look good. I wonder if there is any better way to check the status and return the result:
public async Task<ApiResult> GetCustomersByOutcode(string outcode)
{
using (var client = new HttpClient())
{
Configur... |
I am just trying to use Go so I will be thankful for all remarks and corrections:
package main
import "fmt"
func selectionSort(a []int) []int {
for i := 0; i < len(a); i++ {
min := i
for j:= i + 1; j < len(a); j++ {
if a[j] < a[min] {
min = j;
}
}... |
A friend of mine was practicing his programming skills with a textbook meant to prepare students for computer science exams. He asked for help with a specific task.
The task is to capture user input (day of week and a year in the range 1500 to 2005 inclusive), and output all instances of the weekday in February that ye... |
I was trying one of the problems found on HP Codewars 2007: (2)
Task Description:
The CodeWars judges and scorekeepers need help printing the team names above each column on our score sheet. But we want them to look nice, so they need to be printed vertically. All we have to use is a list of team names. Please writ... |
The assignment is to take a "Magic Square" .txt file (where the horizontal lines, vertical lines and diagonal line all add up to the same number), read it and prove that they are in fact magic squares.
Is anything in this answer bad practice or just bad? I'm using a lot of Lists and for loops.
package magicSquares;
pu... |
I'm trying to read a text file with matrix and put it in a list, but I am using two loops here and I want my function to be faster.
def read_file(path_to_file):
mylist=[]
for eachLine in open(path_to_file,'rt'):
mylist.append([int(eachRow) for eachRow in eachLine.split()])
return mylist
|
I wrote the code and would like to change it to more readable and elegant:
@Repository
public class ProductRepositoryImpl implements ProductCustomRepository {
private static final int MORE_THEN_RESULT = 1;
@PersistenceContext
private EntityManager em;
public List<Product> findByFilter(Filter filter) {
final Crit... |
There are multiple Project Euler problems (e.g. 7, 10) that deal with prime numbers. I decided make a reusable solution that could be used for most of them.
I wrote a method to generate an infinite* prime number sequence, which would enumerate lazily (that is - computing only when requested), using yield return. At thi... |
At the time I'm trying to read a quite big file into a C program for later user. The file size is in the range of 800 megabytes containing around 20 million lines of data of the following format:
YYYYMMDD HHMMSSMMM,X.XXXXX0,X,XXXXX0,0
Y: Year
M: Month
D: Day
H: Hour
M: Minute
S: Second
M: Milliseconds
X: floating po... |
I recently started learning Python, and made a simple text based Hangman game. I wanted to know if there could be anything done to make the code cleaner or more efficient.
import random
import os
import sys
def main():
pickword()
def start(word, twoplayer):
wordarray = ''
userguess = []
guessright = 0... |
I am making a GUI for my C# Monogame project. So since this was the first time I ever made a GUI that is not winforms-based I took a wrong approach in making it and thus I decided to change it entirely. But now the behavior is not the same.
TitleScreenOld.cs
using System;
using Microsoft.Xna.Framework;
using Microsoft.... |
I am generating a pdf form based on user input from an MVC website form. The pdf is genrated using the Foxit .NET SDK, then attached to three separate emails, generated using Postal. It has been requested that the file not be saved to disk at any stage.
I have not worked a lot with files or MemoryStreams before so woul... |
I'm seeding my database with a relatively complex data model.
Constraints: Every meal has exactly one main dish (marked as is_main in intermediate table).
Here is my seeds.rb file:
User.create!(name: "User", #create normal user
surname: "Name",
email: "someemail@example.org",
pas... |
I wrote this class a while ago to learn Kotlin and heaps, so any tips (on either my code style or my heap algorithm) would be appreciated!
class MaxHeap<T : Comparable<T>>() {
private val items: MutableList<T?> = mutableListOf()
var size: Int = 0
private set
fun push(item: T) {
set(size++, ... |
I made a basic XML parser supposed to be work in many browsers by using most older functions. What it must do is return an AST (Abstract Syntax Tree) of a XML text in a string.
(it's not cool for HTML because it doesn't recognize names of elements like input, div, etc...)
The following string:
"<!DOCTYPE html><html><It... |
Notice: The original library has since been replaced by:
https://github.com/JohnReedLOL/scala-trace-debug
See my Scala print trace debugger. This project is used for lightweight debugging sort of like the Haskell Debug.Trace module. The README, the documentation, and the test cases need work.
To test it out, see the c... |
I have a simple working (so it's not a hypothetical stub) framework for calculating Pokemon stats that will later be incorporated in a game. It uses the LCRNG from the first game in order to be as compatible as possible. I use formulas from the Bulbapedia Wiki. The example output matches the example given here.
Things... |
This function works, but it's really really slow and the generated SQL is gargantuan and horrible to look at. It's also very expensive to run when it shouldn't be.
public static IEnumerable<TrackingComputer> TrackingBoardPCsgroup(string groupName)
{
var pingresult = from p in db.GetTable<tblTBHealthPing>()
... |
I have an XML stream that looks like the following (attribute and node quantity , and node depth reduced for demonstration purposes.)
<itinerary>
<organizer>
<company name="ACME" billingLocation="London" adminOffice="Manchester">
</organizer>
<traveller name="John Smith" homeCity="London" />
<flight date="2... |
I am just trying to use Rust so I will be thankful for all remarks and corrections:
fn selection_sort(array: &mut [i32]) {
let mut min;
for i in 0..array.len() {
min = i;
for j in (i+1)..array.len() {
if array[j] < array[min] {
min = j;
}
}
... |
I often receive Excel worksheets (with empty rows) which I have to process as a pivot table. Because pivot tables don't allow empty rows, I've made this script. Any feedback is welcomed.
' Removes empty rows from an sheet.
Public Sub RemoveEmptyLines()
Dim lastRow As Long
Dim currentRow As Long
Dim emptyLine As ... |
I have a utility class, called Bills, that extracts some information from a billId and a paymentId. I'm pasting the whole class here for completeness, you don't need to understand the algorithm behind all functions to be able to answer my question.
<?php
class Bills {
private $typeAndServicePaymentIdMap = [
... |
I am a newly developer in angular. I want to do some homework to create forms with Angular. I spent nearly a week to do it, but my teacher was not really satisfied about it. I tried to follow some web tutorials and I thought that it was good but apparently, the quality of my code is very bad (according to the teacher).... |
I am studying about design principles and design patterns. I have implemented an Abstract factory pattern as per my understanding. The scenario I have considered is as follows :
There is an organization 'DrawingStandards.ltd' for setting standard
rules for drawing.
There are two Other organizations 'Shape.ltd' and
'En... |
I wrote a script that downloads all PDFs found on the web page of a particular government agency. I would have chosen bash for such a task, but I want the script to run in Node.js. The downloaded files are a few hundred kilobytes big, if that matters.
It is the first time I use ES6, but I want to learn how to take adv... |
The data:
pre1 <-structure(list(A = c(0.0276, 0.0165, 0.0113, 0.0229, 0.0113,
0.0151, 0.015, 0.0122, 0.0113, 0.0113, 0.0113, 0.0113), B = c(0.0884,
0.0135, 0.0001, 0.0523, 0, 0.0069, 0.0069, 0.0007, 0, 0, 0, 0
), C = c(0.04, 0.0155, 0.0065, 0.0291, 0.0065, 0.0128, 0.0127,
0.0078, 0.0065, 0.0065, 0.0065, 0.0065),... |
I programmed a Pong game in the editor Processing. I would be glad if you could give some improvements.
//Variabeln werden erstellt
int untere_spiel_grenze;
int obere_spiel_grenze;
float spieler_x;
float spieler_y;
float ball_x;
float ball_y;
float ball_geschwindigkeit_x;
float ball_geschwindigkeit_y;
float spiel... |
I'm writing a code which task is to grow Random Forest trees based on multiple parameters. In short:
Firstly, I declare a data frame in which model parameters and some stats will be saved.
Secondly, I declare model parameters and the loop iterator (it will be showed after every loop iteration).
Next, I have a nested l... |
This is my first bash script. I am trying to learn scripting and needed an idea. This is the first idea I came up with. When I used to distro hop I had to reinstall everything. This helped me out once I got the first part working. Then I wanted to add if then else for more than just Debian distros.
#!/bin/bash
#Script... |
I'm writing a small Android application that deals with payments and, in my function that handles transactions, I need to translate a number of installments (1-12) and whether or not it has interest (0-1) into the de facto objects for those of the SDK I'm using.
Right now I have a switch that looks like the following:
... |
I have got a piece of code that initialize Scanner in two possible ways:
no argument constructor creates Scanner that uses stdIO (System.in) as source
contructor with String, which creates Scanner, that uses file as source, where String is a path to file
It looks like this:
public class InputMethod implements IInputM... |
I recently tried my hand at writing Go code for a project I'm working on. In order to help myself get a better grasp I decided to write a simple yet somewhat practical program for parsing numeral characters from strings based on the ascii values of the runes within, and appending them to a slice.
My primary concerns wi... |
I've written an implementation of a Stack data structure using a linked list.
Stack.java
import java.util.EmptyStackException;
public class Stack<T> {
private class Node {
private T data;
private Node prev, next;
public Node() {
}
public Node(T data) {
this.d... |
I am trying to read properties file using a singleton class. I would like to know if there are any best practices and design patterns to read the properties file. I found dependency injection is one way to read properties file. But, I did not find any examples on the DI design pattern. Any sample code and links would b... |
I've created a class that translates an integer into words in an English (not British) format. My first human language is not English, and I don't have a good idea of a truly right way to read numbers, so I followed the exact meaning of the numbers (e.g. 1024 = one thousand twenty-four, not ten twenty-four as read by s... |
I've created a simple JavaScript application, which also happens to be my first-ever piece of code in any programming language.It took me two days to get the core correct and another two days for styling and the progress bar.
I'll be adding subsequent features to this quiz, as I continue to learn more and more about th... |
I'm using nodegit to develop the backend for a nodejs app that uses a mix of mongodb and git for persistence. The app has to version documents and be able to present diffs between versions, thus the use of git in the backend.
For one of the API endpoints, I needed to get the diff between two commits, so I've develop th... |
After rolling my own virtual machine, I decided to implement an assembler for it. Ironically, it's all Java, since I needed to do a lot of text manipulations. Please, tell me anything that comes to mind.
Here is the main component:
ToyVMAssembler.java:
package net.coderodde.toy.assembler;
import java.io.FileNotFoundEx... |
Would you please recommend how I could improve this code? My PHP editor only gave a warning about the variable $id.
require_once 'includes/config.php';
$id = (isset($_GET['id']) || trim($_GET['id'])) ? intval($_GET['id']) : 0;
if (!empty($id) && filter_var($id, FILTER_VALIDATE_INT)) {
$sql = $pdo->prepare("SELECT... |
I'm currently building a game called "Drones! Attack!", and I needed a drone controller that the player can use. It's currently very simple and only supports a small amount of actions, such as:
Basic movement (forward, backward, left, right, up, down)
FPS camera control
Camera scoping (e.g, changing the FOV from a hig... |
When I started learning Repository Pattern with Unity few days ago I was under impression that the main benefit of this pattern is the separation of data layer from the business layer.
In other words, if there is a need to change the way, how application stores the data, it's very easy as only one main model takes care... |
I've recently applied to a backend position and I was asked to complete a take-home interview question. I thought the question was rather simple and I completed in about an hour although I was told it could take up to 4 hours.
I got a response back recently stating that my answer does not demonstrate the necessary skil... |
This is my 2nd program I wrote on my own, a pretty simple program consisting of two functions (those functions are not combined in any way yet though). The first function moves the display times of subtitles saved in .srt files by a specified amount of time.
The second function "warps" the display times by a specified... |
I have a game in which the player has to do something within a defined time.
E.g.: the player has 10 seconds to complete a level.
My current code animates an imageview (it's only a horizontal line) when the game starts:
progressAnimation = new TranslateAnimation(0, -Settings.screenWidth, 0, 0);
progressAnimation.setDur... |
Do you think the way I'm doing it is fine? Is this the most typical way to do it? Share your thoughts please.
# Display the last three lines of a text file with line numbers in reverse order
# Can come quite in handy when reading log file entries
cat -n [FILE] | tac | head --lines=3
Test:
# Let's create a text file to... |
I'm new to Powershell scripting and trying to write a script that will go through printer queues on a print server, get the print queue's port address, then compare the print queues port address to the DHCP reservation associated with the print queue port address on the server. If the port address of the print queue co... |
This code works but I don't know if I am doing this correctly. I want to have a do-while loop for the menu and app. How could I improve this code?
import java.util.Scanner; // import scanner
public class CalcPart3 { //class definition
public static void main(String[] args) { //main class
char result... |
I tried to come up with a good challenge to learn some Rx.js programming and I came up with this chain of operations below. As well as a bit of code that works and does these things.
Take github username
Create folder based on username (/repos-${user})
Get all repos for username (https://api.github.com/users/${user}/... |
I am writing a program to generate a height map following the midpoint displacement algorithm (somewhat similar to diamond-square).
I'm at the point where I have a recursive program that paints the whole map but still needs some modifications to provide the desired result.
Before I do, I would like a code review on wha... |
So I've written my first android app in kivy.
This app takes a Vehicle License Number as input from the user and submits it to a sites and shows the results from the site.
The complete Source Code of the app is at https://github.com/Logmytech/Andhra-pradesh-vehicle-lookup
Here is the Kivy language code:
<RootWidget>:
... |
I'm very new to AngularJS and just started in a new project which uses AngularJS for Web UI. I was looking into our code and found out that we have huge functions in controllers. Like, one 100-LOC function which does a lot. Logically, our Sonar complains about it and for me as a novice it's quite difficult to understan... |
I implemented a vector class in C for integers. Any feedback welcome.
header:
#define DEFAULT_CAPACITY 1000
// Define a vector type
typedef struct
{
int nrOfElements; // Current number of elements.
int capacity; // Possible capacity.
int *data; // Pointer to array elements.
} CVectorInt;
typedef e... |
I am using the following Depth-first search algorithm to compute value of a property called rotation_absolute based on previous values of rotation of parent elements recursively.
The result of the script is correct (open console to see the result) but I would like your code review regarding performance, considering tha... |
I have this code which makes it easy to color a string in terminal but it is looking really repetitive. Is there a more idiomatic way of writing this? Also is there a functional way of doing this more effectively?
It seems really trivial, something like strings blue,red etc should point to a generic function, and when ... |
I solved FizzBuzz using tail recursion. Is it efficient enough?
(defun mod-3 (n)
(zerop (mod n 3)))
(defun mod-5 (n)
(zerop (mod n 5)))
(defun analyzer (n)
(if (mod-3 n)
(if (mod-5 n)
'fizzbuzz
'fizz)
(if (mod-5 n)
'buzz
n)))
(defun fizzbuzz (limit)
(fizzbuzz-helper limit nil))... |
This is follow up to this one. In the previous some minor errors slipped, so I couldn't update the code. Also took some advice.
So final version is below.
header:
#define DEFAULT_CAPACITY 1000
// Define a vector type
typedef struct
{
int nrOfElements; // This just denotes current number of elements.
int capacity;... |
I've got a job to create a library that would be able to support multithreaded and multi process read and write to a single file. On that single file we would store C# models in an array in JSON format. It would basically work as a mini file system JSON DB.
When the application that uses this lib starts, it would load ... |
I have created this middleware code for slim. I just want to know that is this right way to store site settings globally. so, I can use where ever I want. What do you think about my class structure apart from invoke (which is slim's own feature) what do you think about foreach and setting the data. I'm trying to learn ... |
I have a need to get notified about validation errors that occur in a child collection of my ViewModel. For validation I use the INotifyDataErrorInfo interface.
I've created a class that handles this successfully however, I feel that additional refactoring / simplification can be done on it.
Here's the class that imple... |
I have done this quiz project and I have tried as hard as I could when I was writing to make it user friendly to read. Could you help me on improving and making it more user friendly please.
import random
import operator
import csv
OPERATIONS = [
(operator.add, "+"),
(operator.mul, "*"),
(operator.sub, "-")
]
NB_QUES... |
I have this Brainfuck interpreter:
// Credit goes to where it is due
function throwException(cause, index) {
// Execute when there is an error in Brainf*** code
$('p#output').text("Interpreting Terminated because " + cause + " at char index " + index);
}
function runBrainfuck(data) {
console.time("Runnin... |
I have used loops to remove lines that are doing various things, but all are deleting rows where certain criteria is met. Some are deleting less than certain numbers, deleting blanks, removing specific rows that contain specific things in columns, remove all the items that don't contain 4 specific parts. This works but... |
I'm trying to improve my C++ template metaprogramming skills. From my understanding, I can't partially specialize a function(either member function or not). So, I need to define another class that can be used as template class, which enables us partially specialize template argument.
So, In order to check my understand... |
I created a Sliding Number Tile Game, and am looking for input on how to make the code better organized & more efficient.
#include <iostream>
#include <random>
#include <algorithm>
#include <chrono>
#include <windows.h>
#include <conio.h>
using namespace std;
void initializeBoard(char pB[][3]);
void printBoard(char ... |
CasperJS doesn't allow continue statement inside a casper.then functions. This was my solution but I'm not happy about it. Is there a better way to achieve this effect?
casper.start();
casper.then(function() {
var current = 1;
var end = 4;
var skip;
for (;current < end;) {
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.