instruction stringlengths 71 71.9k |
|---|
I have the following code which duplicates the previous input if any entry is less than zero or NaN, except the first row of a matrix.
Is there any other efficient way to do this without using multiple for loops? The input matrix values may differ in some case and may contain float values or alphabets. The matrix cons... |
I’ve made an e-commerce website where administrators can specify the number of deliveries they can make on any one day.
I’ve written a SQL statement that then finds all delivery dates, finds any matching orders on those dates, and then returns any where the remaining “slots” are greater than zero (i.e. available). The ... |
I have been working on a calendar widget for the past hour or so. I wonder if it could be compacted any more than it already is (ignoring whitespace).
$(document).ready(function() {
var d = new Date();
var cd = d.getDate();
var cm = d.getMonth() + 1;
var cy = d.getFullYear();
var M = cm;
var Y = cy;
va... |
I have been given a requirement to create a symbol toolbar, a toolbar where each button represents a unique symbol.
This is how the toolbar would work:
A user clicks inside a text field and enters data.
The user would then click a symbol on the toolbar and it will be appended to that specific text field.
The browser ... |
This class allows for easy management of the KeyboardState of an XNA game.
It provides a simple, easy-to-use API for interacting with the Keyboard and getting key-presses, via a few (trivial) events.
As far as I can test, it works as intended.
GitHub Link (for future reference) as of this version: KeyboardStateManager.... |
I have the following code:
public final class PropertyFileLoader {
private static final Logger logger = LoggerFactory.getLogger(PropertyFileLoader.class);
private final String propertyFileName;
public PropertyFileLoader (String propertyFileName) {
this.propertyFileName = propertyFileName;
}
... |
Due to some constraints I had to manually parse an HTTP response coming out of a stream.
I could not use buffered reader or scanner because the perform buffering and end up buffering bytes beyond the response header itself.
I'll be hitting my AWS S3 and only expect 200 or 206 status response.
This seems to work, but I... |
I was inspired by this answer and decided to implement an AVL tree with the methods equals and hashCode as if I was asked to do that at a job interview.
This is my code on GitHub.
In addition to the solution itself, I wrote tests for all the possible cases. If I missed something, or if my solution has any bugs, please ... |
I have the following that loops through a range. When the initial value is found on the second sheet it goes to the cell to be able to compare some date values on the same row. Once the comparison is complete another value from the same row is copied to be placed back onto the first sheet. I believe the Application.... |
The task of this project was to create a method that takes in an array of stock prices, one for each hypothetical day. From there, the method should return the best day to buy and the best day to sell the stock to maximize return.
A few ground rules:
Stocks need to be bought before they can be sold
It is possible th... |
I am using this code to display all the permutations of a given input string. Any advice/solution will be very helpful.
#include<iostream>
using namespace std;
/* Function to swap two characters */
void swap(char& a, char& b)
{
char temp;
temp = a;
a = b;
b = temp;
}
/* Function to obtain permutations of string c... |
My code reads in the data using DictReader, then creates a header row that contains my composite key (PEOPLE_ID, DON_DATE), and then adds various values that are distinct to each section. The output looks like this:
-01- PEOPLE_ID, DON_DATE, etc...
-02- dataline
-02- dataline
-01- ...
etc...
I'm looking to possibly s... |
I have implemented an upgrades system in my Unity3d game, and I am pretty sure that I am not doing things in an optimal way. Any advice regarding best practices would be much appreciated.
The idea is that when the player collects a powerup, their run speed and jump speed increases. Collect enough powerups, and you can... |
I have made some simple functions to find the first SO chat message. How can I improve my code?
Even if there is a stackoverflow link that will get the job done (I'd be glad to know), I'd like to improve upon my already written code.
import Network.HTTP
import Text.Regex.Posix
type UserID = String
type MessageLi... |
The chart data is stored in a nested dictionary struct @line_charts, and I need to convert the prices to target currency with the function exchange_datasets_currency. It should finally return the @chart in the end of method.
Is there any way to improve my pattern?
def sample_a
@line_charts = [get_line_chart(@from, ... |
This code returns true if the sentence is a palindrome, and false otherwise. Is there a better way of doing this?
def palindrome?(sentence)
array_stripped_sentence = sentence.reverse.downcase.delete('').split('')
array_stripped_sentence == sentence.downcase.delete(' ').split('')
end
puts palindrome?("Never odd ... |
I'm building a HTTP API and this part should return a JSON list of posts and their attached photos, like this:
[
{
"id": "788",
"content": "Foo bar! Foo foo, bar bar.",
"photos": [181, 282, 182]
},
...
]
And this is my PHP code handling the request:
// get all the posts and their ph... |
I started coding in Scala some time ago, and also learning some fundamental algorithms in CS.
Here's a terribly slow implementation of Kosaraju algorithm to find strongly connected components in a graph.
I'm looking for three things:
Learning how to use Scala data structures
Learning how to implement this algorithm in... |
Here is a small code snippet I wrote that I feel is pretty naive. I copied the code directly from my project and renamed some ID/class names.
I'd like to know how you could help to improve/refactor the code. radiobox1 and radiobox2 form a pair, and radiobox3 and radiobox4 form another pair - they're both mutually exclu... |
I have an image which I know the number of rows and the number of columns. I would like to calculate the limits of the new image after a rotation.
BufferedImage myImage = ImageIO.read( new File( "D:\\Users...jpg" ) );
xmaxOrigine = myImage.getWidth() - 1;
ymaxOrigine = myImage.getHeight() - 1;
angle = 12... |
I had the idea to have a static method on an activity which creates intents that it can use. For example if I have an activity with a webview that can load html from a resource or a URL I would have 2 methods in the activity like so.
public static Intent createURLIntent(Context context, int titleId, String URL) {
I... |
Is there a better way to implement a binary search than I am in my code? My function is taking two two lists - first_booth_voters and second_booth_voters with second_booth_voters being sorted and first_booth_voters not sorted. I feel like I am making an unnecessary amount of comparisons.
from classes import VoterList
... |
I am experimenting with making my own re-usable libraries. Therefore, I decided to start with some of the plots that I generally use during development/debugging to check what is actually inside my data.
My questions therefore are:
Would this be the correct way of writing a library?
Are there any pieces of my code tha... |
I am new to programming and I am trying to make a simple unit converter in python. I want to convert units within the metric system and metric to imperial and vice-versa. I have started with this code and I found this method is slow and in-efficient, How can I code this more efficiently?
import math
import time
"""Unit... |
I made a simple routing class that I like to get reviews for, mostly because I do not know how to make it SOLID, since I even made this class separate from the HTTP response/request for the sake of SRP.
All this class does is route-specific, which seems like solid enough to me.
The actual library can be found at fastp... |
After the feedback for my last script, I realized I should be using functions and trying to adhere to the style guide. I tried to do that here, though still very beginner.
The rounding in Python confused me a bit, and originally the program got stuck for some numbers when the range narrowed down to 1. I think it should... |
Every piece of business that gets written (E.G. an adviser's client puts an additional £10k payment into a pension plan) goes in a spreadsheet called the SubSheet. It's split into 8 worksheets for different kinds of business, each with lots and lots of columns. E.G. "Adviser" "First Name" "Investment Amount" "Commissio... |
This is a contest problem;
Description:
In the winter, children started to build snowmen. The snowmen were becoming adorable, except for a detail: none of them had a nose. The king, touched, decided to give some of his carrots away so they could be distributed in rectangular-shaped regions of the Town. But the childre... |
Here is my solution in Haskell for the Euler problem #101. It relies on building a specific base of polynomes given the values we want to fit (memories of my linear algebra courses from a long time ago). The algorithm is quite fast but as a new Haskell programmer, I'd like your opinion on what could be done to improve ... |
I created this function that allows you to declare a string, then multiple instances of a substring. This uses a hash map to keep track of strings that have already been searched for and upon each call of its returning function will give you the next instance of that substring.
I'm wondering if there's a way to do this... |
I've written a password encryption algorithm in PHP, which (I think) is not very vulnerable to rainbowtable attacks. It's just that I don't have a lot of experience with encryptions, nor PHP. But from the knowledge I have I think this is a hashing algorithm which automatically adds salt, but I actually have no idea if ... |
The purpose of these two classes (and hence why I am including them together) is to allow you to create a Camera, that indicates a "render zone", and track an object in this Camera, so that when the Position of the ITrackableObject changes, the Camera.Position changes to reflect that.
Ignore the unimplemented Camera.Ce... |
I have an array vs.tags which may contain hundreds of objects, and a smaller array coloredTags which only contains up to 3 objects.
The goal is to efficiently check the ids in coloredTags to the ids in vs.tags and perform some action.
This is what I have so far:
var coloredTags = ColoredTagFactory.retrieveColoredTags()... |
I wrote this recursive function to get all constants from a class and its subclasses. Can it be simplified?
private static IEnumerable<FieldInfo> GetPublicConstants(Type type)
{
var subtypes = type.GetNestedTypes(BindingFlags.Public);
foreach (var subtype in subtypes)
{
foreach (var constant in Get... |
Everyone knows "99 bottles of beer on the wall".
Mat's Mug made a comment about mugs on the wall in The 2nd Monitor and I realized I never wrote a "beer on the wall" program. But that seemed way too easy, so I made it a "n number of x on the y" instead. It also seemed like a good excuse to use templates in Python, whic... |
I wrote a little bit of code in JavaScript that takes an array of objects and does some sorting, then outputs to an HTML page. I set a goal to do it without any frameworks, and in functional style on purpose to learn vanilla JS. It would be nice if someone could highlight any bad code or bad practice, and how I could i... |
I have just discovered the beauty of prepared statements in PHP and how they protect against SQL injection. In my first time using them, I am attempting to grab a hashed password from a database and seeing if it matches up against the password the user inputted into the login form.
Is this the most efficient way to:
G... |
When looking at people you may know on LinkedIn (requires you to be logged in) there are sometimes some annoying boxes that are for people who are email contacts but not on LinkedIn. I don't want to see these. If I wanted to connect with them and invite them to LinkedIn, I would have. So I wrote a userscript! I wro... |
The prime 41, can be written as the sum of six consecutive primes:
41 = 2 + 3 + 5 + 7 + 11 + 13
This is the longest sum of consecutive primes that adds to a prime below one-hundred.
The longest sum of consecutive primes below one-thousand that adds to a prime, contains 21 terms, and is equal to 953.
Which prime, bel... |
As part of a larger project I'm working on, I've made a function that aims to replicate, as best as I can, the placeholder part of the console.log() function usable in most browsers.
It replaces %s, %d , %i , %f and ,%o. It works by having 'unlimited' parameters (the replacements), looping through the parameters, check... |
I have built a Caesar Cipher in Ruby that utilizes ASCII for the encryption. I am not sure whether or not this was the best way to go about the task but this way made the most sense to me. Please give me any feedback that comes to mind.
puts 'Please enter your string to be coded'
string = gets.chomp.split("")
puts... |
I need to compute the number of target values \$t\$ in the range: \$-10000 \le t \le 10000\$ (inclusive) such that there are distinct numbers \$x, y\$ in the input file that satisfy \$t= x+y\$. I have the code which does work and would like to optimize it to run it faster.
Also, we'll count the sum \$t\$ only once. If ... |
I changed the normal way of using Angular. I'm using my controllers just to talk to my API routes and am using directives to manipulate the data and DOM as well.
I am using the object literal pattern where I have my INIT method that initializes global variables (object) and then calls other methods, bind clicks methods... |
I am learning how to implement testing and try/catch statements into my code. I have a Laravel application with the following method. I am looking for advice on where I should add in try/catch statements and what phpunit unit-test(s) I would create to ensure this is functioning properly. Tips on comment blocks are also... |
I'm adding three attributes to a Django QuerySet that represents a hierarchical tree structure:
a display_name which is added to all objects
the id of the object's parent (or immediate_parent) which is added to all objects based on a condition
a boolean is_parent field that should be added if and only if the object ha... |
I am finding the order of sorting of an array. The code works but can it be made better especially the return values of the function findSortOrder.
#include <stdio.h>
#include <stdlib.h>
// Returns 0 for unsorted, 1 for sorted in increasing order, 2 for sorted in decreasing order
int findSortOrder(int array[], int len... |
I am given two strings and return the position if in the larger string the smaller string is found. If not I am returning -1 for position. Any suggestions for improving my code.
using System;
using System.Collections.Generic;
using System.Linq;
namespace Reverse
{
class MainClass
{
static int IsFound... |
I have implemented the Salsa20 stream cipher as an ICryptoTransform. It runs fairly fast and has successfully encrypted and decrypted all of my tests. I would mostly like the Salsa20 algorithm to be reviewed (since there are very few reference implementations in C# out there), to make sure I haven't missed anything. I ... |
I got rejected in tech screen yesterday. I was asked to write a JavaScript function and send it over email. I have also added hiring manager's response at the bottom.
Could you please write a JavaScript function to compare two strings that look like phone numbers and indicate whether the digits in both strings match? ... |
This is my code to solve HackerRank's version of Project Euler Problem 91: on an N × N grid, find the number of possible right triangles where one vertex is (0, 0) and the other two vertices are integer grid points.
I know its an open challenge, but it is not for any job related coding, and I have also partially solved... |
The objective: Given an m by n matrix, I have written a function in Matlab that reorders the columns of the matrix to output linearly independent columns; other/redundant columns. Basically, it just pushes the redundant columns to the end of the matrix.
Here is my attempt at the code (which produces correct results): ... |
The whole process mainly depends on the ProcessFile() function:
I get all the credentials and details from a JSON file.
Initially I get data from the db: two IDs and a URL.
There is a text file for address state matching, reading, and compiling with | to match regex.
The same is done for zip and zip keywords.
Iterate ... |
Given an array and a string and bounds within which to search, I need to find the position of the string within those bounds.
What I want to optimise:
If possible, I want to re-design the function so that it doesn't have 10 optional arguments, some of which are not actually optional depending on the size of the array... |
I am using WinBGIm.
#include <iostream>
#include <cmath>
#include "graphics.h"
void Swap(double &a, double &b)
{
double x = a;
a = b;
b = x;
}
double Round(double number)
{
return (number >= 0) ? (int)(number + 0.5) : (int)(number - 0.5);
}
void PlotPixel(int x, int y, int color)
{
const int rad... |
I'm trying to refactor some code I wrote months ago when I used to use lots of anonymous functions. The way I'm trying to do it now is by taking all those functions and rewrite them within Object Literal Pattern.
I'm new to this kind of pattern and I would like to know if I'm doing it right, what should I improve or if... |
I am trying to write for both NT and POSIX (my two usual platforms) and have come up with the code below. The clrs code I refer to is apparently from blender build scripts, I discovered it on this SO post. They called the class bcolors but I wanted to reduce clutter so I renamed it.
But the main class is what I've writ... |
I am debugging one legacy J2EE application I and think I found some dead code and some redundant condition checks. Please give me your thoughts on my observations i.e. if they are valid. Please note that I am not permitted to rewrite this block, only to fix something if wrong or redundant.
...
else if ((emailList != nu... |
Given a folder typically containing ~250,000 small (20-100kb) files in HTML format (they open as single-sheet workbooks in Excel) and a list of ~ 1 million filenames, I need to open all the files that match the list and Do Stuff.
Overview of Main code Loop: "Test 1 Start" to "Test 1 End"
Once we get to the main file lo... |
I created a login service which holds a boolean based on if a user is logged in or not.
angular.module('deafApp')
.service('LoginService', function(){
var $this = this;
$this.loggedIn = false;
});
Inside my login controller (LoginCtrl), I attach the LoginService to a local scope object an... |
I'm using Bootstrap 3 to build a tab-panel component, based on information coming from the end-user. I don't like how there's a second foreach loop, but I don't know how else to print the HTML correctly.
Given an array structured like this:
[
{
"title": "Title 1",
"content": "Lorem Ipsum"
},
... |
I decided to create simple blog app by using Ember.js which should has the following interface
For this purpose I created blog route which contain the following code:
import Ember from 'ember';
export default Ember.Route.extend({
setupController: function (controller, model) {
controller.set('currentPost', 0);
... |
This VBA macro uses a worksheet (source_data_worksheet) to filter and split out the records based on about a dozen unique column (D) values in a dataset of about to separate workbooks which are saved to a folder.
There are over 10,000 records x 18 columns total with text and numbers (the overall file size of source wor... |
pairs() is a function which returns the total number of combinations whose difference is k.
static int pairs(int[] a,int k) {
int counter=0;
for (int i : a.length ) {
for(int j=i+1;j<a.length;j++){
if(a[i]-a[j]==k||a[i]-a[j]==-k){
counter++;
... |
I wrote a simple javascript program that takes a user's input and calculates the cost of their commute. I feel like I'm repeating a lot of stuff though.
How could I refactor this to make it cleaner and more concise?
function calcCost(costOfGas, vehicleMPG, numMiles) {
var dailyCost = (costOfGas / vehicleMPG) * (numMi... |
Sometimes, there's the need to verify if a given number is an integer or a decimal. Since JavaScript doesn't distinguish between both, I've made an extremelly basic function.
function isInteger(num){
var numCopy = parseFloat(num);
return !isNaN(numCopy) && numCopy == numCopy.toFixed();
}
As you can see, it rel... |
I decided to write a function that would generate an index of the Fibonacci sequence making use of Python's mutable default parameter. It's inspired by a question I answered on Stack Overflow where someone was converting a script with this idea from JavaScript to Python and I wanted to expand on it to see how I could h... |
I'm a web development student, and I made a chat bot that emulates an SMS app commonly found on smartphones, etc. It responds with random lorem ipsum text. I'm wondering if my functions are too long and how/if I should refactor further. For instance, when building the chat bubbles, would using a DocumentFragment or clo... |
I'm developing a web application allowing a logged-in user to find most correlated stocks for selected stock ticker. The user chooses a ticker, period of time (10, 30, 60, 90) and type of correlation (KENDALLS, PEARSONS, SPEARMANS). Then on the server side, the 'magic' happens and the server responds to the client by p... |
This is the current very repetitive and long SQL I have. Unfortunately I'm not that good at SQL to group this and get rid of the repetition.
select * from Mail
where admin_status = 1
and admin_id = 4
and core_event_id =0
and user_id !=0
and mail_reply_status = 0
and sent_to = 0
and admin_inbox_date > DATE_SUB(CUR... |
I have input of a string containing a single number (like: \$3\$) or a range (like: \$1-5\$). Sample input, all together, looks like: "1-5,3,15-16", and sample output for that input looks like "1,2,3,4,5,15". Output doesn't need to be sorted.
I built something to parse this, but it's ugly. How can I improve this?
from ... |
Here is the solution I've written for Hacker Rank Candies challenge.
It uses dynamic programming (memoization in a boxed array).
I'm interested on what could be done to improve this code in term of style and performance (although it passes all the testcases of the challenge)
For example, I wonder if the bunch of guards... |
I started learning AI recently. In AI, searches should be avoided and everything in AI is a search problem.
One of the easiest problem where we could use general AI search techniques is the water jug problem which states:
You are given two jugs, a 4-gallon one and a 3-gallon one. Neither has any measuring markers on i... |
I use this piece of JS code to login to my bank and get the balance. This code snippet works, but I wanted to know if I could make this code smaller, faster or if I could anything differently to improve it.
casper.start(url, function() {
console.log("Checking login status @ " + url);
this.waitForSelector("for... |
I have a Collection of 166 elements:
Dim MyCollection As New Collection
MyCollection.Add ("%")
MyCollection.Add ("%O")
MyCollection.Add ("D")
MyCollection.Add ("CMS")
...
I want to compare them to the value of the cells in a column. If the value of a cell is not in MyCollection, I change the background color to red.
F... |
I am always super annoyed when I have to write a bunch of if statements whenever I have to traverse an object graph of possibly null objects. As there is not yet a ?. operator I resorted to creating this wonderful piece of work: TryGetProperty. Please tear it apart. This was written for LINQPad.
public bool TryGetPrope... |
I am making a space-themed shooter game, and I need to render many "lasers" at the same time. I am using the library Slick2D, a wrapper around lwjgl. Unfortunately, when there are a lot of these "lasers" on the screen at one time, the game drops from its usual 60 FPS to around 30 or even 20.
Things I've noticed:
Not c... |
I wrote a small function to return a random in a given range:
int random_in_range(int min, int max) {
std::random_device rd;
std::mt19937 rng(rd());
std::uniform_int_distribution<int> uni(min, max);
return uni(rng);
}
But I read somewhere that you should only seed a random number generator once leading... |
I have just somewhat completed a program, and was wondering what I could do to improve readability, and design as some functions seems to be rather large and an eye-sore.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Text.Reg... |
Suppose I have an array of sentences:
[ "How To Format", "put returns between paragraphs", "for linebreak add
2 spaces at end" ]
I want to print it like this:
How put for
To returns linebreak
Format between add
paragraphs 2
spaces... |
In generic code, I sometimes want to conditionally add a data member to a class template. Writing separate template specializations scales as 2^N for N conditional data members. Absent a static_if feature, I have found the following user-defined class templates empty_base<T> and optional_base<T> useful:
namespace xstd ... |
I have written a mergesort in Python/Numba:
import numba as nb
import numpy as np
@nb.jit( nopython=True )
def merge( x ):
n = x.shape[0]
width=1
r = x.copy()
tgt = np.empty_like( r )
while width<n:
i=0
while i<n:
istart = i
imid = i+width
ien... |
Racetrack:
The August community challenge is to implement a program that plays the Racetrack game. Each player starts with an integer position on a square grid. On each turn, the current player can accelerate by -1, 0, or 1 unit in each direction. The first player to reach the finish line wins.
This is a Java implement... |
Racetrack
The August community challenge is to implement a program that plays the Racetrack game. Each player starts with an integer position on a square grid. On each turn, the current player can accelerate by -1, 0, or 1 unit in each direction. The first player to reach the finish line wins.
Most of my Java implement... |
I have recently written some code in Bash where I'm starting to program some things and I think I'm overcomplicating the script I wrote.
I'd like to make it simpler so that in future I would avoid these mistakes.
I've posted this on Stack Overflow and one user did reply that I can "simplify" multi-echoing:
just use 1 ... |
The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be:
1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...
Let us list the factors of the first seven triangle numbers:
1: 1
3: 1,3
6: 1,2,3,6
10: 1,2,5,10
15: 1,... |
This singleton is responsible for counting every pageview (called Routes in our case) we get by id, until the timer runs out and commits the results to the database in one query. Then the counter gets reset and the timer starts again.
I made this to reduce the amount of connections happening on our database at a given ... |
I'm new to Python and I'm trying to convert between Microsoft GUIDs and plain hex strings:
def hex_to_guid(hex):
h = binascii.unhexlify(hex)
return '-'.join(map(bytes.decode, map(
binascii.hexlify, (h[0:4][::-1], h[4:6][::-1], h[6:8][::-1], h[8:10], h[10:]))))
def guid_to_hex(guid):
g = binascii.u... |
I have code that fetches different templates for HTML and CSS in the file system. The templates are stored in different folders, so I have two implementations for the code that fetches them, passing the correct path as a parameter.
private string _templatePath;
private readonly IConfigurationManager _configurat... |
I have this code querying for some objects from my database with Flask-SQLAlchemy:
areas = Area.query.all()
subareas = Subarea.query.all()
And then I use it on html with Jinja template to display data:
{% for area in areas %}
{% if area.number=='0' %}
<select id="{{ area.number }}" class="subarea" onchange... |
Find the thirteen adjacent digits in the 1000-digit number that have
the greatest product." eg, the product of the first four adjacent
digits is 7 * 3 * 1 * 6 = 126
public class Java {
public static void main(String[] args) {
String temp = "731671765313306249192251196744265747423553491949349698352031277450... |
Zend framework 1. Physically, the file does not exist, it is created based on database.
Okay so use header?
public function downloadAction()
{
$id = $this->getRequest()->getParam("id");
$optin = new Application_Model_Optin();
//$data = $optin->getCodesFromDownload($id);
$data = array(
array('cod... |
I am new with async task in C# 4.5 and feel insecure about this:
I want to create a Windows Service that listen messages from a network (similar to msmq for example), when a message is received, do stuff not CPU bound (call webservices and rest API) without blocking other messages.
I created this console application in... |
I have programmed for 2 months, and I began writing a Chess game. I am a beginner programmer in Python, so please assess my code.
class Chess_Board:
def __init__(self):
self.board = self.create_board()
def create_board(self):
board_x=[]
for x in range(8):
board_y =[]
... |
So I have an Entity, which is responsible for providing an abstract base for other objects to inherit. (Like Actor objects, which are people, Creature objects, which are animals, etc.)
The Entity provides a solid foundation for Actor and Creature to interact with, I'm just curious if it's not gone overboard or if I've ... |
This is a reservations software for hotel and restaurant management, allowing you to add and delete rooms, show available rooms, keep track of reservations etc. I am looking to trim my code a bit and improve upon the style since it's a little cluttered right now. I believe the use of classes will help rather than makin... |
I have written this code to build a list by looking inside directory within deep to the level it finds a audio file and then move to the next level or next folder.
Can there be a more efficient way since a user can have any number of files? Do you think it can be achieved more robustly in terms of performance?
path = '... |
I want to learn OO design and as a start, I implemented Tic Tac Toe. I'd like to hear your thoughts on the design and implementation.
Classes:
Player - Has just a name as of now. I hope to develop this more to use for other similar situations.
Board - Has a 3x3 matrix and takes care of checking if game is over and if ... |
I have a file on my server which contains a running output of a script. This file is constantly changing and fluctuates in size between 0 - 1Mb. Now I want to take this file and make it viewable from the web. Currently I am using jQuery to get the file then I set a textarea's value to be the file content. In order to m... |
I have an Ajax request from a page where the user is being asked to enter their date of birth. The request URL file has the code below and works all good. However, I'll be rewriting all MySQL/MySQLi functions used on the same website and this is generally how I use prepared statements. Should I avoid using die();? Is t... |
In an array of strings 'a' having 'n' strings i have to select the Palin Pairs from the given strings .for ex for input 3 bba abb abb Output=2
I am getting correct output but want to reduce time complexity....what other logic or enhancement I can use to optimize the code
import java.io.BufferedReader;
import java.io.In... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.