instruction stringlengths 71 71.9k |
|---|
I just started working with ASP.NET MVC a few weeks ago, and I'm finding that it can be very easy to write spaghetti code in the controllers. For my first project, I created a very simple view with a few controls. At first, all of my code was in the Index() action result. That worked okay for a while, but as more fe... |
My project for my class is to create a Java-based game where the user must enter a number between 1-20 and a number between 250 and 300. The computer randomly chooses a number between those 2 numbers. Then the user has 10 guesses to correctly guess what number the computer is "thinking of."
There is a catch, though. We... |
I am struggling with commenting and variable naming. My teacher says my comments need to be more explanatory and explicit. He says my variable names are also sometimes confusing. I was just wondering whether you could go through my code, see whether you are able to understand the comments and whether the variables name... |
I'm debating which version would be more suitable in parameters of code length, readability and maintenance. This is a portion of a set of functions which together parse a Gif file.
Version 1:
if ((errno = GifLoadHeaders(g, &bufTemp)) != GIF_SUCCESS) {
GifDispose(g);
*gPtr = NULL;
return errno;
}
if ((err... |
I can't seem to get the formatting right, so here is the pastebin if needed:
http://pastebin.com/g6VmdYbM
public class Hangman {
///////////////////////////////////
// Global Variables
///////////////////////////////////
private static String[] correctPhrase = new String[5];
private static String[] currentGuessPhrase ... |
Coming from Java and Android development and Objective-C still is a bit strange to me, but I just went in head first and started writing code. Before I started getting really far into it, I just want to throw some basic code here for suggestions about correct syntax, etc. I just want to make sure that my variable and f... |
I have become interested in reflection and I wrote a class to wrap an Object so that I can access its private instance fields. The code works great. I do not need to wory about the exceptions in the get() and set() methods because I cast the values appropriately through my wrappers accessor/mutators, but I was wonderin... |
I am trying to implement the F1 score shown here in Python.
The inputs for my function are a list of predictions and a list of actual correct values. I thought that the most efficient way of calculating the number of true positive, false negatives and false positives would be to convert the two lists into two sets the... |
I'm making this little game for programming class. Not as an assignment, but as a small side project. Just wanted to point out I do not know a lot about Python, so please don't be harsh, but I can take constructive criticism.
from scene import *
from random import random
import console
import canvas
console.set_color... |
I recently received a 'good, but not good enough' rating on a coding exercise I was asked to perform. It was to validate that if "Product complaint" option was selected that Product name, Product size, Use-by date and Batch code fields all needed to have values. What can I do to improve the JS to go from 'good, but not... |
I've written a simple function for building a prefix tree (and searching):
import qualified Data.List as L
import qualified Data.Map as M
data Tree a = Empty | Node a [Tree a] deriving (Show, Eq)
partitionBy f = map snd . M.toList . M.fromListWith (++) . map (\x -> (f x, [x]))
buildTree value dt = Node value (map (\x -... |
So I'm writing some code to perform a quite specific task given a large numpy array with N rows and 3 columns representing points in 3D. The 3D points are to be binned along one of the dimensions between specified bin edges. For each of these bins, there is a set fraction by which I must reduce the number of points in ... |
I have created a Drupal 6 module that sends messages through PubNub when the user updates information about a Node. I have a separate app that, when launched, calls my Drupal site and receives a JSON array containing a lot of information about some nodes. I then update the info in my other app by PubNub->publish from D... |
Suggestions for cleanup and optimization request.
This question is a follow-up question on this post.
Lets assume the range of
1, 2, 3, 4.
This function takes in an array of repeated elements, [1,1,4,4] and the output is [2, 3].
The question marked as duplicate takes an input of [1, 4] and output is [2, 3].
Whil... |
This is my forked branch attempting to make the code better, This is an application for having a slide show of photographs in current directory or supplied as argument.
Use keyboard controls[left to go backward and Right key to go forward and spacebar to toggle play/pause] only.
File 1. utils.py
import os
import sys
d... |
Suppose I am listening for network changes with the following listener:
interface NetListener {
void onNetworkAvailable(boolean isWifi);
void onNetworkUnavailable();
}
I want to have an object, accessible from anywhere within the app, holding the registered NetListeners, that can trigger the appropriate meth... |
I have something like that:
My custom exception class:
public class SolvableException extends RuntimeException {
protected boolean solved = false;
public SolvableException(String message) {
super(message);
}
public void setSolved() {
this.solved = true;
}
public boolean isSo... |
I am looking to make a generic config file using variables such as:
$PLACEHOLDER_USER
Then after moving the file into the correct position I want to replace every instance of *$PLACEHOLDER_VARIABLE* into the value of $VARIABLE from my settings.sh file.
In the example below *"$PLACEHOLDER_USER"* in log.conf would be re... |
I'm dealing with huge amount of data. I've written following code into a function to find out similar questions. It's working perfectly but it is taking too much time in execution. Can anyone help me to optimize the function code so that the execution time will be less?
<?php
class QuestionMatch {
var $mError =... |
I'm trying to solve a programming challenge for fun. The programming challenge is here and my solution for the same can be found here.
It currently causes an exceeded time limit.
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
int a[25001];
bool is_edit... |
I attempt to create a reusable and scalable Cron Wrapper in PHP.
I'm at the begining of the project and I wanted have some tips/ critics / improvments to make before going too far.
The final objective is to have a complete cron wrapper which allows to lauch :
'one-shot' task (like huge DB export) from Web
manage Cront... |
I'm working on an application which has a defined and immutable (for our purposes) communication protocol. One of the features is that users on the controlling terminal can enter text commands that in many ways mimic interacting with a commandline application.
The structure of these commands (wrapped within a normal co... |
I'm working on a path planning algorithm that will be converted to RobotC. I'm trying to optimize it so that it uses the least amount of memory, as the robot it will be implemented on has supposedly as little as 15k available memory.
It may just be the nature of the algorithm used, but it is apparent that it is making ... |
I have written about 180 lines of code that implements an Event system.
I would like a general review about the code and I'd love comments about the usability of it. (Is the code useful? Would you like to use it or a similar system like it?)
Summary of the parts involved
IEvent is a marker interface for event classes
... |
The code works just fine, but recently performace has taken a hit and it has SQL Timeouts far too often. I have it set up so I can run 50 different version of the application two for each different m.qlevel.
This allows it to run fairly fast, but the SQL timeouts are requiring to much babysitting.
document_attachments... |
I would like advice on making my code more elegant and straightforward. The code works great, but it lacks these things.
<?php
if(isset($_POST['retrieve_posts'])) {
$post_ret = $_POST['retrieve_posts'];
}
if(isset($_POST['retrieve_images'])) {
$image_ret = $_POST['retrieve_images'];
} else $image_ret = 0;
req... |
I was tasked with refactoring our existing IniReader class, which is Windows only compatible, to be cross-platform ( specifically UNIX compatible ). We decided that boost::property_tree was a good fit for this and a quick play with property_tree confirms this.
The original class had many readValue overloads for the var... |
As a school project in my navigator 12 class, I've decided to try and learn Java. I thought that I'd try and make the Game of Life, because it would be a good way to start learning Java (watched a bunch of Java tutorials).
Could I get your feedback on this program I wrote? I would like input on if everything is inputte... |
As shameful as it is to say I wanted to see what all the fuss about was with Tinder, but after downloading it I found I was more interested with its animation effects and started wondering how they did them!
I decided I wanted to see if I could replicate some of them using jQuery so they can be used on web apps and sit... |
I have an assignment as follows:
Write a program which reads from the keyboard two integers n and m,
and a character c from the keyboard. This program should define and
call a function:
print rectangle(n, m, c) which prints a rectangle of
size n x m consisting of the character c
My solution is:
n=int(input("E... |
Here is a small library which manages writing into and reading out a byte array. It uses TValue arrays to get and put data, its my first time using them. Its crudely written, and poorly optimized but I tried to make the best solution in the 3 hrs I was given to build and debug it. Right now it only supports Integer, St... |
I found myself writing code of the form...
val foo : Foo = ???
val step1 : Foo = {
if ( someCharacteristic( foo ) )
someTransformation( foo )
else
foo
}
val step2 : Foo = {
if ( otherCharacteristic( foo ) )
otherTransformation( foo )
else
foo
}
val result = step2;
That seemed awkward, and it ... |
We have a large directed acyclic graph and a requirement to filter it by allowing a user to select certain nodes and then we remove all nodes that are not selected nodes, ancestors of those nodes, or descendants of those nodes.
As you can see in the above image nodes 6 and 9 have been selected and so nodes which do no... |
I have this code which will store user session credentials:
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public class SessionCache
{
/**
* Default Constructor
*/
public SessionCache()
{
}
/**
* Map which which will store C... |
just wanted to check with you could this be done better:
awk -F"\t" '{
for (i = 1; i <= NF; i++) {
if ($i != "NULL") {
printf("%s%s", $i, FS);
}
}
printf("\n");
}' file1
The goal is to print only non-NULL fields. For example:
echo "TestRecord001 NULL NULL Age 29 NULL ... |
I have implemented several lock-free algorithms to maximise throughput but have always baulked when performing a spin-lock. I can usually convince myself that this is the only way but it still nags at me that a spin-lock is a terribly bad idea.
I recently came across a FIFOMutex code fragment and thought perhaps that w... |
I'd like to have this code looked over because I feel my approach might be very novice and there has to be a more elegant or at least less "grunt-work" way of doing it.
I have to write a small TCP client in my application which can send an object to a server for it to be stored in a Database. Before I send the object I... |
I am trying to implement a function below:
Given a target sum, populate all subsets, whose sum is equal to the target sum, from an int array.
For example:
Target sum is 15.
An int array is { 1, 3, 4, 5, 6, 15 }.
Then all satisfied subsets whose sum is 15 are as follows:
15 = 1+3+5+6
15 = 4+5+6
15 = 15
I am using jav... |
I have an assignment as follows:
Write a program where you can enter from the keyboard up to 10
integers. If the number entered is equal to -99, stop reading numbers
from the keyboard and compute the average and sum of all values
(excluding -99). Print the average on the screen. Make sure you
consider all the ... |
I am developing a GUI using Swing, but before my project gets too complex. I would like to have a good design structure. I have a few ideas and will use a simple example to illustrate. Some feedback on whether or not this is a good approach would be great.
This is what my GUI looks like:
There are 2 Jpanels LeftPan... |
I have written a method that uses binary search to insert a value into an array.
It is working, but i would like to get a second opinion to see if i didn't write too much code for it. aka doing same thing twice for example.
The code looks for the right index for insertion and is called by an insert method that uses tha... |
I have a List of objects, List<myObject> objectList, and each object contains a List of strings like so:
myObject: StringList( "A_1", "B_1", "C_1", "D_1", "E_1", "F_1" )
myObject: StringList( "A_2", "B_2", "C_1", "D_2", "E_2", "F_1" )
myObject: StringList( "A_2", "B_3", "C_1", "D_3", "E_2", "F_1" )
I'm trying to... |
Whenever I create a Javascript "class" I do something like this:
// Definition
function MyObject() {
this.id = 0;
this.legs = 2;
}
MyObject.prototype = {
walk: function() {
// Do stepping
},
stop: function() {
// Stop stepping
}
};
// Instanciation
var TestMyObject = new MyObject();
TestM... |
Should I leave the Default Route in if it's not adding any benefit?
I have a RouteConfig.cs file that looks like this:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Dashboard",
url: "{controller}/{action}",
... |
I need to build the following XML document
<?xml version="1.0"?>
<SFDocument>
<TableID>5415</TableID>
<PageSize>1</PageSize>
<PageIndex>1</PageIndex>
<MultiCompany>No</MultiCompany>
<Language>1033</Language>
<Fields>
<Field>Operation No.</Field>
<Field>Line No.</Field>
<F... |
How can I rewrite this code to make it more readable and, if possible, more efficient? The conditions are entirely necessary in this problem, but how could I rewrite those if(a != 1) and such?
celula ** verificaNo(celula ** matriz, int linhas, int colunas){
celula ** aux = matriz;
int i, j, k;
int node = 1;
int a = 0;
... |
This code basically connects to a database, sets login success and failure pages, queries the database for user details, checks if user is active, sets session value and redirects accordingly.
Can you have a look? What do you think of it? Any suggestions?
<?php
session_start();
// Connect to the database
try {
$d... |
I am trying to simplify the below if else statement, and I think it can be done.
Algorithm is like this -
If user_ptr exists, then lock attrmap, find user_ptr. And if it
is a batch, then don't ping. And else if user_ptr doesn't exists
and if it is not a batch, then do other stuff. But if it is a
batch and user... |
I have been implementing a delegate class with C++11 that supports class member functions. I am interested in knowing if there are any potential problems with this implementation. My main concern is the private Key struct of the Delegate class. Can I always rely on the key being correct in all situations? Meaning, can... |
Euler problems (projecteuler.net) often invites to quick and dirty solutions.
While hurrying through Problem 32 I found myself in want of the std:: toolkit. Not sure what it is though.
The problem description is included in the first comment.
I would really appreciate any suggestions as for the usage of the tools prov... |
I have a Combobox and I want to edit a boolean value.
<dxe:ComboBoxEdit ItemsSource="{Binding EnumItemsSource}"
DisplayMember="Name"
ValueMember="Id"
IsTextEditable="False"
EditValue="{Binding TargetValue, U... |
I have to do a task hard for me and maybe you can help me. I've tried to design a window dialog to update data from a database view. This database view contains integer, DateTime, string, Time, Boolean properties.
First of all, I load the database view data into a GridControl. The GridControl is readonly not editable.... |
Below is my java code with some complexity,
String input;
double a;
if (null != input && !input.isEmpty()) {
a = Double.parseDouble(input);
} else {
a = defaultValue;
}
With Guava, we can compress the code from 5 lines into a 'single' line,
a = Double.parseDouble(
Objects.firstNonNull(Strings.emptyToN... |
A little while ago I was fiddling with dependency-injection and came up with this small WPF application that I can launch with command-line arguments.
Not only this was my first experiment with DI, it was also my first experiment with parsing command-line arguments. The result works nicely, but looking at the code toda... |
I'm visualizing my stored data in an histogram similar to this one:
However, I'm sure that my code smells a lot! So I'd like to have your opinion on how to make it better.
$listings = array(
array('Price' => 10),
array('Price' => 10),
array('Price' => 11)
); // so... |
I need to merge some large csv files but I feel that the way I am doing it is not optmized. It gets a number of csvfiles and creates one
public static void MergeFiles(IEnumerable<string> csvFileNames, string outputPath)
{
var sb = new StringBuilder();
bool hasHeader = false;
foreach (string csvFileName in c... |
This is roughly what my data file looks like:
# Monid U B V R I u g r i J Jerr H Herr K Kerr IRAC1 I1err IRAC2 I2err IRAC3 I3err IRAC4 I4err MIPS24 M24err SpT HaEW mem comp
Mon-000001 99.999 99.999 21.427... |
I'm new to jQuery, and am using it to dynamically construct chunks of a page.
The created HTML is what I want, but I'm not sure if the way I'm generating it is sensible or idiomatic.
function setupIndex()
{
$(document.body).append($("<img/>", {src : 'logo.png'}));
var div = $("<div/>", {"class" : "content"}).append... |
I have done the following code for testing a web-service.
Is my style correct for using OOP in JavaScript?
<script>
function Ajax() {
var Base = {
createAjaxInstance: function() {
var ajax = null;
try {
ajax = new ActiveXObject... |
Got this design for getting rid of checking network availability and informing user of errors. Is it good at all? Please, help.
Overall point is to fire server call as short as possible:
new DefaultServerCallTask<LoginResponse>(){
@Override
protected void onSuccess(LoginResponse response){
//go to nextA... |
I'm trying to find all the 3, 4, 5, and 6 letter words given 6 letters. I am finding them by comparing every combination of the 6 letters to an ArrayList of words called sortedDictionary. I have worked on the code a good bit to get it to this point.
I tested how many six letter words are checked and got 720 which is ... |
Given some cubes, can cubes be arranged such that an input word can be formed from the top view of the cubes?
For example: assume an imaginary cube with only 3 surfaces where cube1: {a, b, c} and cube2 {m, n, o}, then word an can be formed but word ap cannot be formed.
Please look into the two following issues:
A coup... |
This is a cocoa app that adds a right click menu option to change whether a file is executable. It works by executing the system command chmod on each of the files. But I want to know if there is a better way to change the permission of a file, such as a cocoa function that can change the permission of a file.
What are... |
So, I have a basic 'contact us' form that i have built, and I do some jQuery checking first (that a phone number is only numbers, email address doesn't contain unneeded characters, etc), but I also wanted to do some sanitization before sending out the email.
After reading many questions on SO (such a great service!) th... |
I've created a method which is useful for executing multiple queries, and it works perfectly. Is this a good way to handle this?
public function foo($rQuery)
{
try {
$this->done->beginTransaction();
foreach($rQuery as $val) {
$rSql = $this->done->prepare($val);
$rSql->execu... |
This is a console application which takes as an argument either a .cs file or a directory. If it's a .cs file, it scans it; if it's a directory, it scans all .cs files within the directory.
A simplified view of a method which chooses whether it's a file or a directory and reports errors is this one:
public static void ... |
I am working on coding up a set of models that are based on empirical models. These models tend to be quite complicated. In some cases, the logic used by the equations makes it impossible to compute the results using numpy fast arrays. As a result, I have decided to use list comprehension to do the math. However, this ... |
I would like to ask those of you, who are a little bit more expirienced in development. I would like to ask about toString() method usage. In what situations do you use it?
I've found some info about it, for example here, but it's not what I'm looking for.
Is there any convension which says when should I use it for my ... |
I am hoping this is the right place. I was hoping to find someone to try and help me not only learn but have a look at what I have already done on Android.
DISCLAIMER: I am a long time (10+ years) script developer (PHP, Perl, Ruby) and am happy with OO but have not really had any experience with Java so this is a bit o... |
I'm developing a Java EE project which uses Redis through the Jedis library. I'm retrieving the chat history of a particular channel from the servlet context and if absent, from Redis.
The PMD plugin of Netbeans shows me a message that the Cyclomatic Complexity of the code is 15 which is very large. I wish to reduce ... |
I have designed a proxy server which has the feature to manage miniature separate networks. Each network has space to have up to 500 nodes or 500 IPs. The code for getting a new virtual IP is based on a bit flag based approach. I have used an array of DWORD (Blocks) so as to skip entire 32 IP chunks, if the block is fu... |
This program is supposed to be a player VS player Tic-Tac-Toe game. The computer then checks whether you've won, lost, or tied. The code does work, but I don't want it to work through hacking; I want it to be done the right way.
Sub Main()
'Initialise variables
Dim StrCoordinate(3, 3) As String
Dim BooGameOver As Boo... |
I am currently working on a course project and have been assigned to write a GUI. I've written it and it's about 2000 lines of code. It will be bigger when I add the SQL codes and new panels. So, I've successfully divided it into different classes for each screen. My question is: how do I improve that solution? Here ... |
Up until now, I've been using a 14-pixel reset in my theme's main CSS file, but after looking online, I see that a lot of web developers prefer a 10-pixel reset;
Here is what I'm currently using:
/* reset.css */
* { font-size: 1em; }
/* dark-theme.css */
body { font-size: 0.875em; } /* 14 pixels equals 1.0em */
Here ... |
I've started learning Python recently and I wanted to test myself. So, can you tell me how many I would get out of 10 and how I could improve my future coding?
import random
import time
print('Welcome to Rock, Paper, Scissors')
print(' '*25)
wins = 0
loses = 0
draws = 0
point= int(input('How many rounds do you want to... |
I want to read multidimensional double array from file into a single pointer variable. The number of rows and columns are not known and need to be determined when reading the file in order to allocate memory for the array. I wrote the following code and it works fine with me. I want to know if someone has more efficien... |
I want to check the existence of various API endpoints by doing serial URL request. If the first one fails, I want to try the second one, if the second fails I want to try the third one, etc.
Here is some code I use to do this:
self.apiEndpoint = kApiAjaxEndpoint;
[self testEndpointWithBlock:^(id response, NSError *err... |
I'm trying to get my head around C-string processing. I've decided to try my hand at making a dirt-simple magnet link generator. The format that a magnet link needs is
magnet:?xt=<hash>&tr=tracker1url&tr=tracker2url&....&tr=trackerNurl
This program takes a hash as an argument on the command line, and takes lines on s... |
I was wondering if there's any way I can improve this code's execution. I want to use it on a 9*9 grid, but it takes too long to solve this as 4*4. This program takes as input a 4*4 matrix represented as a 1D matrix and returns the solution to the puzzle in the variable solution. Any comments?
subset([],_).
subset([... |
I'm working on my framework constructor. First I tried to look into jQuery and understand it, but it's so out of my league. Instead I googled and put this code together. Though there aren't many posts about creating a framework. Anyway, since I'm not a guru I might be doing it the wrong way or missing things. Can I tak... |
I need to prepend N spaces to a string to make it 10 characters in length. I came up with the following method, but since it is going to be called often, I want to ensure it is optimized. Could this be made more efficient?
public static string PrependSpaces(string str)
{
StringBuilder sb = new StringBuilder();
... |
The following is a program that lets a Human play "Rock Paper Scissors Lizard Spock" against the computer... (almost playable at: http://ideone.com/EBDlga)
Note I have posted a follow-up question incorporating the suggestions that have been made in answers and comments on this question.
Comments, critiques, suggestions... |
"Scissors cuts paper, paper covers rock,
rock crushes lizard, lizard poisons Spock,
Spock smashes scissors, scissors decapitate lizard,
lizard eats paper, paper disproves Spock,
Spock vaporizes rock. And as it always has, rock crushes scissors."
-- Dr. Sheldon Cooper
S... |
import javax.swing.JOptionPane;
public class DividedBy10v2{
public static void main( String[] args ){
int block[][] = new int[3][3];
int DetermineRow = 0; // The variable assigned for counting rows
int DetermineColumn = 0; // The variable assigned for counting columns
int blockRo... |
I've done this piece of code for creating all possible samples without repetitions, but I think that it is a so heavy algorithm because every time I call this recursive function I create a new vector that is passed to it. What means create any samples without repetitions? it means creating every combination given a pop... |
Last night I made this image uploading class. It was the first time I made a file uploader to be used on a real site, so I thought I would share it here and on Github to get some reviews, hoping if I can perfect it with your help, I will use the class in all my future projects.
<?php
/**
* A small, secure & fast image... |
The Challenge
Create an implementation of "Rock - Paper - Scissors - Lizard - Spock".
The rules:
Scissors cuts paper, paper covers rock, rock crushes lizard, lizard poisons Spock, Spock smashes scissors, scissors decapitate lizard, lizard eats paper, paper disproves Spock, Spock vaporizes rock. And as it always has, r... |
I have an algorithm that evaluates in input byte[] with a source byte[]. Several conditions can be encountered:
Match found
No match found
End of input array
End of source array
Input wildcard (*) matches against any source byte
All of these conditions are dealt with in this algorithm. Having been my first pass at ... |
I have the following MySQL SELECT statement. It is working fine except that the code is too long. I have been looking throughout the Internet to figure out how I can make it shorter.
SELECT regd, Subject, Section, date,
SUM(CASE WHEN (Name_of_exam = 'First Unit Exam'
OR Name_of_exam = 'Second Unit Exam'
OR Name_o... |
This post is following-up on Rock-Paper-Scissors-Lizard-Spock Challenge
I had a gut feeling that I was somehow abusing IComparable<T>, @svick's answer confirmed that.
As @dreza was posting his answer I was in the process of proceeding with exactly that refactoring: stuffing the SelectionBase class with most of the fun... |
This script works for what I need it to do, but I'm not all that proficient with Python yet, so I was wondering if any of the more seasoned python veterans would go about it differently.
import os
import string
import re
'''This script will take in an input list of strictly stellar IDs, and compare those IDs to a mast... |
I'd like a review on anything including optimizations, corrections, suggestions for robustness, adherence to good coding practices, etc.
I also request verification of the complexity: O(nn), where n is the row length or column length.
public final class Sudoku {
private Sudoku() {}
private static void printSo... |
Here's my take at the Rock-Paper-Scissors-Lizard-Spock challenge. The outcomes are as follows:
Scissors cuts paper
paper covers rock
rock crushes lizard
lizard poisons Spock
Spock smashes scissors
scissors decapitate lizard
lizard eats paper
paper disproves Spock
Spock vaporizes rock
rock crushes scissors
I've dec... |
Can anyone review my program and state where I could improve it, even in terms of comments, validation, etc?
package assessed_practical_2;
//Importing Resources (Random)
import java.util.Random;
//Importing Resources (Scanner)
import java.util.Scanner;
public class Assignment2 {
/**
* Scanner used for inpu... |
Continuing the spirit of the recent Weekend Challenge, here is a revised version of the RPSLS game.
This is a follow up to my previous submission:
Rock Paper Scissors Lizard Spock as a code-style and challenge
This version is revised to accommodate the following suggestions:
Model revised to abstract the display mecha... |
Time is very important from times immemorial. Doing great things and making it happen in less time is more important as it can mean less effort. So I really like to know which way is faster and more efficient in the following codes, and I would happy to know any other way we can achieve the same code:
$month=date('m')... |
I know that there are several ways to handle exceptions and probably a good way is to keep the handling consistently and use the pattern which feels comfortable for himself, but I would like to get some advice or hints, what would you do in following situation or how I could improve such a case.
I created a custom URLC... |
I have created a class that has many methods for sorting an ArrayList of objects. Each method is somewhat similar in that they employ some kind of sort on an ArrayList and then return the arrayList. They are different in that some have different methods of comparison and they also call different get methods for the obj... |
I have written a tool for encrypting string using the AesCryptoServiceProvider in .NET. The folllowing parameters are used:
Block Cipher Mode: CBC
Initialization Vector: 16 bytes (randomized
per encryption operation), stored in last 16 bytes of final message
Key/Block size: 128 bit Padding: PKCS #7
Overview of code
I... |
Lil' preparation before the interview. This is my solution to the problem in title. The code is pretty straight forward. Requesting suggestions for improvement and also verification of complexity, which I guess is O(26n)
public class CatToDog {
static Set<String> dictionary;
static {
dicti... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.