instruction stringlengths 71 71.9k |
|---|
Instead of having multiple statements like the following, Is it possible to club them into one liner in jQuery?
var replaced = $("#myContents").html().replace(/Employee:/g,'<b>Employee:</b>');
$("#myContents").html(replaced);
var replaced = $("#myContents").html().replace(/SSN:/g,'<b>SSN:</b>');
... |
I am new to Matlab. Now I need to find the shortest distance between a given point to a surface, which is describe with a function.
I am planing to implement the method described in the link below with Lagrange Multipliers, and have writen my code to do that. However, I found my code runs slowly.
https://math.stackexch... |
I got a four-digit positive number. I need to square the two digits in middle to generate a new number on which the same procedure is applied. The numbers get saved in a list. This loops as long as there isn't an equal number generated (the list contains the number already). If a number is generated containing less tha... |
Tracks the number of calories a person consumes in a given meal it has helper method to get the day's total. The check method Tries to find any duplicate meals within the given list. The assumption is that a day can only contain one of each type of meal.
public class Meal {
public enum Type {
BREAKFAST,
... |
(See the next iteration.)
I have this C implementation of the merge sort for sorting singly-linked lists:
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
typedef struct linked_list_node {
int value;
struct linked_list_node* next;
} linked_list_node;
/***********************************************... |
I wrote this program to model interactions between a user and an artificial player, both playing by the same rules (not enforced here for simplicity).
The game played is here is "your next word has to start with the last letter of mine"
module Main where
import Lib
import System.Random
import System.Exit
import Contro... |
This is my first attempt at writing a programme: a BMI calculator written in Python. Please give me feedback on the programme overall, as well as how easy the code is to interpret and adapt.
from sys import exit
bmi = ["what is bmi?", "what is bmi", "bmi", "bmi?"]
male=["male","m"]
female=["female", "f"]
def bmi_q(... |
Here is my final build of the Age Distance Calculator - Any feedback on the code would be great - This is my 2nd day of java programming and thought this was a good little project.
package dev.swift.atc;
import java.util.Scanner;
import java.util.concurrent.TimeUnit;
public class AgeCalc {
private int personAg... |
I'm new to C# web, I want to know how to properly create a web app using
visual studio 2015 MVC templates, and being able to customise some of its code. I want to both practice C# web and clean code...
So I have 2 projects, one for Domain and another which is the Web App.
For example: In my Domain I have a class named... |
I have a class which lazily factors numbers. It provides the user with these methods:
getFactors returns a vector<unsigned int> containing the argument's factors
getFactorCount returns the number of an argument's factors
compareFactors takes 2 arguments returning a negative integer if the 1st argument has fewer factor... |
There are two functions, sportsRunning and sportsWalking, that will render different text. For this, I am using an if condition at the bottom to display corresponding div:
{sportsDescription.sportsDate && sportsDescription.sportsDate.length > 0 && sportsDescription.sportsDate !== '2199-01-01' ?
this.spo... |
I've made my own std::vector but it's the first time that I work with template and new/delete. The code works, but surely there are a lot of things that are wrong. Can you read the code and say me if I have coded it the right way?
(main is a test.)
#ifndef __STDVECTOR__
#define __STDVECTOR__
#include <iostream>
using... |
I already learned JAVA, a few design patterns (Controllers, etc.) and OOP. I'm trying too build some PHP scripts in OOP (a blog). I want to collect some articles from the DB and store in an array. I'm doing this with a repository (like I do this is JAVA). Is this correct?
Artikel.php :
class Artikel {
private $id;
pri... |
I'm back for more community punishment review of my own scripts and code! This time, I'm looking for general code review of my approach to a Python way of getting one or more hash sums for a provided file path (unfortunately, it's one-file-at-a-time, and only accepts one file path at a time). Hash sum selection is do... |
I have this code which compares two adjacent time stamps. If they are less than 15 min apart, it adds a new time stamp (row) in between with the new time stamp equal to the previous time + 15 min and value equal to the previous time stamp. If there is more than one-time stamp missing (more than 15 min interval), it add... |
I've been trying to improve my C++ skills, and deiced to try my hand at making a interpreter for a toy language. The language is called Quartz, and so far the only thing you can do is output strings. The following keywords can be used to print out a string: output, which prints all the strings on one line, and nl_outpu... |
I am writing a program in Python that takes a folder of images and animates them.
For example, going through a list of pictures like this and animating them one by one:
Relevant features include:
Upon startup, ask user what directory they want to animate images from.
If the chosen directory has no valid images, displ... |
I've created a console based Tic-Tac-Toe game in python that has the ability to be expanded to a 9x9 playing field or more if you wanted to. By default it's 3x3.
Github link: https://github.com/Weffe/TicTacToe
Current Issues:
[Minor] Misalignment when printing a playing field of 4x4 or greater
Tried to keep the TicTa... |
I'm trying to implement round-tripping from LinkedHashMaps to Clojure collections. The implementation below works for smaller collections, but larger collections raise OutOfMemoryError: GC overhead limit exceeded. Below is a generative test that passes, when the number of tests is small (~10), but exhausts memory for l... |
I've made this coding for large web pages with lots of text, images etc. If the user scrolls down or up it shows where the current view approximately is. In relation to the overall document height.
I'm considering to put it on GitHub. What improvements have be made so that it can be used as an Plugin, so that it can be... |
Here are the relevant parts of a project I'm working on that's working perfectly. I was wondering what I should change to improve it (to respect SOLID principle for example), especially regarding my add/remove loot functions which, even though they work, don't really feel right.
public class Hero
{
private int gol... |
Randal Schwartz stole Lisp's decorate-sort-undecorate idiom when he came up with what we'd later call the Schwartzian transform. All of my Lisp knowledge disappeared through nine half lives, but I gave it a shot in SBCL. I'm aiming for an idiomatic example I can use in a presentation about the history of the Schwartzia... |
I have a vector of ints that represents a point on a N-dimensional grid. I need to find all grid points that are within a given radius. I wrote the following, but it is rather inefficient, because it iterates through all points in a cube and checks the radius for each point:
typedef std::vector<int> VectI;
bool getNex... |
I'm an EFL teacher, and I built this web app to present a random group of questions for quizzes and tests. The page opens with random questions. Clicking anywhere brings up the spinner. Clicking anywhere again brings up new questions. The app uses viewport units to scale to any device.
The app works well in recent brow... |
I want to change the background color of each section of the page when the user scrolls. The code works but I feel like it's too inefficient
var colors = ['blue','yellow','green','purple','brown'];
var myScope;
var sections = [$('#section1'),$('#section2'),$('#section3'),$('#section4'),$('#section5')];
var sectionTop =... |
I'm currently building a Windows Form Application using Visual Studio 2015 and the Visual Basic.NET programming language.
On the main form there is a Tab Control and an ActiveX PDf viewer control. The Tab Control has 4 tabs they are labled "Find", "ECO View", "ECO Edit" & "User Admin". ECO = Engineering Change Order
T... |
I am fairly new to AngularJS and I am trying to improve my knowledge of this JavaScript Framework by building small real-world web-apps.
In this case, I have built a currency converter app with harnesses an exchange rate API built by me which runs here.
I want to know whether there exists a scope of improvement and opt... |
This is an interview question which i am trying to solve.
You are given a 2D array of characters and a character pattern. WAP to find if pattern is present in 2D array. Pattern can be in any way (all 8 neighbors to be considered) but you can’t use same character twice while matching. Determine whether pattern is presen... |
I'm pretty new to Java development and have written a little POJO to "PDF Form Filler" program. I'd be interested in recommendations and suggestions about coding style, used methods and classes and so on. The project uses apache's pdfBox and can be found in total at https://github.com/baao/pdffiller.
Extra Question:
As... |
While teaching myself Wx using this GridSizerTutorial page, I suddenly realized that there was a construct in Python that would let me considerably shorten the initialization code below. The three lines at the top replace the twelve commented lines below. (Three statements now split over six lines for greater clarity).... |
I know that the below solution is not the best one and I am in the way to learn that stuff till then I have applied the brute force to see how far I can go with my intuition.
console.clear();
function allButLast(arr) {
return arr.slice(0, arr.length - 1);
}
function last(xs) {
return xs.slice(-1);
}
function ma... |
My problem/concern is that I am trying to remove duplicate code from my functional tests without breaking the Page Object Pattern that I am following.
If you look at the code below, you will notice that 4 lines are constantly repeated in my tests, breaking the DRY principle - they are marked with a "todo" comment. But... |
(See the initial iteration.)
Continuing from Merge sorting a singly-linked list in C, I have incorporated the points made by @vnp.
Now it looks like this:
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
typedef struct linked_list_node {
int value;
struct linked_list_node* next;
} linked_list_node;
... |
I am wondering if that is a safe and proper init, with one failable init guarded and an init.
Are the force-unwrap correct in the self.init as I know they are those types ?
struct Item: Equatable {
let id: NSNumber
let displayName: String
let amount: NSNumber
init(id:N... |
Since I am using Hackerrank codepair, I have to resort to inner classes.
Please review the code and let me know if this can be improved.
import java.util.Iterator;
import java.util.List;
import java.util.ArrayList;
import java.util.PriorityQueue;
public class LinkedListMerge {
private List<LinkedList<Integer>> li... |
I am trying to improve a website to be as accessible as possible to screen readers and people who want to disable JavaScript (not necessarily both at the same time) so I use a checkbox with a label to display/hide the side menu
Some of the aria attributes get changed by javascript depending on screen size and whether t... |
I am implementing fundamental data structures in C#. I have written a weighted graph in Java so my main motivation here is to sharpen my skills in C#. I have tested with various cases and there seems to be no logical issues, but I know the language could be better utilized.
The Pathfinder method is not absolutely neces... |
I was bored the other day and decided to have a crack at Project Euler Problem 54 for some fun. Given a file containing one thousand poker hands dealt to two players, the task is to count the number of hands won by Player 1.
This is the first project Euler problem i have completed and thought it would be good to get s... |
I want to override the console.log function in order to save the data other scripts log. My script executes before any other script, so I have full control over the environment. This is my current function for overwriting console.log:
+function(){
var a = Function.prototype, b = 'toString', c = a[b], d = c.apply(c)... |
There are a plethora of streams and streambuffers available today, none are as fast as a memory streambuf, that you can use for testing. Shoot away!
#ifndef MEMSTREAMBUF_HPP
# define MEMSTREAMBUF_HPP
# pragma once
#include <cassert>
#include <cstring>
#include <array>
#include <iostream>
#include <streambuf>
temp... |
I want to generate a four digit code based on the code generated before it, starting at 0000 and going to zzzz.
These are the available characters to be inside the code:
private static final char[] _availableChar = "0123456789abcdefghijklmnopqrstuvwxyz".toCharArray();
The first thing I do is the get the newest code or... |
I want to search for a string inserted in TextBox1 on Mainwb within a range of data located in Workbook officerA Worksheet DATA!(A2,G2000), and then paste results found into Workbook Mainwb.sheet("MAIN SCREEN").Range (A5,G500)
I am totally new to VBA and wrote this code quoting from many sources. I'd like to know how i... |
This is a simple program that opens programs from a simple spot:
import random
import webbrowser
import os
import yagmail
#importing all module ^^
greetings = ['hola', 'hello', 'hi', 'Hi', 'hey!','hey']
random_greeting = random.choice(greetings)
maps = ['maps', 'open google maps', 'open maps', 'please open google map... |
All my projects have a fairly similar package layout:
package_name/
package_name/setup.py
package_name/package_name/__init__.py
package_name/package_name/data/foo.txt
package_name/package_name/__init__.py contains:
__version__ = '0.0.1'
__author__ = 'Alec Taylor <alec.taylor6@gmail.com>'
With a setup.py like:
from se... |
Here's the school assignment I did:
Problem 1. Write a program that simulates a soft drink machine.
The program should use a structure Beverage that stores the following
data:
Drink Name
Drink Cost
Number of Drinks in Machine
The program should create an array of five structures. The elements
should be initial... |
I have this function to ease out the task of inserting data into databases.
I am not very sure if it is secure to use it this way.
Any suggestions on improving it?
function insert_into($query,$datatype) {
//$i=0; num=1; $i=1; num=2; for(i=1;)
$num=func_num_args()-1;
global $CONN;//set the g... |
I made a very simple program where you input a students grades (edit the code with the set method?) and the program will output the average. Each test has a different weight associated with it.
The problems I think I have right now are:
I am not properly utilizing my methods. The getters and setters are probably done ... |
I have this WCF data service class and I believe it is doing a lot:
[System.ServiceModel.ServiceBehavior(IncludeExceptionDetailInFaults = true)]
public class PetSuppliesRelationalData : EntityFrameworkDataService<PetSuppliesEntities>
{
private string _TenantID
{
get
{
return H... |
With this code I am reading a XML-File that is on a server. In this XML-File are several links. I have to check them if they are accessible. For each link I add an item to a listview with a green background (accessible) or a red background (not accessible). The program is relatively slow.
Public Class frmMain
Private ... |
I have a Rails app where Loan has paid attribute. Loan should be marked as paid if total sum of payments is equal or higher than loan amount_to_pay. Problem is that it is obligatory to have paid attribute and not checking it dynamically by joining payments to loans and selecting whether it is paid or not (long story...... |
def greatest(a,b):
if a>b:
return a
return b
def odd_check(a):
return not(a%2 == 0)
def go(x,y,z):
a = odd_check(x)
b = odd_check(y)
c = odd_check(z)
if a and b and not c:
print greatest(x,y)
elif a and not b and c:
print greatest(x,z)
elif not a and b and c:
... |
I am a jQuery beginner and would like some pointers on whether the following code could be made shorter, or there is a better way to get the same result.
jQuery(document).ready(function(){
var aa=jQuery('#navigation-wrapper');
var bb=jQuery('#top');
jQuery(window).scroll(function(){
if(jQuery("b... |
Is there a simpler way with a simpler notation to do the following part of code:
void swap(char **s1, char **s2){
char *tmp=*s1;
*s1=*s2;
*s2=tmp;
}
void sort(char ***m, int dim){
int i, j, flag=1;
for(i=0; i<dim-1 && flag==1; i++){
flag=0;
for(j=0; j<dim-1; j++)
if(str... |
I am learning Java by reading source code of other authors. This Java method handles communication with SQL database. While the code does work several things concern me. For instance the try catch block at the end of the file used as a workaround. What is the correct way of doing it? What other problems can you spot?
... |
I am preparing to write a widget for the browser that is both visual and interactive. I am a newbie to Javascript/Ecmascript and prototyping. I want to encapsulate the canvas element, abstract the data, and render visuals. A major design goal is to minimize developer effort. I am looking for direction and best practice... |
I need to create a tree from a flat collection. The order of elements is defined in a specification so it's rather impossible that it will ever change... but I want the whole algorithm to be configuratble and extendable aka universal... the SOLID virus ;-) so I did the following...
Data Models
I created an attribute t... |
I'm new to Python and experimenting with some simple scripts. I would appreciate if you could give me some suggestions on how the following code can be improved or made simpler or anything in general.
#Coverts MAC Addresses into cisco format
def mac_conv(mac, sep='-'):
#split mac address into 3 groups
splitted_mac... |
I just stumbeled accross some code and I would do it in a different way. Since I am quite new to programming, I just wanted to know if I understand it right.
Original Code:
protected void FireStateChange(LightCommunicationState OldState, LightCommunicationState NewState)
{
if (StateChanged != null && OldS... |
It's a simple hexdump that prints to stdout. I wanted to handle correctly input coming from the user typing at the terminal, this made the logic a little more complicated than just exiting after reading less than requested. It doesn't use the stack or memory variables, except for the tables and buffers, so I employed e... |
Input is a string, and the method should return repeated characters in that string and the position of these characters.
I'm currently using Java 8 Stream. The problem is I have to do it by calling 2 times collectors. I am trying to find a way to combine all these operations in 1 single collector operations if possible... |
Create a program to find all the prime numbers between 1 and 100.
One way to do this is to write a function that will check if a number is prime (i.e., see if the number can be divided by a prime number smaller than itself) using a vector of primes in order (so that if the vector is called primes, primes[0]==2, primes... |
I've just bought myself a domain and recently created a rough draft of a portfolio website.
A few of my friends have looked over the general design of it and given me some positive feedback so I thought I'd see if anyone here would have some feedback about the actual code.
It's quite a handful of code, so I'm not expe... |
There is a list consisting of zeroes and ones. I want to find out the length of the longest streak of ones. Is there a better solution?
def consecutive_one(data):
one_list = []
size = 0
for num in data:
if num == 1:
one_list.append(num)
elif num == 0 and size < len(one_list):
... |
I have a python code named seasons.py which uses inputs to open different web pages in which there are links to download Pokémon episodes.
The program has a module called seasons.py where it returns the number of episodes that has the season which was entered. It also needs a number of text files called last.txt, and s... |
First Class Functions
So, VBA doesn't support functions as first class objects - no passing functions as arguments or storing them in variables.
I eventually found a way to implement function pointers using AddressOf and DispCallFunc, but it was rather dangerous - if you pass the wrong number or type of parameters, you... |
Clojure beginner, looking to improve this code I submitted for Escape the Trolls, a Weekly Programming challenge over in reddit. No trolls yet, just walking through a maze for now.
(ns ctrollmaze.core
(:gen-class)
(:require [clojure.string :as str]))
(def sample-maze
"#####################################
# # ... |
I have completed writing a responsive menu (it uses the HoverIntent plugin) for my WordPress theme and it looks like it is working fine on desktop/tablets/phones.
You can test the code here. Just make sure that you are testing within Chrome/Opera Developer Toolbar (ctrlshiftI) and then toggle device toolbar (ctrlshiftM... |
Brief Description:
A generic extension method that performs the same function as IEnumerable.Any(), but does not throw an error when passed a parameter with a null value.
Explanation:
Often times I will come across code that performs two steps on a nullable collection to make sure it contains elements. The first step c... |
I'm developing an ASP.Net web application, using MVC 5. This application authenticates via LDAP and will assign an Identity Role of "Admin" to a designated user.
The Admin user will be able to go to an administration page to add users with a role of "Admin", if the admin checkbox is not checked, then the role is "Emplo... |
Similar problem: Sum Of Prime
I've done the given problem in roughly \$\mathcal{O}(n\sqrt{n})\$.
How can I improve this algorithm?
#include <stdio.h>
int isPrime(long long int n)
{
long long int i;
for(i=2;i*i<=n;i++)
{
if(n%i==0)
return 0;
}
return 1;
}
int main(void) {
int... |
Title says the biggest part. The class is designed to be used to search for very big prime numbers, hence the element type is templated. The performance, neither in space nor time, is considered. Users are free to provide any type that supports required semantics. It also supports traverse performance of std::vector du... |
I am developing a game, its map is based on a 2D city. The city is being generated as string, # are streets, O are buildings.
Here is an example:
#######
#OOOOO#
#OOOOO#
#######
#OOOOO#
#OOOOO#
#######
Now I am replacing the Os with other buildings, by replacing the character with an other. The other buildings are def... |
I needed a simple and efficient way to use events in my JavaScript code, so I came up with a small event library.
Currently, I'm doing it like this:
// eva.js - The lightweight es6 event library.
var eva = (() => {
// Prepare local globals
var eva = {};
var receivers = [];
var gid = 0;
/**
* Verify the typ... |
I'm a teacher and I built a one-page web app to display random question sets for quizzes and tests. The script I wrote selects one question from a set (array) of questions.
The script works fine, but I wonder if it follows best practices or if it could be made more efficient. I want to share my app with other teachers... |
I am developing a text-based RPG with a randomly generated world space. I have built a light engine to produce a world for me and fill it with 'world objects' like trees, mountains, villages, and the like. The world can be generated either through a fully automatic method, or a "manual" method, that allows for more spe... |
This is part of a larger project that is to run on POSIX systems. My concerns with it are the lack of comments, best practices with the filesystem, and naming things. Of course all feedback is great.
fileio.h:
#ifndef FILEIO_H
#define FILEIO_H
char **readlines(const char *path);
void freelines(char **lines);
#endif
... |
I am practicing to code in the right way and make it testable. Please review this code and tell me anything bad practices of it.
Entity:
namespace MockBlog\Entities;
use Doctrine\ORM\Mapping as ORM;
//use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity
* @ORM\Table(name="mockblog_page")
*/
class Page {... |
I have a simple app which is checking occurrences of values. If there is already occurrences which I am looking for, it display that. If not, it adds.
create table Strings
(
StringID INT IDENTITY(1,1) NOT NULL PRIMARY KEY
, StringValue VARCHAR(100) NOT NULL
)
create table Links
(
LinkID INT IDENTITY(1,1) N... |
I wrote a script to copy a file, but this file already exists in the target directory. So, first I need to rename the original file.
The script works, but a colleague did not want to use it because it is too complex. I would like to know how can I improve the code of this script. In some sense it seems to be overkill ... |
I'm a beginner working on a text adventure. It's quite bare-bones at this point but I would appreciate feedback before I continue and the flaws in my code become further ingrained.
I plan to add an item pickup and inventory system which can store items to heal and deal damage to enemies, some problem-solving and expand... |
I was asked to make a String encryption utility without using encryption API
I basically had to come up with my own ecryption methodology! the program was to be able to encrypt a string and decrypt a string and to of course make it nearly impossible for anyone to figure out what the encrypted string says!
I would real... |
I've written a procedure which allows serialized writing of a stream. I don't in any way consider this done, but this is the beginning of it. I know there are other implementations out there like this, but they tend to be either too primitive or too heavy. This is an attempt to simplify serializing the output stream.
T... |
I am trying to solve a programming problem on a coding platform. When I submit the code on the coding platform, it throws a "Time Limit Exceeded" error. Can someone check my solution and help optimize it?
A food delivery company X gets a lot of orders every day. It charges some
commission from the restaurants on these... |
I wrote a method that calculates the average and standard deviation of sell currency exchange-course (ASK). But I think that it isn't the easiest way to define such behavior.
In my opinion there is too much creating of BigDecimal values.
I have also doubts about using an ArrayList to get values in order to count stan... |
I made a little copy tool, but my progress bar seems to be too slow. I would also be very interested in any tips and improvements or code smells.
MainForm (code behind):
public partial class MainForm : Form
{
private FileCopy _fileCopy;
private delegate void UpdateProgressEventHandler(object o, CopyProgressChan... |
I am trying to write a program to find a zip file's password. I know the password consists of only lower-case letters and it's length does not exceed 6 characters. I wanted to check the passwords of length 1 first, then length 2 and so on.
So I used breadth first search, but then I realized that BFS consumes so much m... |
The problem I was trying to solve sounded pretty basic, but turned out to be a bit hairy.
I need to select some lines of arbitrary length from an input stream (file or standard input) and print them to output. In other words, a function that just echos the line would do the job. The input stream is encoded in UTF-8. Fo... |
The question is to find a number with absolute minimum difference from a number of the form be. I came up with the below code which takes 4 seconds to solve each test case on an average however it has to be solved within 2 seconds.
Sample Input:
11
25
Sample Output:
20
Explanation:
11 is the nearest to 32. Th... |
So I have started creating a UITableView with multiple prototype cells. I currently have the below code setup, which works fine
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell: UITableViewCell?
if indexPath.row == tableView.numberOfRowsInSecti... |
I've tried out implementing a combination generator using boost coroutines. It accepts an array of possible values and generates one array at a time for each combination. As a limitation, it only generates combinations of the same length as the array of possible values and does not check for duplicates inside the sourc... |
I'm trying to learn some Haskell by working my way through the CodeAbbey problems. I really struggled to find a nice functional (but still efficient) way to solve problem #21: Array Counters.
The problem is, given a list of M numbers between 1 and N (an input parameter), to count the number of occurrences of each numbe... |
I am working on some sampling to collect data for my research on SOLID Principles. One of my sample consists proceeding code snippet:
public abstract class Notify
{
public abstract void NotifyClient();
}
public class OnPremisesClient : Notify
{
public override void NotifyClient()
{
Console.WriteLin... |
I need to handle configuration errors and ask the user for the right credentials if something is wrong. I cannot decide between three implementations. Which style is better in Python and why?
A:
while not backend.check_config():
click.echo('Invalid Configuration parameters!')
for param_name, question in backend... |
I implemented a generic Dijkstra algorithm. It's lazy since the vertices with their final distances are request on demand. I used the Fibonacci Heap from this question with a few changes (added a copy and move constructor and the copy and swap idiom among other things).
I'm looking for a general review.
Dijkstra's algo... |
The code will move the mouse from a start point (xs, ys) to finish point (xe, ye) like a human would.
I'd like some help possibly shortening the code (by optimizing it) and making it more readable.
Also, if you spot any mistakes I could have made while converting the Pascal code to C# code, please let me know!
Original... |
I have just begun to learn the C language and wanted to start off small with a temperature conversion calculator. The program works, and I'm looking for feedback on do's and don'ts as I am sure there are at least a few errors in technique that can be improved. (I just realized Fahrenheit is spelled incorrectly).
/*Calc... |
Basically, I want the code to break when strLink doesn't contain any domains in the googleDomains link.
The code seems to be very awkward. I wonder if there is a way to make this more elegant.
Dim googleDomains = {"google.com", "blogger.com", "youtube.com"}
Dim pass = False
For Each domaingoogle In googleDomains
If... |
I'm creating a personal website where, among other things, there is a blog, or a "microblog" (I'm still not sure how to define the two), where I will be writing articles and having users, who will create accounts, write comments on the posts. In addition, the blog posts will be tagged to allow for easier searching of s... |
I've started to learn Python today. I'm trying to write decoupled middleware or chain of responsibility pattern.
In my app I have some two classes:
abstract class or interface named Processable
class ProcessorChain, which must locate implementations of the Processable, create objects of these implementations and call ... |
I'm a beginner. This is my implementation of binary search algorithm in Python. Please review my code and give your valuable inputs for further improvements on overall coding style, rare cases etc.
def binary_search(arr,value):
left = 0
right = len(arr) - 1
while(left <= right):
mid = (left + right)... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.