instruction stringlengths 71 71.9k |
|---|
I've been learning Sass recently and I've made a small project to master key concepts. I've tried to use placeholder to make different styles of boxes. I have a few questions:
is the project generally correct (metodology, semantics, sass
structure)?
is it right to use nested style in placeholder (.icon in %feature-box... |
*** PS_HOURS.3_1
July |1 |2 |3 |4 |5 |6 |7
Name |Total|Total|Total|Total|Total|Total|Total
Abram, John |1.00 | | | |3.00 |3.00 |3.00
Agara, Hara |2.00 | | | |2.00 |2.00 |3.00
Alsi, Idria |2.00 | | | |2.00 |2.00 |2.00
Amon,... |
I am wondering how to optimize the following OCaml simple code.
#load "unix.cma";;
open Unix;;
let time f x =
let start = Unix.gettimeofday ()
in let res = f x
in let stop = Unix.gettimeofday ()
in let () = Printf.printf "Execution time: %fs\n%!" (stop -. start)
in res ;;
let syracuse x =
let... |
For a while, I have worked with the Nuget Epplus package to export MVC models to fresh Excel documents. While the code I show below works correctly, I have a feeling that either I can make this code better or perhaps that there is a coding pattern of which I am unaware that could simplify what I am trying to do.
The m... |
At my work, I need to use multiple versions of Java, depending on which project I work on. I've made a batch script to take care of this. There are several different actions that you can perform with the script.
You can change the current value of your JAVA_HOME from a version in your file. You can add new Java instal... |
I wrote a method early of our development last year about getting the content of a webrequest where it contains an xml data that we need to process and insert to database. I wanted to improve this, so I'm asking a feedback on these code snippets.
public async Task<BulkStatusCode> AuthenticateConnection(string url, stri... |
This is in reference to the following kata:
Item Unit Special
Price Price
--------------------------
A 50 3 for 130
B 30 2 for 45
C 20
D 15
I am still trying to learn F#.
Thus, I have the following code:
module Checkout
(*Types*)
type Type = A | B | ... |
As my go to first project for a language is a Mandelbrot, I had to implement one in Rust. I'm particularly annoyed by invalid_arg_count, as I feel like there has to be a way to add the arg length checking to the match. I also wish to find a way to multi-thread this in the future.
extern crate image;
extern crate num;
... |
I have a simple task that comes up often my work. I need to create a dictionary for an id key to a list of data associated with that key. I'm wondering if there is a better way to do this than the one I am using. The pattern is so common that I feel there must be better solution.
value_list_dict = {}
for line in f:
... |
I've been learning Haskell from LYAH for quite some time, and as a first practice for Chapter 7: Modules, I decided to make a simple numTimesFound function: it returns the number of times an element is found in a list.
Here's my working code:
numTimesFound :: Ord a => a -> [a] -> Integer
numTimesFound _ [] = 0
numTimes... |
I have implemented few functions of a linked list. Feedback is welcome.
Please note I have specifically avoided using pointer to pointers.
#include <stdio.h>
#include <stdlib.h>
// Node data structure inside the linked list.
struct node {
int data;
struct node* next;
};
struct node* BuildOneTwoThree(void);
void... |
I would appreciate critique and comments in regards of thread-safety on a basic type I'm trying to create.
In C#, the Lazy<T> type is initialized only once, and only when needed the first time.
My type, called Snoozy<T>, is similar, but differs in one important aspect:
The value can be reinitialized when necessary (but... |
I like to overcomplicate things, this is fairly simple though but I would like to keep it simpler without lowering readability. Not just to improve my code but also my self.
private String checkTrailingSlash(String website) {
if(!website.endsWith("/")){
website = website + "/";
}
return website;
}
|
I have a class which contains a reference to a parent of the same type( or null if it has no parent).
class MyObject{
private MyObject parent;
public MyObject getParent(){ return parent};
…
}
I have a list of MyObject, and need to order it so that every object comes after its parent in the list (the pare... |
I want to create a modular website with no frameworks or CMS nor server-side language.
Also, I am doing simple use of the hashchange event to help the navigation.
The structure would be as follows:
A basic container HTML page with 3 main areas: header, content, footer.
Individual HTML files - one for each page - which... |
Well, I'm writing a piece of code that will take a list of file names and should search a local drive for each file, determine if it's there or not, and return an array of all the paths found.
Right now I'm using a function that searches for one file and I call this function for each file in the list:
Public Function D... |
Currently, I am interested in programming. I have programmed a calculator in C. Everything works, but I do not feel completely confident in my solution.
Are there any logic or efficiency issues with my code?
Supported operations: \$+\$, \$-\$, \$*\$, and \$/\$.
Algorithm: Flowchart
main.c
#include "practice.h"
int ma... |
This is an algorithm that I wrote to get the nth Fibonacci number using bottom-up dictionary. How can I make this better/more efficient?
memo={1:1,2:1}
f=0
def Fib(n):
for i in range(3,n+1):
memo[i]=memo[i-1]+memo[i-2]
f=memo[n]
print(f)
return f
Fib(15)
|
import tornado.web
from selenium import webdriver
import sys
import psycopg2
from selenium.common.exceptions import NoSuchElementException
class LevelHandler(tornado.web.RequestHandler):
def __init__(self, application, request, **kwargs):
super().__init__(application, request, **kwargs)
self.conn_... |
I recently found an Objective-C extension on NSData that encodes and decodes data with AES-128. I made an attempt to port this code to Swift 2.2:
NSData+AES.swift
extension NSData {
struct AES {
static let privateKey = "DefaultPrivateKey"
}
func AES128EncryptedDataWithKey(key: String = AES.privat... |
I wrote a utility class called ObservingCache, which receives a task in the form of Supplier<T> and an interval, computes the task every [interval] millis and allows its result to be queried via the getItems() method.
I'm using for making sure that outside resources (such as configuration files or DB tables) are always... |
Any suggestion to improve this, they ask me to input characters that should be an invalid input and ask you again to input the number of process without crashing the program.
#include<iostream>
#include<ctype.h>
using namespace std;
int main()
{
int bt[20],wt[20],avwt=0,i,j;
int n;
cout<<"Enter total n... |
My problem is related to data manipulation: on the basis of the existing variables in a given data set, I would like to create new ones. Bonus points for performance as well as code readability.
Let's consider a reproducible example for the famous "iris" data set. My goal is to create a new variable, which can be descr... |
Following my previous unbounded prime generator and a followup by Martin R, I've tested the waters in Kotlin by making an unbounded sieve.
To quote Martin R's wonderful explanation of the base algorithm,
The interesting thing about that algorithm is that the prime generator needs a list of "base primes" which are cre... |
I recently had the need to implement Luhn's Algorithm in a Java/Kotlin application. I needed a function that would add the check digit to the string of a number like a credit card or IMEI. It could be easily modified to check if the last digit is valid.
At first, I had a code of around 20 lines in Java, but by using ev... |
RESTRICTION: jQuery 1.6.4 only, no other library, or version can be used.
My goal is to use jQuery to allow two input checkboxes behave the same.
For example: If 1st checkbox is checked, 2nd will be checked. If 1st is unchecked, 2nd will be unchecked. And vise versa. When either of the checkbox is checked, I will add a... |
I have a shell and batch script to make specific calls to a MBean on a JMX server. The shell input args are not working in windows because windows handles " differently than linux.
Assuming this is a bean name : bean = "hostName=\"localhost\",name=\"foobar\"\""; and the whole input args on linux is something like this:... |
This is an algorithm to find the item with the minimal value in a sequence. I've written a function called minimal to implement this algorithm.
Here is my script:
def minimal(*args):
"""Returns the item with the minimal value in a sequence. """
if len(args) == 1:
sequence = args[0]
else:
... |
# unit tests for the /brands endpoint
from flask.ext import restful
import unittest
import os
import json
import sys
# tells sql_models to use the testing database
os.environ['API_TESTING'] = '1'
sys.path.append('/opt/backend_api/')
import api
from models import sql_models
from config import settings
class TestBran... |
using System;
using System.Diagnostics;
using System.Threading;
class Program
{
public static void Main()
{
ThreadPool.QueueUserWorkItem(() => {
Thread.Sleep(10000);
PressAnyKey.Cancel();
});
Console.WriteLine("Press Any Key or don't...");
PressAnyKey.WaitOne();
}
}
internal ... |
I have made a simple pagination algorithm. It shows "next" and "previous" buttons when appropriate.
It also limits the amount of buttons if the page amount exceeds a certain amount, e.g. 1 2 ... 15 16 17 18 19 ... 99 100.
It works fine, but I feel it can be simplified.
function appendTruncateButtons(buttons, pageCou... |
I have two classes:
country
country_name
Country.java
public class Country {
private Integer ID;
private String ISO;
public Integer getID() {
return ID;
}
public void setID(Integer ID) {
this.ID = ID;
}
public String getISO() {
return ISO;
}
public void... |
I have an array matrix, for example A(3,3), I want to make a table with header names like, ['force','mass','acceleration'], the second row contains the units (subheader), ['N','Kg','m/s^2'], and the rest of the table contains the elements of A.
I want to export this table as a (.dat) file, how can I do that in an effic... |
I started learning Python recently and I really like it, so I decided to share one of my first projects mainly in hopes of someone telling me what I can do to make it run faster (threading/multiprocessing?).
from requests import get
from bs4 import BeautifulSoup
from time import time
from re import compile
print('***P... |
I have written a working minimax tree for Tic-Tac-Toe. What I have done so far is create a tree with end node having value 10, 0 or -10 base on win, lose or draw. After I create a tree I then determine the move based on depth first search which bubbles the end node value to root node. Based on the value received at the... |
I'm new here and this is my first simple console application that calculates the number of hours left. There's a lot to improve and if you have any suggestions on what things to add or refactor that would be awesome! It's 486 because it's the usual number of hours an internship has.
The user presses 1 to enter the nu... |
This script is designed to create an Excel spreadsheet from each HTML table from auto-generated index.html file.
It needs to be very robust but unfortunately I don't have many example files to test it against. Any feedback on style, possible points of failure, or vulnerabilities would be very appreciated.
Powershell
f... |
I have just learned classes and was practicing some examples from the textbook when I came to a screeching halt.
Here's the program I have written, which is complete but not optimal. What this program does is that it inputs information about the company and then lets you display the data or search for a specific set o... |
This is a Python document (PDF) downloader I made to download some question papers automatically. However, it is very slow. Any better way to do this?
try:
import urllib2
from bs4 import BeautifulSoup
from time import sleep
import os
import sys
from time import sleep
except ImportError:
prin... |
I was searching for a way to display a List<T> with n elements in a user friendly and easy to handle way within the console application. So I wrote this console-list-pagiation method.
Probably there are ways to improve the usability of my approach.
public static void ConsolePaging<T>(this IEnumerable<T> Values)
{
i... |
I would like you to take a look at this simple script I wrote that's supposed to emulate the Unix sort [FILE] | uniq -cd command. What's different about my script though is that it also lists line numbers telling the user where occurrences of duplicate lines are located in the file. Please, tell me what you think as we... |
I have been using R for stock analysis and machine learning purpose but read somewhere that python is lot faster than R, so I am trying to learn Python for that.
I am using Yhat's rodeo IDE (Python alternative for Rstudio), Pandas as a dataframe, and sklearn for machine learning.
This is the code I wrote for forecasti... |
One of the requirements of a third-party SDK I am integrating with is to sign an identifier string with the identity from a p12 certificate. This code loads a p12 certificate from the application's bundle, opens the cert with the specified key, retrieves the key, signs an input string (the requestorID) with the inform... |
I'm mainly wondering about whether or not I have used the (TAP) async/await pattern correctly. I get a bunch of these warnings, "Because this call is not awaited, execution of the current method continues before the call is completed.", however that sounds like exactly what I want. Which is for the server to be able to... |
I've been thinking of using this:
template <typename T>
inline T from_string(const std::string& s){
std::istringstream iss;
iss.str(s);
T result;
iss >> result;
return result;
}
in my code. Then I thought "I shouldn't construct istringstreams all the time", and made it into this:
inline std::istringstre... |
This is my simple game that gives you a country and has you enter the corresponding capital. What do you think? (Before running it you need to do score.txt.)
package com.company;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Random;
import java.util.Scanner;
p... |
In one site there was one question to make one program where you will be given a positive integer n and we have to calculate the number of such pairs (a, b), where n = a² - b² and both a and b are positive integers.
for example 15 = 4² - 1² = 8² - 7².
Currently this question is closed and in my case I am still not able... |
I'm experienced with JavaScript, but new to refactoring. Sonar specified that the below function is too complex. I'm looking for suggestions on how to simplify it, mainly the conditional statements.
_executeWhenReady: function() {
if ($('#applyButton').length) {
$('#applyButton').on('click', function(e) {... |
I'm creating a little proposal for the data access layer using Dapper ORM.
The code is based in an generic interface IStore:
public interface IStored
{
int Execute(string Name);
int Execute<Output>(string Name, Output Parameters) where Output : class;
IEnumerable<Output> ExecuteReader<Output>(string Name) w... |
Here, the for loop loops over a arraylist and checks smsc type of batch and submits it to the proper queue.
Is there a way to rewrite this piece of code in a better way? Is there any way to eliminate the if/else?
for (Batch batch : input.getBatches()){
ArrayList<Messages> arrSentsms = batch.getlist();
String smsc =bat... |
I have written a prefix-free compressor that assigns the shortest bit-strings to the most common characters. It works very well for natural language as some characters (SPACE, "a", "e" ...) are much more common than others ("y", "z" ...)
This method of compression does not work on random text where each letter is equal... |
I have a working VBA script for Excel that converts a matrix of data with multiple records in per row to multiple rows with one record per row.
A StackOverflow user told me that the code could use significant improvement, specifically mentioning implicit variants (not quite sure where I went wrong there), difficult to ... |
This is basically designed to format/bold/fill whatever cell has a value greater than 0. I would appreciate some help in simplifying it so that it doesn't lag as much.
Public Sub basesheet()
Dim ws As Worksheet
Dim icounter As Long
Dim wso As Worksheet
Dim rw As Long
Dim lastrow As Long
Set wso = Sheets("Base sheet(O... |
The program is complicated. I didn't call any class because it was hard for me using classes.
Did I do something redundant or did I miss something?
import java.util.Scanner;
public class Gpa {
public static void main(String[] args){
int i;
Scanner keyboard = new Scanner(System.in);
//7th t... |
I am working on brushing up my data-structures knowledge, and was hoping to have my code/thoughts reviewed.
Thoughts on Generic Array Stack:
Insertion/Pop are amortized to \$\mathcal{O}(1)\$. This is because the stack resizing itself should be a rare enough event that it won't increase the overall time.
Peek is \$\mat... |
This connects to Salesforce to import a report through the enabler4excel add-in. The report overwrites what is currently there on the sheet (2016 Incidents Dashboard). The report contains about 55,000 rows and 10 columns each. I also have 8 columns of formulas (nothing complex) off to the right. The next section autofi... |
I'm currently making a mobile phone simulation, using a custom object in an ArrayList. I was wondering if there was any difference in using these two following styles.
First style, creating a new instance of Contact in my update method as so:
private static void updateContact() {
System.out.println("Enter a contact... |
I'd appreciate any comments about my Python calculator, ways in which it can be improved and where it's currently lacking.
import operator
"""
Do the actual calculation
"""
def calculator(operation, operand_1, operand_2):
ops = {"+": operator.add, "-": operator.sub, "/": operator.div, "*": operator.mul}
return... |
This code is a representation of lambda calculus using an AST instead of text.
-- beta
-- (App (Abst var body) env) -> (Sub body var env)
-- eta
-- (Abst var (App body var')) -> body
-- alpha
-- (Sub (Var var) var env) -> env
-- (Sub (Var var') var env) -> (Var var')
-- (Sub (Abst var body) var env) -> (Abst var bod... |
I have a method which uses the same code over and over again. I would like to optimize my code in such a way that there is no repetition in my code. I am sure there is a better way to do things instead of using the if-else statements.
private void web_content(final String content1, String content_type1, final String co... |
I am using Clojure spec to conform (coerce) a 1 or 2 value of a number type or string into a 1, 2 or :clojure.spec/invalid.
(require [[clojure.spec :as s]
[clojure.core.match :as m]])
(defn parse-number [n]
"Parses a string or number in a safe way."
(m/match [n]
[_ :guard number?] n
[_] (Integer... |
How can I improve the speed of the script?
$Excel = New-Object -Com Excel.Application
$Excel.visible = $True
$Excel = $Excel.Workbooks.Add()
$wSheet = $Excel.Worksheets.Item(1)
$wSheet.Cells.item(1, 1) = "Folder Path:"
$wSheet.Cells.Item(1, 2) = "Users/Groups:"
$wSheet.Cells.Item(1, 3) = "Permissions:"
$wSheet.Cells.I... |
This is my first application in Java, it imitates the world-known Ping Pong Game.
I have a lot of questions in my mind...
I read that the class Timer is not recommended with multiple timers so I use ScheduledThreadPoolExecutor which probably does the same? Is there something better than that?
The collision detection in... |
I have written code that can compile, execute, generate output and match that output with the actual output of the given code, kind of like this site. Currently, this supports only Java and C++ code. I need some suggestions about design, OO, architecture, packaging or any other suggestion that I could improve on.
This ... |
This is the first time using the Task Parallel Library and it seems to be performing much slower than I was expecting. The application is simply a web crawler that returns all URLs for a given URL.
Here is my method that, depending on the level param, will either download single page links (getSinglePageLinks()) or it ... |
I developed a function to send email based on this. Does this code have problems? Also, I'm not sure if this code is thread-safe because of the global payloadText variable.
#include <string>
#include <curl/curl.h>
static std::string payloadText[11];
std::string dateTimeNow();
std::string generateMessageId();
void se... |
Here is what I came up with for a binary search of an array. It allows for searching one or many columns to match. It assumes that array being searched is sorted with the same sort priorities as the order in which the parameters are submitted.
It seems to work well but any advice on performance or structure would be ap... |
I'm not really sure what the preferred way is to deal with records not found in the database. Is it better to write a Find method which returns null or a Get method which raises a RecordNotFoundException?
[AuthenticateFilter(UsernameAndSecretKey)]
[Route("api/v1/activities/emails/{id}")]
[HttpGet]
public IHttpActionRes... |
Any suggestions to improve?
public class FindSmallestMissingPositive {
public static void main(String args[]){
int a[] = {3,5,4,-1,1,-1,0};
System.out.println("Smallest Missing positive : "+ findSmPositive(a));
}
public static int findSmPositive(int input[]){
int min = input[0];... |
This class uses the openweathermap API to receive information about the current weather and forecasts. I am looking for any type of advice, but primary for structure and style improvement suggestions:
This method builds the the API URL:
private Uri BuildQueryURL(Interval requestType, NameValueCollection parameters)
{
... |
I'm implementing deep_get functionality to look inside arbitrarily nested Python 2.7 objects. Primarily for further logging.
This turned out to have surprising amount of quirks. Here's what I ended up with, would appreciate the feedback as I probably missed a few more things.
# coding=utf-8
from __future__ import unico... |
Background
I've been working on an algorithmic trading platform in Rust and utilizing the newly released futures-rs library to keep everything asynchronous and non-blocking.
One issue I've come across with this is that the majority of database interface libraries currently available for Rust are blocking, which poses a... |
We are trying to count to 100 on two hands!
Input is given like so: LP LR LM LI LT RT RI RM RR RP (i.e. 0111011100)
Where:
L = Left, R = Right, P = Pinky, R = Ring Finger, M = Middle Finger, I = Index Finger, T = Thumb
Our job is to make sure the code is valid according to this counting scheme, and then show w... |
I'm new to Scala and I'm trying to write a generic function to convert from Int to any scalar.
For example:
val res: Float = convertInt[Float](12)
val res: Double = convertInt[Double](12)
//etc
I've achieved the following code:
trait FromIntConverter[T]{
def apply(int: Int): T
}
def convertInt[T](int: Int)(... |
Here is a lexer for a grammar I'm designing. After benchmarking with 1MB files and having several iterations of the lexer, I found that coping the file being read into a buffer and lexing that buffer is the fastest. However, I can't seem to get under 0.3 seconds, and in order to process a file I need to load it into a ... |
I recently implemented a binary reader/writer for my multiplayer game.
Now reading bytes looks like this:
static int32_t readInt32(std::vector<uint8_t>& msg, int *off)
{
if ((*off) > msg.size()) return 0;
int32_t result; int size = sizeof (result);
memcpy(&result, msg.data() + (*off), size); (*off) += size;... |
Project Euler Problem #4: "A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
Find the largest palindrome made from the product of two 3-digit numbers."
The code works well enough until trying to find the largest palindrome of two eight ... |
Task description:
A set of product-thumbnails is shown. The user can filter the shown products by vendor(s). Done by clicking one or multiple buttons.
I used jQuery together with the Isotope-plugin: http://isotope.metafizzy.co/
First I had the idea of using iteration for assembling the filter-criterium string:
$(fun... |
For a game I'm writing using LibGDX framework and Kotlin language, I've decided to make a dev console. This is a WIP line parser. Since there's already a decent amount of code written I've decided to show it here to see what I'm doing wrong and what can be improved.
Intention:
Parse literals such as true, false, null ... |
Scenario
A portable controls/widgets library for Xamarin.Forms (PCL Profile 111) contains a combobox/dropdown/picker control where the ItemsSource property is an IEnumerable.
The ItemsSource can be populated with any IEnumerable of objects.
The combobox displays value by
DisplayMemberPath: string
The combobox sync... |
The code that I wrote is as follows:
public class Astack implements StackInterface {
private int sz;
private Object[] a;
private int topPosition = -1;
public Astack(int sz){
a = new Object[sz];
this.sz = sz;
}
public int size(){
return topPosition+1;
}
public boolean isEmpty(){
if(topPosition == -1){
return ... |
I want to make some VHDL code open source. But before I do, I want to make sure that it is as readable as possible. Things to improve upon could for example be naming and the use of comments.
The code is adding two binary-coded-decimal numbers. The algorithm behind it will come in the documentation. Note that this isn'... |
I have learned a bit of C in university and I'm now learning C++ independently. I'm trying to print out std::vector<std::string> char by char. I know, that in C, strings are arrays and are terminated by '\0' terminator. Can I assume the same thing in c++? I use C++14.
This works, but I'm unsure if it's the correct way ... |
I rewrote a ActionResult method that will output list of users depending if it is a SuperAdmin, OrganisationAdmin or GroupAdmin. I know there is a lot of things in the codes I still can improve so I would ask the community here the things I should learn and keep in mind when writing codes.
You might ask why I have para... |
I have written the following routines.
Do you know of any better algorithm?
Is there any faster way to pad an image for image processing?
How can I optimize them for better performance?
public class ImagePadder
{
public static Bitmap Pad(Bitmap image, int newWidth, int newHeight)
{
int width = image.Wid... |
Anyone can tell how to make this code faster?
This search takes too much time... 700 000 files for 15 minutes...
I will be grateful for each micro optimization!
Search Class:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Runtime.InteropServices;
public class... |
I have a console application, which uses Ndesk.Options to parse console arguments, request weather data and print them. I am looking primarily for code style suggestions.
This is the code, which parses the console arguments:
var argSet = new OptionSet() {
{ "l|location=", "Can be a city or a zip-code. Add a countr... |
I'd like to create a pyqt widget similar to the one Blender uses for representing its nodes After wasting some bounties without getting any answers on Stack Overflow, I thought maybe posting a little piece of code here in Code Review would be a better idea.
My goal is designing a powerful node graph widget using pytho... |
#include <iostream>
using std::cout;
using std::endl;
int arr[] = {3,4,2,1,-5,116,31,4,0};
void QuickSort(int start,int end);
int Partition(int start, int end);
void Swap(int * , int *);
void PrintArr();
int main(int argc, char* argv[])
{
PrintArr();
QuickSort(0, sizeof(arr)/sizeof(int));
PrintA... |
I'm making a chess engine that is going to run the function containing this loop many times a second, so I want it to be well optimized.
Which of these two implementations would perform faster?
This:
for(var j = idx-8, ji = 0; ji < 2; j-=8, ji++) {
if(b[j] != 0) break;
m[m.length] = [idx,j];
}
Or this:
for(var... |
I have written the following routines to convolve two images in the frequency domain which are represented as 2d Complex arrays.
How can I optimize my routines for better performance?
public static class Convolution
{
public static Complex[,] Convolve(Complex[,] image, Complex[,] mask)
{
Complex[,] ... |
I have written the following routines to work with digital images in various representations.
Can I optimize them for better accuracy and performance?
public static partial class ImageDataConverter
{
#region Bitmap ToBitmap32(int[,] image)
//Tested
///Working fine.
public static Bitmap ToBitmap32(int[,... |
Content of task:
Given a string of words and numbers. Extract the expression including:
the operator: either addition or subtraction
the two numbers that we are operating on
Return the result of the calculation.
Example:
"Panda has 48 apples and loses 4" returns 44
"Jerry has 34 apples and gains 6" returns 40
"lose... |
Following up from my previous question where I put up a solution in brute for algorithm to this problem from codechef.
Given some number \$K\$ and a list of \$N\$ numbers, count the number of pairs (\$i\$, \$j\$) such that \$1 \le i \lt j \le N\$ and \$|a_i − a_j | \ge K\$.
\$1 \le N \le 65000\$
\$1 \le K \le 10^8\$
... |
I just started learning Haskell, and I made a simple program which can calculate factorials and powers:
Input:
What do you want to do (0=quit, 1=factorial, 2=power) 1
Enter a number: 10
The factorial of 10 is: 3628800
What do you want to do (0=quit, 1=factorial, 2=power) 2
Enter the base number: 2
Enter the exponent: ... |
I've defined myself a function for caching requests and their responses in a browser environment; I'm using ClojureScript.
(defn make-requester [namespace time-limit fun]
(fn [cont & params]
(let [cache (ls/get-item namespace)
key (pr-str params)]
(if
(and
(contains? cache key)
... |
Background
This is the first (and only) Go program I've written so far.
My employer just formed a small team to make a prototype written in Go ready for production, so I (and everyone else on my team) am learning Go as quickly as I can. We're setting up our documentation, version control, issue tracking, etc... using G... |
Thanks for the help so far! Especially all of the people who helped out on part I - seen here. Making a report from payroll details
Here's the revisions to the code based on feedback from that thread. The goals of this code are to take payroll details in spreadsheet format, and to make a properly formatted report that ... |
As part of a challenge with one of my colleagues, I developed a NodeJS Sudoku solver. It takes an array of all the values of the grid as input (with zeros for absent values), and outputs the same array with zeros filled with the missing numbers.
I choose to use ES6 classes because it helped me to reason about the code.... |
I've recently started working on some projects with react & redux.
I understand it is best practice to manage component/UI state inside a component with setState etc. However there are various advantages to fully utilising the global state to do with making components and the application as w whole easier to test, debu... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.