instruction stringlengths 71 71.9k |
|---|
I'm working on a sliding puzzle, one little project as a hobby, and yesterday I thought that instead of working on an algorithm to figure out a solved puzzle, it would be easier to make an algorithm that "shuffles" the tiles from a solved position. I came up with this and it works, but I don't know if it's elegant enou... |
I want to implement code for inserting a new Node in a binary search tree in java so please check if my code is correct ,,, Here is my method :
public class BinarySearchTree {
…
public boolean add(int value) {
if (root == null) {
root = new BSTNode(value);
r... |
I don't want to serialize everything. I created a custom attribute DoNotSerializeAttribute. If some property in info contain that attribute then ignore it and do not serialize it.
Is my code bug-free? Maybe I can improve it or I miss something?
class Program
{
static void Main(string[] args)
{
var s = S... |
Sorry for being a little abstract but I have attempted to concoct something simple but it seems to spiral out of control. So I was thinking maybe I am taking the wrong approach.
Here's what I am trying to do:
When I get a message it gets de-serialized into its own class. I would like to use a strategy pattern to choo... |
Edit: since originally posting this I have: realized that it won't run from irb/pry, and refactored to remove some sleep calls. I've also separated the sections into different code blocks.
I wanted to make a program for running background jobs (ruby scripts).
The goal was to continuously run a background script on an i... |
This is my solution to an assignment on the fractional Knapsack problem. I take as problem input the following pieces of information:
The number of item types
The total weight limit
For each item type, the total available weight of that item type and the value per unit of weight
The output is the amount of weight to ... |
I am working on a MSSQL Database (for a program called Sage 200). There are many tables in the database, however, I want to be notified of changes (new record inserted or existing record updated) via Trigger on a specific table.
I also want to support multiple rows on this table being updated at same time also.
When a ... |
Goal: I am trying to build teams of 5 people. Each person has an integer elo (rank). My goal is to make all the teams as equal/fair as possible, by having the average elo of each team be as close as possible to one another.
Approach: My initial thought was to go through the list of elos and take the highest elo player ... |
I'm quite new to Python and I have been trying to find a way to search a csv for a test string and return the index of that item in the csv.
I am using the code below but find it hard to believe that there is not a function built in to the csv module to do this.
I want to perform the 'lookup' so that I can select the... |
Wrote a small bash-script today that downloads the latest swedish wordpress archive , extracts it and writes wp-config.php
Would appreciate any feedback that could improve it / prettify it.
The script assumes that the database name & the username is always the same.
#!/bin/bash
#Download wordpress tar.gz
echo "Laddar ... |
I have need for a task scheduler determined by a directed graph. The tasks are held in a std::vector<task_type>, while the dependency graph is held in a adjacency_list<vecS, vecS, bidirectionalS> (bidirectionalS so that I have access to the in_degree() function). A single dispatch will start the tasks. Are there obviou... |
Working on a little Sprite Kit game, I had the problem that I wanted a couple of things to wait until a group of sprite nodes had stopped their animation.
I decided to use a GCD dispatch group to monitor the sprites' actions. The nodes that I was concerned about were all instances of the same class, so I gave that cla... |
I have just finished writing a simple Python3 program which converts a custom input file (or multiple files within the same folder) to an XML template.
It works as it is, but I think that I somehow messed up the code as I had to open several files, append to them, close them, loop through their lines and so on.
I thoug... |
I have been using a static class to connect and retrieve information from a MySQL database and also reading about how static works in php. I'm still not sure if the code is bad or not and why (besides the usual static are dangerous). Also, code improvements suggestions will be appreciated.
class Database {
const S... |
I have created a simple application that has grown a little bit. Though most likely it won't grow anymore, I have looked back and I realized that it has become a little monster in terms of how many almost identical properties and methods I have created. Please let me know how this could be made more manageable etc.
Pur... |
I am working on a LargeInteger class to store Integers beyond the size of long long as a dynamic character array. I have overloaded most of the relevant operators to be used with the large integers.
I would like to find a way to further streamline the addition/subtraction. I think it ought to be possible to only use a ... |
In my current project I have objects of the following structure:
CanvasBundle - Object
Some elements...
gridCanvas
axesCanvas
functions[] (contains unknown number of functionCanvases)
overlayCanvas
I'd like to write an iterator which would iterative over all the canvases (grid/axes/func/func1/func2/.../overlay).
I've... |
I have this Subroutine that works, but I have recently started updating the sheet and adding new columns. I'm finding updating the current macro to be a bit of a chore.
Is there a way to use named ranges instead of declaring the cell ranges as in this code?
Private Sub Reset_Rows_Click()
Const USED_RANGE ... |
This is my implementation of MinHeap in Java.
public class MinHeap {
int[] heap;
int pos;
int size;
public MinHeap(){
this.size = 2;
heap = new int[size];
this.pos = 0;
}
private void minHeapify(int index){
int child =... |
Attempting to see whether using 196 as a respectively in my program will have a result or not, I made a simple function to test it. Now the 196-Algorithm requires this:
Take any positive integer with at least two digits, a
Take a and reverse it (for example 23 becomes 32)
Now add the new number to a
Repeat the process... |
I am trying to implement a machine learning algorithm (k-nn for example). But before I attempt to do that I was hoping for some feedback on my current Main class, which essentially builds 8×8-pixel matrices into an array to be manipulated later. (See the data description and sample dataset.)
import java.util.*;
import... |
Similar to this question here, I am trying to implement sort algorithms in Julia, as part of a package.
The code for the implementation is as follows:
"""
The swapping function implementation
"""
function swap!{T}(x::AbstractArray{T}, a::T, b::T)
tmp = x[a]
x[a] = x[b]
x[b] = tmp
return x
end
"""
`insertsor... |
I have a java component that was using a lot of string literals that I need to make comparisons on and return booleans based on these comparisons.
In order to make the code more robust I externalized these strings first as class constants, then after other classes started to use these constants I had to separate them t... |
I am aware of the Python modules galore to do this, but this was partially a learning experience and partially all the functionality I need and no more.
I'm writing a simple interpreter for a Forth-like language, and because my CLIs are of the most high quality,[citation needed] I need to make the entire source (docstr... |
I had a logging function…
@task
def log_request(label, target, request_as_dict):
# Detect flood
# In general this task do not process misuse. But it can send
# an alarm to another celery task if something strange happened.
if incr_with_ttl(INDICATOR_KEY, INDICATOR_TTL) >= INDICATOR_THRESHOLD:
p... |
Yesterday a friend of mine asked on U&L: How to optimize 'grep'-and-save?
I will summarise shortly. The output of the torque pbs queueing system tool qstat should be parsed to contain only the Job ID, Queue, Jobname, and the node it is running on. This should be appended to an existing file, filtering out the duplicate... |
I created a class that I plan on using to autoload my project classes (20-30 classes) maximum. I wonder if there is anything, anything at all, that I can improve on this class to improve it any further.
Please let me know your thoughts below.
<?php
/**
* YodaCMS, content management system.
*
* @info This cl... |
I haven't done any programming in a while, and I'm getting back into it. I made this Snake clone to refresh me a bit, and I would like to get some feedback in the "elegance" and "well-done"-ness of the code.
main.cpp
#include "Game.h"
int main()
{
Game::run();
return 0;
}
Game.h
#ifndef __GAME_H__
#define __G... |
I am a relatively experienced WPF developer who has had good exposure to MVVM. I have been developing legacy WinForms applications for a while and have recently been asked to fully re-write a large one.
To do this I want to use TDD and in order to facilitate this and make the application as extensible as possible goin... |
Here is one of my programs that utilized memoization and array to improve performance and memory usage. The performance seems satisfactory but the memory usage is ridiculous and I can't figure out what's wrong:
{-# LANGUAGE BangPatterns #-}
import Data.Functor
import Data.Array (Array)
import qualified Data.Array as Ar... |
To import the data contained into the file my_file.txt that have the form:
Label[0] = 0.980252
Label[1] = -nan
Label[2] = -nan
Label[3] = -nan
Label[4] = 0.664706
Label[5] = -nan
Label[6] = -nan
Label[7] = -nan
Label[8] = -nan
Label[9] = -nan
Label[10] = -nan
Label[11] = 0.800183
Label[12] = -nan
Label[13] = -nan
Label... |
A little while ago, I had to write a little C# application to recover my HDD data (full context on this question)
To answer my problem I developed a console application which job was to recursively copy the entire folder tree of my HDD.
The code can be seen below :
using System;
using System.Collections.Generic;
using ... |
I'm trying to come up with a general way to correctly round floats with Python, given the known limitation of round():
Note: The behavior of round() for floats can be surprising: for example, round(2.675, 2) gives 2.67 instead of the expected 2.68. This is not a bug: it’s a result of the fact that most decimal fractio... |
I have written a program to display the kth permutation sequence of a string made up of letters 'O' and 'Z' . I tried optimizing it but my code have not passed test cases due to timeout issues.Looking for someone who can guide me in optimizing the code i posted below.
public static void main(String[] args) throws IOExc... |
I've implemented a SortedList which takes in streams of floats and returns a median at any point.
public class SortedList {
float[] list;
int pos;
int capacity;
public SortedList(){
this.pos = 0;
this.capacity = 2;
list = new float[capacity];
... |
I would like to create a simple interface to allow a user to make a few choices via select boxes and drive a resulting equation.
Here's a screenshot:
This is a gross simplification and I am looking for guidance/suggestions throughout my existing code.
Some areas of concern:
Should I be looping through the inputs?
Whe... |
This gives me the output of how many times the word is in the file. (I will eventually want to enhance the program to output on what line of the file the word is.)
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io... |
Python sets are magical things. Mutable, deduplicating data stores with handy operator overloads for &, ^ and |.
Specifically among the others, sets overload the & operator to do mutual membership tests like so:
>>> set("aasd") & set("aabc")
{'a'}
This is endlessly handy, but the huge downside of sets is they do not a... |
I came across this problem:
The following iterative sequence is defined for the set of positive
integers:
n → n/2 (n is even)
n → 3n + 1 (n is odd)
Using the rule above and starting with 13, we generate the following
sequence:
13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1
It can be seen that this sequence... |
Background
A prototype of a firefighting robot has been done recently based on an Arduino microcontroller. It has two servos, one laser LED and 2WD motors. The desktop application is done in C# to control the robot.
Desktop app logic
For controlling two servos, I am using the x-y mouse position on the screen and bind k... |
I am new to Ruby (1 year as hobby project on weekends) and solved a code challenge and it was not as good as they wanted. I want to know how i could make it better and how to make the structure better. In summary, how would a mid or senior ruby developer do this challenge?
This is the task:
Write a program that prints... |
I've just begun programming Java and I'm working on the following code that deals with socket-based communications. Basically it connects to a client on port 8888:
Gist of code
package com.mobile.stoq.stoqpay;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import or... |
I must write code for my classes which simulates multi-layers production line. But I don't even know how to check if it's good. Can anyone take a look at my code, please? First machine works in random frequency putting integer into first queue. Then, second machine puts out this number at freq2, adding 100 and so on...... |
I decided to make something to count the significant figures in a number to see how easily it could be done, but I think there may have been a better or simpler way. Any advice even just for conventional purposes is appreciated!
def count_sig_figs(answer):
'''This fucntion will count the sigfigs used in the answer ... |
I have implemented a program that produces a permuted index.
Actually it is this exercise:
https://stackoverflow.com/questions/4015016/what-is-a-permuted-index
Could anyone tell me if I did something wrong, and if it could be done better?
An input is for example:
The quick brown fox
And result:
The quick bro... |
I'm having trouble deciding if I should leave the default: break; in the switch statement or not. It does kinda show intent, i.e. that most keys are not handled, but it's also effectively useless code. I feel like it's clear enough anyway, but maybe being explicit is better?
function handleKeyDownEvent(event) {
swi... |
I've written code to be called from Powershell like so:
Rename-DatabaseUser -Name 'someuser' -NewName 'somenewuser'
I'm wondering if there's another way I can approach this. I want to create objects of the same type with slightly differing property values.
Here's the code I'm currently using now (RenameDatabaseUserCmd... |
I'm looking for feedback on improving the structure of this code. Also, I could not find the command line executable for Chrome.
General feedback is also requested.
#
#
#
# Divider - configures bash, git, grunt, sublime and chrome
#
#
#
user1=foo
config_bash() {
rm ~/.bash_profile
ln -s ~/root/config/bash/lo... |
Just looking for a review on my code, its currently only player vs player, but I'll be working on the AI soon enough. Functions edit_name, tutorial, and AI have been left out as I haven't started work on them.
class tic_tac_toe:
board = [" "," "," ",
" "," "," ",
" "," "," ",]
players... |
Summary
I have written a pair of Perl scripts that form a UDP chat room allowing users to send messages over the internet with RSA encryption, making the messages imune to MITM attacks. The scripts include a server script and a client script, and works as would be expected with the clients connecting to the server with... |
I haven't really worked much with asynchronous code so I'm wondering if I am doing something wrong/something could go wrong. Right now of all the test cases that I have done, my code has worked but I'm not sure if I will get side effects or not.
I won't post any of the business logic, just the iteration part with the a... |
Take a look at the following code and let me know if its right, and if there is any room for improvements.
Strategy Class
<?php
/**
* Draw Strategy class
*/
abstract class DrawStrategy
{
abstract function draw(Shape $shape);
}
/**
* This is ConsoleDraw and takes the shape object and draws accordingly, Drawign Al... |
Products Class that are like
Table, Chair, etc.
Please review it and give your thoughts and let me know if there are any rooms for improvement.
Products.php
<?php
abstract class Products
{
}
class Table extends products
{
public function __construct()
{
echo "New Table Created";
}
}
class Chair ... |
I made this decimal to binary conversion as an exercise for myself and because it is obviously often asked during job interviews / tests.
Any hints concerning possible improvements welcomed.
// -- START : Testing the function --------
var display = document.querySelector('div');
var result = '';
var n = 255;
var maxS... |
In my country (South Africa) mobile numbers have 10 digits and always start with a "0" (e.g. 0821231231).
But they can also have the international dialing code ("+27") replacing the "0" (e.g. +27821231231).
I have this regex:
((\+27)|(^(?!\+)(0)))\d{9}
Is there any way that this can be improved upon?
|
How can I improve the following code?
private const string OAuthTokenUri = "oauth2/token";
private static string GetOAuthTokenUri(string uriAddress)
{
var uri = new Uri(uriAddress);
var baseUri = uri.GetLeftPart(UriPartial.Authority);
var s = new Uri(new Uri(baseUri), OAuthTokenUri);
return s.ToString();
}... |
I have rolled my own parallel merge sort. My performance figures are as follows:
Seed: 1457521330571
java.util.Arrays.sort() in 6840 ms. Sorted: true
java.util.Arrays.parallelSort() 3777 ms. Sorted: true
net.coderodde.util.sorting.ParallelMergesort.sort() 4498 ms. Sorted: true
Arrays identical: true
Close, but no c... |
I have a bunch of processes that are being executed on different virtual machines. All of those processes have a StartDate, EndDate and Resource properties. Resource is a specific virtual machine it was ran on. I generated the actual timeline for items and found out that all of those resources have "holes" in timeline ... |
I just wanted to build a simple converter from an XLS Excel file to JSON. I have predefined JSON format. All fields except of two - are just simple mapping from Excel to JSON. The two fields have a special format, "|" separated values which should be converted to array items. I also need a geocode address and save lati... |
I have written code for insertion sort. I just want some feedback whether the above implementation is correct and can be improved.
public class InsertionSortNew {
static int temp;
public static void InsertionSort(int [] array){
for(int i =0;i<=array.length-1;i++){
int key = array[i];
... |
I'm pretty new to async/await and I want to ensure that the code I've written is going to be safe and not cause any deadlocks.
The RestClient in the code will be injected as a singleton dependency via an IoC within an ASP.NET MVC application, so that the access token request is made only once and shared across all API ... |
ok spent ages on this simple problem (I'm not good at XML) below code is probably self explanatory and it works, but i think this could be done a lot easier
Sample XML
<data>
<id name="ch01">
<channel>test channel 1</channel>
<gpio>3</gpio>
<cont>front</cont>
... |
I have just finished a simple C program which is basicaly composed of 3 functions:
accadd(void){} which adds some customer details to a binary file
void view(char file[30]){} which is supposed to let me view some of the data in a .txt file
void modify(char file[30]){} which verifies if a value of a struct is present ... |
Inside a function I'm calling playgame service. Once I've obtained the needed data (gameBeingPlayed), I need to show a 3..2..1 counter and then start a game.
chooseGameService.playGame(gameDefinitionID)
.then(function () {
vm.container.gameBeingPlayed = chooseGameService.gameBeingPl... |
I'm trying to find out what is the right approach to return DB values from a class. This is what I came up with:
class Category {
public $result;
public $errors;
public function __construct( $pdo) {
$this->pdo = $pdo;
}
public function getCategoryNames () {
$sql = "SELECT category_id, category_na... |
I want to develop a simple in-memory web request rate limiting module, I am allowed to have 50 requests from each unique cookie ID every 60 seconds.
I am wondering if the following code is an optimal way of implementing such functionality:
class RateLimiter {
private static final int MAX_REQUESTS = 50;
privat... |
I have the below toggle button sub that works;
Private Sub Toggle_Unused_Click()
Dim xAddress As String
xAddress = "DR:FI"
Call KeyOpen 'unprotects the sheet
If Toggle_Unused.Value Then
Application.ActiveSheet.Columns(xAddress).Hidden = True
'This returns a value to my notes tab.
ActiveWorkbook.She... |
(See also the next iteration.)
I have this small virtual machine.
What is there:
Stack and, thus, recursion.
Conditional and unconditional jumps and, thus, choice and iteration.
What is not there:
Floating-point type support.
Bit manipulation instructions.
No input operations, all "input" must be hardcoded into the... |
Newbie to PHP.
Trying to output the results of an array inside a foreach loop. I have got the following code but I cannot understand what to do with it next.
Mainly;
Where/how do I start and end the php statements?
Is there a better way to format this code?
I want to make it as easy to understand and legible as pos... |
Can someone tell me if my code is okay so far? I've read quite some resources online for responsive webdesign but it seems like everyone's opinion on best practices is different.
The page I'm working on is this. It's a very simple page with very little content. Right now it works quite well on smaller devices but I wan... |
I have several functions for merging some dictionaries but over time I created a more general function that would make all these others obsolete if it weren't slower.
I have the specialized (and several like it) functions that look like this:
def merge_keep_lowest(dict1, dict2, *dicts):
"""
Merge an arbitary n... |
I am doing a coding exercise in codility and I came across this question:
A binary gap within a positive integer N is any maximal sequence of
consecutive zeros that is surrounded by ones at both ends in the
binary representation of N.
For example, number 9 has binary representation 1001 and contains a
binary gap... |
What is a better way to create this select statement? I tried to just select 'u' and 'us', but the object properties were not accessible when I did this.
var userSubmittedRequests = (from u in db.TimeRequests
join us in db.UserManagers
on u.Emplo... |
I wrote this class to use a C++ function as hardware interrupt handler. The idea is to have a single entry point where I can switch stacks, and call a chain of std::function objects to handle the interrupt.
It works... but I think it's a pretty ugly hack. Is there anything I could improve here?
class __attribute__((pac... |
I have an array of API objects, below is an example of one object:
{
description: "Get a list of most recent social alerts"
example_input: ""
example_output: "status"
id: 19
method: "GET"
resource: "/api/alerts"
}
With my code below, I'm able to loop through the big Array, then filter out items... |
This function scrapes data from a webpage by spawning a process that executes a CasperJS web scraping script. The spawned process outputs data to stdout.
This function has an event listener for stdout and this is how the parent process (Node) gets the scraped data back. How can I make this more modular? Also, would cr... |
I have quite huge question/favor to ask but I hope I can get some useful answers. This is my first complete project, I'm still learning C#, my first programming language.
I'm afraid that there will be a lot of things that people won't probably understand but you can also check some of my other questions they include fa... |
I created a program on Code::Blocks that allows you to play Tic-Tac-Toe with 2 players on the same program:
#include <iostream>
#include <cstdlib>
#include <cstdio>
using namespace std;
char square[10] = {'o','1','2','3','4','5','6','7','8','9'};
int checkwin();
void board();
int main()
{
int player = 1, i, cho... |
I've implemented an events system in C++11. I've now got it pretty much as good as I can get it. It feels like I have found an optimal design pattern, and I'm using sensible variable names to illustrate what is going on.
Still not sure what the best words are: e.g. Invoker, Dispatcher, or Notifier? Event.fire() or .pu... |
I have enhanced my itoa implementation, taking the advise from my previous simple itoa implementation in addition to handling multiple radixes and negative numbers other then just base 10. Looking for general feedback.
const static size_t complemnt_digit_coun... |
Please help me in reducing the time complexity of this code as it is taking a long time to read its Excel input.
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 9 14:26:22 2016
@author: DalalNS
"""
from openpyxl import load_workbook
import os
import shutil
filename = 'test.xlsx'
wb = load_workbook(filename, use_iterat... |
I want to improve my coding skills. How do I write this code with concatenation
string query = "insert into StudentInfo values ('" + textBox1.Text.Trim() + "', '" + Name.Trim() + "', '" + comboBox1.SelectedItem.ToString() + "') ";
SqlCommand command = new SqlCommand(query, cn);
command.ExecuteNonQuery();
|
Here is a simple client for Wwitter that I wrote based on the twitter library in Python. The aim is to be able to read the feeds from different twitter accounts from the same place in a light way.
I should mention that the code does what I want it to do. Nevertheless, how could I improve it?
(It is available on GitHub.... |
I have a method which relies heavily on object supplied by third party APIs. Below is my working code, is there any scope of improvement?
public LineItem getLineItem(
String networkId, String lineItemId) throws ApiException_Exception {
LineItem lineItem = null;
session.setCode(networkId);
LineItemSer... |
I often receive large Excel-sheets in which data has been inserted via copy and paste. Usually a lot of the cells contain whitespaces at the beginning and the end before / after the actual value.
I made a VBA-script for to get rid of these whitespaces.
' Removes whitespaces at the
' beginning and the end
' of all cell... |
This is a FIFO blocking memory queue in F# to be used as a component in a logging library.
namespace Primitives
open System
open System.Threading
open System.Threading.Tasks
type QueueOpResult<'T> =
| Success of 'T
| Failure of exn
| Cancellation
type QueueOpCancelType =
| Timeout of TimeSpan
| W... |
I have a piece of code that I would like to refactor but can't figure how to do it. This is a method from a Play controller where I have to verify many precondition and respond different status for each case :
resource should exist or 404
revision should match the If-Match value or 412
payload should be valid or 422
... |
I have a requirement for archiving 5 huge tables from PROD to ARCHIVE server without losing the integrity of the tables.
The query makes use of the Linked Server functionality and current idea is to host it on the PROD server. It is a distributed transaction which makes use of Microsoft's Distributed Transaction Coordi... |
I'm implementing an HTTP client shell that's going to be used for the lifetime of my application in C#. It needs to be initialized before the instance can be accessed. It looks something like this:
public static class AssetSyncServiceClient {
private static object _lock = new object();
private static bool _in... |
I have applied the KNN algorithm for classifying handwritten digits. the digits are in vector format initially 8*8, and stretched to form a vector 1*64..
As it stands my code applies the kNN algorithm letting the user decide on the k input. The training dataset can be found here and the validation set here.
ImageMatr... |
I decided to try make my own way to save normal python data yesterday after coming across the minecraft NBT format, it's more limited than cPickle but appears to produce shorter results and so far works reliably (if a little slower). It works on the type of the input, and is currently compatible with bool, int, str, di... |
Three questions: is there a more performant way, is there a more suscinct, strike that, a way of expressing this where if you read just the body it is immediately apperent what the alorithm does, and should I be returning and IEnumerable of an IEnumerable, I mean what would be the point over and IEnumerable of IList?
p... |
This is my palindrome-checker that is doing what it should do. If you have any additional suggestions, please let me know.
# -*- coding: utf-8 -*-
def palindrome_verif():
Mot = raw_input("Tapez votre mot \n")
Comptage = len(Mot)
Lett_Sep = list(Mot)
Decompte = 0
Der_Lett = Comptage
if ((Com... |
After first code review I have fixed the found issues. Could you please review my new refactored application?
Main class (entry point)
static class MainClass
{
private static readonly ILog Log = LogManager.GetLogger(typeof(MainClass));
static void Main(string[] args)
{
log4net.Config.XmlConfigu... |
I'm writing a Morse code translator for homework in C#. It takes an input from the user and returns the Morse code version of their input. I understand that this code may look horrible, so how could I improve it in terms of efficiency and readability?
Program.cs
using System;
using System.Collections.Generic;
namespac... |
\$19!\$ is a curious number, as \$1!+9!=1+362880=362881\$ is divisible
by \$19\$.
Find the sum of all numbers below \$N\$ which divide the sum of the
factorial of their digits. Note: as \$1!,2!,\cdots,9!\$ are not sums, so they are not included.
Input Format: Input contains an integer \$N\$
Output Format: Print th... |
I've implemented the Equals() support for my class as follows:
public override bool Equals(object obj)
{
return Equals(obj as TwoDPoint);
}
public bool Equals(TwoDPoint p)
{
return ((object)p != null) && (x == p.x) && (y == p.y);
}
This obviously doesn't match the reference implementation on MSDN, here, as they a... |
I have this function here:
<?php
public function assignData($data)
{
$aSqlData['company'] = $data[0];
$aSqlData['tx_trouserextend_contactperson'] = $data[1];
$aSqlData['username'] = $data[2];
$aSqlData['tx_trouserextend_commission'] = $data[3];
$aSqlData['tx_trouserextend_wincap_version'] = $data[4]... |
I've written a script that I would love to get feedback evaluating the following: Module Pattern implementation, robustness, conciseness, cross-browser compatibility. My goal is to eventually use this script and others, as part of my portfolio for a job application. All criticisms are most welcome, especially if you're... |
My goal is to generate a sequence of random float from a seeded random generator. The sequence should be the same on any machine / any compiler -- this rules out the use of std::uniform_real_distribution since it doesn't make that guarantee. Instead we have to create our own version of this, which we will be able to gu... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.