instruction stringlengths 71 71.9k |
|---|
I was working on representing a large List of information on a number of different pages, and a colleague of mine suggested that I try to make a generic method for the task I was trying to perform:
private <T> List<List<T>> listSplitter(List<T> originalList, int splitCount) {
List<List<T>> listOfLists= new ArrayLis... |
I [believe that I] wrote foldl in terms of foldr:
myFoldl :: (a -> b -> a) -> a -> [b] -> a
myFoldl f base xs = foldr (flip f) base (reverse xs)
Is this an idiomatic implementation?
|
I've written a Geocoding library that is hosted on Github. It has got 7.9 rating by the scrutinizer. I've checked and the only thing that I think I can improve is populateAddressVars. What do you think?
<?php
namespace kamranahmedse;
/**
* Geocode
*
* A wrapper around Google's Geocode API that parses the address, ... |
I have tried the following code:
SystemUser user = (SystemUser)Session["CurrentUser"];
Data.Configuration configuration = db.Configurations.Single(c => c.ID == user.ID);
MailAddress from = new MailAddress("noreply@test.com", "Test");
if (configuration.EmailFromAddress != null)
{
from = new MailAddress(configuration... |
In my project there are a lot of GUI so I have a class for each GUI. I created a class to connect to my db (MySQL). Remember, I don't have problems with code not working. The code (important to this question) in the connectiondb class is:
public static void loadDriver_doConnection(){
try {
Class.forName(jdb... |
I've just begun creating a class to get User information, and I'd like for it to be improved.
The global variable $oConni is the database connection.
class UserInfo {
public $id, $oConni;
public function __construct($id, $oConni) {
$this->id = $id;
$this->oConni = $oConni;
}
public function getInfo() {
$... |
I just started using Laravel 4. I read some tutorials on how to implement CRUD in Laravel, and I was able to develop a portion of it. What I am going to show you is more on Controller and Eloquent ORM.
I have here 2 models "Group" which can only have one Country, but Country can be assigned to different Group ("one to ... |
I would like any suggestions and improvements for this code, be it generics or my Node class being completely mutable. Should I make it mutable? Is it good? Why?
package ishan.trees.tree;
class Node implements Comparable<Node> {
private int data;
public int getData() {
return data;
}
public v... |
I have written this HTML static class which may categorize as a helper (not really sure what the definition of helper is). Anyways, I was just wondering if it was a smart idea to call a bunch of PHP functions instead of using raw markup because it just doesn't seem right to me.
One of the things that I'm positive about... |
I have been recommended on stack to rewrite the function, but it does get the job done. Can I improve the efficiency or readability?
def get_notifyees(jobdef):
if 'notifyees' in jobdef:
origNotifyeesList = jobdef['notifyees'] if isinstance(jobdef['notifyees'], list) \
or jobdef['notifyees'] is None ... |
The following will by my simple helper, that should behave just like std::chrono::system_clock but with the epoch being 1.1. 2000, that I can easily cast durations to seconds (or milliseconds or centiseconds) and store them in some records (originated from small devices).
It all started with one constexpr:
/// 1.1.2000... |
I'm using Parallel.ForEach to download 500K URLs and I want to monitor the number of URLs that have been successfully downloaded each minute.
int elapsedMinutes = 0, cnt = 0;
Parallel.ForEach(list, tuple =>
{
var currMinutes = (int) ((DateTime.Now - startTime).TotalMinutes);
... |
I have a requirement of a templated clone() method which Base classes can implement through an ICloneable interface and all the derived classes will automatically get a pure virtual clone<T>() method to override. I know this is confusing, so below is my code which probably explains it better.
// ICloneable interface
te... |
I am brushing up my Data Structure knowledge (for preparation for internship interviews) and I started by implementing a very simple Linked List class. This is by no means intended to be able to replace the Java library just to be something robust enough for making me understand and remember how to implement a Linked L... |
My program is structured like this: there are M producer threads, each of which computes a section of an object O with index i O[i]. When a specific O[i] is completed by all producers, it is put in a ring buffer, which is consumed by N threads. When all consumers are done with a specific O[i] can be discarded.
There mu... |
I needed BatchBlock with support for timeout (act greedy on what it received at that time) and by some search and study, this is the outcome.
What are drawbacks or rooms for improvement in this code?
class BatchedQueue
{
static readonly Logger SlotClassLogger = LogManager.GetCurrentClassLogger();
protected stat... |
I am looking for a code review on this class. I found myself writing this logic a lot, so trying to save myself some time.
require 'etc'
require 'net/ssh'
require 'net/scp'
class SSHOps
def initialize(host, user=Etc.getlogin, *args)
@host = host
@user = user
@keys = args.empty? \
? args << Etc.getpw... |
I'm new to Python and programming in general, but I'm making it work. I have this little game I've been working on as a learning exercise and I'm a bit concerned that I'm using far too many if/else statements for the user menus. Is there perhaps a better way?
# Bizarro house text adventure game
from sys import exit
imp... |
This is an alternative edition of a game I modified the code for. See:
Guess My Number, Classic Edition
I seek advice on best practice. Tips, tricks, and suggestions, all welcome:
# Alex Grattan
# 9/10/14
# This is an alternative version of the "Guess My Number Game".
# The Computer now has the role of guessing a nu... |
Basically I had 3 columns of Data
Adjudicated Cases
Not Adjudicated Cases
All Cases
and I wanted to get a list of all the cases that were missing from Column A and Column B, with a little help from @RubberDucky and his really cool Enumerable.cls (Found on GitHub in His VBX Repository) I used the Merge function to fi... |
I have created a set of functions to calculate the aspect ratio of an image, set a height/width on document.ready and on window.resize resize the image. Now, I have got these functions working, however I feel like they could be more efficient/clean. So far I have to use cases. First, an image gallery I have setup and n... |
I am looking for a better way to do a while cycle with the variable update.
The background is that I'm writing a StAX-line XML reader in JavaScript and want to implement a skipElement function. The function may only be called on the start tag and should skip everything until the closing end tag.
this.nextTag() skips t... |
I have a MySQL table which contains product SKUs among other things. PHP powers importing data into this database, managing data through a control panel, displaying the information on the front-end, etc. (For clarity, this is a Magento site.) On the front-end, I need to be able to list SKUs in natural sorting order, ho... |
I've created a console customizer for a C# console application. This is not finished yet but I'm looking for tips, requests and suggestions so I can make some updates.
Sample Preview
The following code is use to create a customize Write() and WriteLine() and I also make some Typewriter effect on it.
namespace GetBoot... |
I have a Windows form that when a user moves some groupboxes around, before the application exits, it saves those X and Y coordinates into a MySQL database (with a bit of added text to identify which groupbox those settings belong to). This all works fine. When they log back into the application, I can pull those set... |
I would like my program to be reviewed. I had to write a simple program that calculates the number of molecules in a hydrocarbon.
1 carbon atom has 12 AMU.
1 hydrogen atom has 1 AMU.
#include <iostream>
using namespace std;
int main()
{
cout << "Enter mass of hydrocarbon (in grams)\n"
"followed b... |
My task was to implement a method which performs basic string compression by counting sequences of repeating characters. Given "aaabbbccc" it should return "a3b3c3". I have included some sample tests I made up. Please let me know if I have missed any cases. I am looking for the fastest implementation possible with the ... |
I'm new to Java and I want to know if this code is efficient, and if there a shorter and faster way to reverse a string.
package Excercises;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("Please enter ... |
With big inspiration from code from different webpages, I have created this DictionaryTagger. My problem is that it takes around 2 sec. to initialize the taggers / class.
When the tagger has been initialized, it only takes a few milliseconds to use the different taggers. I see two different ways to optimize the tagger:... |
The following is a very simple implementation of an Encryption class using mcrypt whereby the functions encrypt and decrypt are called statically by a PHP script on GET and on POST respectively:
class Encryption
{
const CIPHER...
static function encrypt($plaintext)
{
$td = mcrypt_module_open(self::... |
I've done my second application in Java now. I want to know if:
This code is efficient
This code can be written in a shorter and faster way
Any flaws
Any misuse or better use of concepts
Main Class:
package Excercises;
public class Main {
public static void main(String[] args) {
PigLatin pigLatin = new P... |
I'm building a list of filters for a website user to filter on, such as a product category page. I'm giving the user the option to filter on brandname, model name, or gender.
To avoid serverside code I'm trying to build it clientside. So, I'm looking on the different data-attr and building an array of filtering values ... |
It is OK to model a double usage register with a record variant:
type Capture_Compare_Selection is (Output, Input_TI1, Input_TI2, Input_TRC) with Size=>2;
for Capture_Compare_Selection use(Output=>0, Input_TI1=>1, Input_TI2=>2, Input_TRC=>3);
type TIM_Register_CCMR (CCxS : Capture_Compare_Selection := Output) is reco... |
I have this working code for a toggle-item inside a Bootstrap dropdown-menu. See demo here.
I suspect that it should be possible to improve it :
in order to have a shorter code and avoid all the (...).css('visibility','hidden'); code redudancy... Is it really like this that I should move the tick icon on the selected... |
Was advised to post this question here after posting to Stack Overflow. I'm pre-populating a UITableView app with data using a local JSON file. The JSON itself is very simple:
[
{"Name":"Tennis Ball Launchers",
"Type":"Forces"},
{"Name":"Magnetic Hot Plates",
"Type":"Magnetism"},
{"Name":"Giant Le... |
My external sort function works but it is way too slow. I think the bottleneck is the merge function. How can I make it faster. Is there a better merge function I can use for merging into a file using random access file objects and buffers?
private static void merge(String a, String b,
int l, int m, int r)throws FileNo... |
I found myself mounting a query by concatenating strings. This just seems wrong. Any ideas of how to avoid this kind of situation?
I'm using Rails 4, and I don't see how can Arel make things better for my case.
def self.search(params)
# query example
# SELECT "jobs".* FROM "jobs" WHERE (telecommute = 'f' AND ... |
I have the following code:
inversions :: (Ord a) => [a] -> Int
inversions xs = snd $ countInv' (xs, length xs)
countInv' :: (Ord a) => ([a], Int) -> ([a], Int)
countInv' ([], _) = ([], 0)
countInv' ([x], _) = ([x], 0)
countInv' (xs, n) = (sorted, leftInv + splitInv + rightInv)
where
leftLen = n `div` 2
... |
Just learned how to use custom attributes in C# and the first useful thing I did with it was to make a class object representing a database table. The constructor can accept an IDataReader and populate the members based on the custom attribute. Is this a good usage of custom attributes?
[AttributeUsage(AttributeTarget... |
We have just learned about classes. Please help me improve this program. I created a class called Box with members that represent its dimensions. Then I calculate the volume and surface area and print it.
#include <iostream>
using std::cout;
using std::endl;
class Box
{
public:
Box(){};
double m_Length;
... |
I wrote an answer for the following question and wondering if there is any better approach to it.
Using the Java language, have the function RunLength(str) take the str
parameter being passed and return a compressed version of the string
using the Run-length encoding algorithm. This algorithm works by
taking the... |
I have a switch in the index.php file. When there is a value in the $_GET['page'] and it matches the switch it includes a page, for example: "www.website.com/index.php?page=home". So basically you'll always be in the index.php file.
Above the switch I am calling the classes, but is there a better way? Should I call a n... |
I wanted to write depth first search reversal iteratively in Java. Can someone review my code? I'm not that much interested in naming of the variables, but in the structure of the code, i.e. I don't need to mark the nodes as visited when I traverse binary tree, right?
public static void dfs(TreeNode root){
if(r... |
I am trying to make a loading screen but my code isn't DRY. How could I make it DRY? I have thought about using CSS3 keyframes but I might have problems cross-platform.
$(document).ready(function() {
var lc = $('.loaderContainer'),
wh = $('.welcomeH'),
th = $('.toH'),
meeuh = $('.meeuH'),
se = $('.sit... |
I am implementing some basic data structures to freshen up my memory and I wanted my DoubleLinkedList remove method to be reviewed. I feel like it has extra checks but I could not think of another way to implement.
My implementation holds both the head and the tail of the list making things a bit more complex.
remove m... |
#include<iostream>
#include<string>
using namespace std;
// Generic class for tracing the function call
class functionlogging {
private:
string name;
string in{ ">>" };
string out{ "<<" };
public:
functionlogging(string x) :name(x) {
cout << in << name << endl;
}
~functionlogging(){
... |
I've been working on a Final Fantasy-ish game and am leaning toward more like 1 - 3. This is my attempt at map movement. It does work, but if anyone has any suggestions or critiques, I would like to hear them. For instance, is there a different way you would do something or is there a way I can clean up the code?
packa... |
The following code calculates a perfect
elimination ordering in a special case in Haskell.
I am less worried about its correctness than
its high use of memory. The following code runs
out of memory on my computer. It seems it should be
possible to execute the algorithm without ever having
more than around 1000 integers... |
We're all aware of Fibonacci sequence calculators but they look like C-style code. I want to avoid that and take advantage of the standard library. This code is very short, so I'm focusing on readability and correctness.
Barring comments, will people be able to understand the code just by looking at it?
As you're pro... |
Does the implementation look correct? Did I miss something major/minor?
class CircularBuffer
class BufferEmptyException < StandardError; end;
class BufferFullException < StandardError; end;
def initialize(size)
@size = size
@buffer = []
end
def write(data)
raise CircularBuffer::BufferFullExc... |
The objective is to find the number of working days (days spanning from Monday to Friday) between two given dates inclusively.
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
for (int i = 13; i <= 31; i++)
{
... |
I just started to learn Java and had to write a "guess the number" game.
Could you please review and give me some feedback?
public static void main(String[] args) {
System.out.println("Welcome to the guess the number game!\n");
System.out.println("Please specify the configuration of the game:\n");
Scanne... |
I wrote a program that places values in one array to the end of another array. It keeps the order of the values. If the second array is bigger, then there will be leading zeroes.
Is there anything I can improve? How do I simplify this program?
#include <iostream>
int main()
{
int fromArray[10] = {11,... |
I've made a program that outputs you the most common word in txt file. Does anybody know how to optimize it so that it would work for bigger files and run faster?
#include <iostream>
#include <string>
#include <fstream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
i... |
I want to solve the following for \$x\$ (in Python):
\$x^{101} = 8765 \ (\mod{9691573})\$
I coded this:
n = 8765
power = 101
mod = 9691573
x = 0
while x < mod:
if (x ** power) % mod == n:
break
x += 1
print x
This is basically the "brute force" approach.
What is the most efficient way to solve this p... |
I drafted a method that I intend to use to convert integers to strings. Is there a way to make it faster? Are there any "simple" changes I could make to improve its performance? This cannot be done with C++11.
std::string to_string(int val) {
static std::string str;
static std::stringstream ss;
ss << val;
... |
I have been learning Python for a while (my first programming language) in my spare time. Since it's been 20 years since math class, and I didn't get very far with that, I just brushed up on pre-algebra and have started learning algebra. I decided to try and write some scripts/functions for what I have been learning, a... |
For my first basic project with functions, I wanted to make a program that would allow you to input a number, and it would output whether it was prime or not. For the most part, it's functional and working.
How can I optimize it to be more efficient? How can I make my code more readable for the next person? What are so... |
I attempted to write an \$O(N)\$ Fibonacci.
fibMemo :: Integer -> Map Integer Integer -> Integer
fibMemo n map
| n == 0 = 0
| n == 1 = 1
| otherwise = case maybeMember of Just x -> x
Nothing -> calced
where maybeMember = M.lookup n map
cal... |
I recently interviewed with a company for software engineering position. I was asked the question of finding the longest unique sub-string in a string.
My algorithms was as follows:
Start from the left-most character, and keep storing the character in a hash table with the key as the character and the value as the inde... |
I had to write a program that accepted five numbers from the user. Then it will display the number of odd and even numbers, and a total sum of all numbers.
#include <iostream>
using namespace std;
int main()
{
int a;
int b;
int c;
int d;
int e;
int sum;
int remainder;
int bremainder;
... |
This is a program I wrote to print out 100 prime numbers. How can I improve it?
// Calculating primes
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;
int main()
{
const int MAX(100); // Number of primes to be identified
long primes[MAX] = {};
long trial(5); // ... |
Example project (and code presented here) on GitHub
At first, simple example.
layout / activity_slide_show.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
... |
I know that there are several ways to develop the MVC pattern. To improve consistently my knowledge, I would like to get some advice and feedback. How could I enhance my code? I knew that there are several lines of code, but it would be great if you help me improve my skills.
The Model store the object Person and notif... |
My mission is as the title states.
Here is the original code, before optimizing slightly (but still not enough).
Revised code is in my answer, and it still needs work.
Also, I want to write this without having to import any libraries. Time is only there for me to test, of course, time.
Here's the original code, before ... |
I have a substantial music collection, which will not load entirely in any music program.
So I wrote this quick program, to play a random song in a subfolder of my music directory.
I'm just wondering if anyone can improve on this code? It works pretty well, but the subdirectories are not all equal with respect to size,... |
I'm pretty proud of the following, but would welcome any comments from experts:
%% Provide with a Goal and it will iterate towards it.
guess(Goal, Res) :-
guessIterate(Goal, [], Res).
guessIterate(Goal, Guesses, Res) :-
makeGuess(Guess),
check_against_guesses(Guess, Guesses),
score(Guess, Goal, ThisSc... |
I am quite new to C# and to the ASP.NET programming. When maintaining the legacy code, I have found rather terrible implementation of the method that is used on many places to get the DataTable object with the data filled by the SQL command.
Here is my first approach to rewrite it. Does using work with the return as sh... |
This is my version of the Snake game, written in C++. How could it be improved, and what general advice would be useful for future projects?
#include <iostream>
#include <conio.h>
void run();
void printMap();
void initMap();
void move(int dx, int dy);
void update();
void changeDirection(char key);
void clearScreen();
... |
I can't understand why this strange behavior when I call the method remotely is expensive.
I have observed a performance issue when my object method called remotely compared to when it's called within the same process. To confess, I don't have good understanding of .NET remoting technology. Yes I have read few articl... |
I was asked to write code for the below structure:
1
3 2
4 5 6
10 9 8 7
11 12 13 14 15
And I tried the below code, which works, yet I'm wondering if there is any better approach than this:
public static void main(String[] args) {
int n=5; // no of rows
int c=0;
for(int i=1;i<=n;i++){
... |
When creating a new model in Rails, I need to pass a bunch of other models into the view so I can define the correct associations. All I’m really doing here is querying the persistence layer for models and assigning them to instance variables, but I’m having to do it twice. What’s the best way of extracting the assignm... |
I want to display all the prime numbers between two integers taken from the user as input. Also I have to take a user input to specify the number of times the loop should run. Here is the Java code that I have written. I have to now reduce the run-time.
import java.util.Scanner;
public class Main{
private... |
I have an array of thing objects, each of which has an array of categories. I'd like to build a category hash with a category ID for a key and an array of things for a value.
category_hash = Hash.new
things.each { |thing|
thing.categories.each { |category|
category_hash[category] = Array.new unless category_hash... |
I have a file, the content is in the format of
41545
0
0
1
2
3
3
3
...
Following is the code
X=[]
Y=[]
total=0
count=0
for line in open(file,'r'):
count+=1
line=line.strip()
if(line.strip()):
if(count==1):
total=int(line)
else:
X.append(count-1)
Y.append(... |
I have three huge files I need to process in order to rearrange the data contained within.
The first file is a list of English example sentences (468,785 lines long).
A typical line from this file looks like this:
120033#eng#Creativity is an important aspect for the development of human.
The second file is a list which... |
I have a functional program that compares multiple collections of basketball team name objects. It creates a new array of objects that the input collections share in common, and simultaneously prints it out to the console. I am not allowed to change the findMatchingItems method signature that you see in the code. It ha... |
I have decided to create a console Blackjack game as my final Java project. Please take a look at my code and give me some feedback.
I have tried to make the game as object-oriented as possible. I have five different classes.
Player class:
public class Person extends Dealer{
Random ran = new Random ();
Scanner scan =... |
I have a function written in Python 2.7 that I call several times in a program. This function is rather slow, and I'd like to rewrite it in NumPy. However, I don't know how to do it.
I basically have a canvas of width * height pixels, and I'm making something rather complicated inside. I'd like to know how to replace a... |
I'm creating own script for backup user's directories.
CentOS 6.5;
Python 2.6.
Directories looks like:
# tree -L 2 -d /var/www/vhosts/
/var/www/vhosts/
├── freeproxy
│ └── freeproxy.in.ua
├── hudeem
│ └── hudeem.kiev.ua
├── profy
│ └── profy.kiev.ua
├── rtfm
│ └── rtfm.co.ua
├── setevoy
│ ├── forum.setevoy.ki... |
So I am running a Switch case to check if a user has filled in all the necessary fields within a form, and if not I prompt them to do so. I was wondering if there was a better way to do this, or if a switch case like this would suffice. General suggestions/naming improvements would also be appreciated.
This runs insid... |
Is the following query is vulnerable in terms of $itemstatus? I want to be sure about it. $yesorno is a user input which is sanitized and it's fine, however, $itemstatus is a not user input but is included in the query. Can $itemstatus be manipulated or overall if it's vulnerable?
$username = $this->site->SanitizeI... |
I've been working on a little problem where I need to compute 18-digit numbers into their respective prime factorization. Everything compiles and it runs just fine, considering that it actually works, but I am looking to reduce the run time of the prime factorization. I have implemented recursion and threading but I th... |
I was posed this question by a friend:
I am a natural number written with 10 different digits such that for all \$i ∈ {1, . . ., 10}\$ the number formed by my \$i\$ first digits (from left to right) is divisible by \$i\$. Who am I?
I came up with a brute-force solution over the next hour or so (a few attempts failed)... |
I'm doing this:
Consider:
struct Tnode {
string word;
int count;
Tnode* left;
Tnode* right;
};
Write a function for entering new words into a tree of Tnodes. Write a
function to write out a tree of Tnodes. Write a function to write out
a tree of Tnodes with the words in alphabetical order. Modify ... |
I've recently started working on a new application in Rails 4.2.0-beta2. I've been using this as an opportunity to learn more about MiniTest, with a stretch goal of being as strict with myself with testing as possible.
My general problem: How do I test the after_save action for an ActiveRecord model in such a way that ... |
After I completed writing this code, I started to wonder if the switches should be replaced with a more OOP approach. I originally picked the switch approach because there will never be anymore skill groups, only the 5 listed. It also made it a bit easier on the GUI side of things to associate a selection index to one ... |
This CAPTCHA is not text but basically images of objects that the users has to identify between an array of options. My current code is kind-of slow because the query takes almost .7s to execute and it has to run three times.
I'm looking for a way to improve it and make it faster.
// Loop through to display the picture... |
I am trying to write the simplest to undestand code possible, each function has documentation and examples and I tried to use the best style possible.
""" This programme implements a polyalphabetic cipher. """
import string
ALPHABET = string.ascii_lowercase
CHARACTERS_THAT_MUST_REMAIN_THE_SAME = string.digits + stri... |
I've started learning PHP for university-related projects today. I tried implementing a basic blog/forum. Here's the full source code.
It has the following features/design-decisions:
There are posts, which have the following fields: title, author, date and contents.
Posts have comments, which have the following fields... |
Here's a Tic Tac Toe program I wrote in C++. It can play (semi-effectively) against the player. Please give tips on how to improve.
#include <iostream>
#include <ctime>
#include <cstdio>
#include <cstdlib>
using namespace std;
int computerRandomPick; //random location which computer selects if first.
int computerPi... |
This is an assignment posted here.
This is my first foray into OO for me. Is this design OK? Or is there something very wrong that I'm not seeing at all. Any suggestions are most welcome and needed.
import java.util.*;
/*
* Encapsulates a Sudoku grid to be solved.
* This project is based on the assignment given in ... |
I wrote a program that computes longest increasing subsequences and common substrings.
Can you please suggest more elegant and eloquent ways for this program? (Perhaps better ways to represent a graph with vertices and edges?)
Longest increasing subsequences using longest increasing suffixes:
from functools import lru_... |
I'm trying to find a nice API for a Quiz Engine. This is what I have so far:
Implementation:
public class Question
{
public string Title { get;set; }
public List<Answer> Answers { get; set; }
public Answer CorrectAnswer { get; set; }
}
public class Answer
{
public bool IsCorrect { get; set; }
publ... |
I'm making a portfolio website right now with Visual Studio 2013 and ASP.NET 3.5 because my free hosting only supports 3.5. Are there any bad practices in my code at the moment? What would you change and why?
$TextColor: #d9d3d2;
$LandingColor: #343434;
$BackgroundColor: #1a1a1a;
$ImportantTextColor: #de9100;
$Ori... |
I have currently implemented this simple example of a database to output for a REST API to show the way information is being parsed, mapped and serialized starting from database data converting it to JSON. This solution currently works fine, but the problem comes from the fact that it makes use of PHP tricks (like call... |
Delegate
This class module defines what I'm calling, in this context, a Delegate - here a function that can take a number of parameters, evaluate a result, and return a value. Close enough to the actual "delegate" thing I find.
Example usage
Set x = Delegate.Create("(x) => MsgBox(""Hello, "" & x & ""!"")")
x.Execute "M... |
I want to know if there is a better way to square numbers in an array. This is what I wrote:
#include <iostream>
using std::cout;
using std::endl;
void square(int []);
int main()
{
int array[] = {2,4,6,8,10};
square(array);
for(auto i : array)
cout << i << " ";
}
void square(int array[])
{
... |
This is for Project Euler question 18 and I'm looking for feedback on whether my algorithm is incorrect or whether I've just implemented it wrong (which I don't think is the case after some testing).
The question is to traverse the maximum path in a triangle from top to bottom.
75
... |
Previous question:
Checking for the nth prime number between 1 and 1,000,000, must compute 1,000,000th in under 3 minutes
My mission is to find the nth prime number, based on user input 1-1,000,000. It also must be able to compute the 1,000,000th prime in under 3 minutes.
My code is relatively fast, however I need to m... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.