instruction stringlengths 71 71.9k |
|---|
You can call it ports and adapters or hexagonal architecture. Regardless, what's facinated me about this picture isn't the layers. It's the Clean Architecture UML diagram over in the corner of a plugin that looks like an upside down, folded over version of the Dependency Inversion Principle:
So while the original DI... |
I have a PHP class:
<?php
//connectionclass.php
class connectionclass{
public $conn;
public $warn;
public $err;
function __construct(){
$this->connect();
}
private function connect(){
$this->conn = @ new mysqli('localhost', 'sever_user', 'user_password');
if ($this->conn->connect_error) {
$this->conn = ... |
I want to write a Python script where the input is a genotype (e.g. "CCDd") based upon the following Punnett square. The output should be the phenotype (e.g. "seal").
My code works, but doesn't look that 'pythonic' at all.
def colour(input):
if len(set(input)) == 2 and input[0] != 'C' and input[2] != 'D':
... |
The program has an input a list of doubles and the output needs to be a string containing the list values grouped by their value. The list values will be grouped if they are equal. Something like: input 9,77,5,5,31 => output 9 77 2*5 31
I created an algorithm in C# (in Java I think that is almost the same) for this but... |
I am thinking about how an inventory could be designed. The requirements for this inventory will be the following:
There will be predefined item types in the inventory.
The user can define new item types and add them to the inventory.
In the interaction with the GUI the user will be shown the item types contained in t... |
I always wanted to know how to pass member functions as arguments, and then I stumbled across templates that could automatically deduce types, and so I rejoiced! This is used in a Publisher-Subscriber system for a game server. I wanted the subscribing to individual packet 'types' (i.e. by enum) to be simple at the call... |
I am working on a second-sealed-bid auction web app. I have an Auction table to keep auction items on record, a Bid table to keep the bids, and a ProxyBid table to keep trace of the highest bids that users have ever placed.
Bid and ProxyBid are both associated with Auction. There could be multiple bid records for a giv... |
I have already got the answer for my previous question, and I decided to use std::vector<int> instead of int *. I have written the following code. Am I use shared_ptr properly now?
class MyClass
{
public:
MyClass(unsigned size, std::string name) {
_size = size;
_name = name;
_arr = std::make... |
I am writing code for the following equation with fixed boundary condition on a 2 dimensional lattice of \$L\times L\$ sites:
$$\begin{align}
x_{i+1} =&\ (1-\varepsilon)r\, x_i (1-x_i) + \\
&\ 0.25\varepsilon\left((r\,x_{i-1}(1-x_{i-1}) + r\,x_{i+1}(1-x_{i+1}) + r\,x_{i-L}(1-x_{i-L}) + r\,x_{i+L}(1-x_{i+L})\r... |
I am new to React.js. On the server side, I am using Passport.js for social authentication setting a cookie. With that cookie I am verifying on the client side with a higher order component (HOC). This component will check a specific value in the decoded cookie for every secure component that is being rendered. Is this... |
A few days ago I posted a question about my code. It was obviously awful and thanks to some advice from Hosch250 I learnt a lot of things about OOP.
Now, I rewrote the program. To me it seems a little bit better than the previous one but I still feel that something is wrong.
In ServerSide.java there are 2 threads: one ... |
I am seeking a review of a previous project I completed to help understand hash tables. The following is my implementation of a hash-table using linear probing.
My solution assumes a number of variables have been initialised:
Private int[] H; Representing the hash table with each value initialised to -1
private int... |
Advent of Code is a fun competition. Here is a link to the first day. Each day has two parts.
--- Day 1: No Time for a Taxicab ---
Santa's sleigh uses a very high-precision clock to guide its
movements, and the clock's oscillator is regulated by stars.
Unfortunately, the stars have been stolen... by the Easter Bunny. ... |
This is a naive implementation of a Z-sorting in order to fake 3D depth using sprites in a 2D scene. I would appreciate feedback on this, especially for performance as this has to be called each frame to handle moving objects.
A ZIndexHandler is added to every object that may need to be sorted. When an object is loaded... |
As the title says, the goal is to get all the possible palindromes of a string in C#:
public static bool IsPalindrome(this string source)
{
for(int i = 0; i < source.Length / 2; i++)
{
if(source[i] != source[source.Length - 1 - i])
{
return false;
}
}
return true;
}
... |
I need to convert an amount to an Indian currency format:
import decimal
def currencyInIndiaFormat(n):
d = decimal.Decimal(str(n))
if d.as_tuple().exponent < -2:
s = str(n)
else:
s = '{0:.2f}'.format(n)
l = len(s)
i = l-1;
res = ''
flag = 0
k = 0
while i>=0:
if flag==0:
res = res + s... |
I was just looking for some feedback for my c# program to run Euler's method. I was just wondering on any possible improvements, refactoring, inefficiencies... the usual stuff you probably deal with here.
I am using YAMP, a math parser that can evaluate string inputs (so I can run things like calculating the derivative... |
The purpose of this code is to to implement the time as the number of seconds since midnight. The class should have one data field (an int with the number of seconds since midnight) instead of three. The Driver class will test the Time2 class . This program should ask the user to input the number of hours, minutes, a... |
I created a JS view micro-library not too long ago it's named contours. Its primary purpose is element creation. It has some similarities to ReactJS. It lacks many features that React has like server side rendering virtual dom and the like. It is also a much smaller scope as it only cares about creating things for the ... |
This is a 10 question quiz that assess's the user's knowledge of the C++ programming language. Upon the start of the program some ASCII welcome art prints. The questions, answers, and correct answer are stored in a text file. The questions are loaded in random order. The user is prompted to answer each question, if the... |
The program is meant to compare values between the two datas given and see who has beaten the map faster and by how much. Formatting is set to MM:SS:SU. It looks REALLY sloppy right now and I'm sure it can be improved.
Working example
<?php
$yWin = 0;
$eWin = 0;
$yourTimeTot = [];
$enemyTimeTot = [];
... |
I am integrating the Celery 4 task queue into my Pyramid web server. The documentation seems a little sparse though. I found a somewhat dated pyramic_celery module that’s supposed to handle Pyramid’s .ini files, and to make them usable to configure Celery. There is also an even older blog entry which uses a similar ide... |
I am trying to build a very simple user interface in Python 3 using Tkinter to be used in windows. and have written a code which is not efficient - it is excessively long for no good reason. I am looking for advice, perhaps even conceptual, about how to make this short and elegant.
Here is a simple excerpt from the cod... |
The problem: Palindrome: Implement a function to check if a linked
list is a palindrome
If it's a palindrome, the list must be the same backwards and forwards
Below is the code I wrote:
def isPalindrome[A](list:List[A]):Boolean= (list.head, list.last)match{
case (a,b) if a==b&&list.size>2 => isPalindrome[A](... |
The problem is:
Intersection: Given two (singly) linked lists, determine if the two
lists intersect. Return the intersecting node. Note that the
intersection is defined based on reference, not value.
That is, if the kth node of the first linked list is the exact same
node (by reference) as the jth node of the s... |
Who has to use enterprise software like for example Microsoft Access knows that control: There a two select lists. The one list offers possible options. With a button you can add one or multiple options to a second list. The second list are your choices (from the offered options).
Moreover, one can move already selecte... |
I have made a simple python algorithm that calculates the amount of moves (Right, Left, Up, Down) to get to all other points on a grid from a certain starting point. However, the grid includes obstacles (*). The points that haven't been explored yet have the value -1.
def floodfill(x,y):
# The default grid
gri... |
Here is command-line blackjack for up to 6 players (not including dealer). Would love any and all feedback!
"""
This is the code for a blackjack game.
"""
from random import shuffle
from time import sleep
def get_valid_response(query, valid_responses):
response = raw_input(query)
if response.lower() not in [r... |
I want to write a cleaner version of this code. It's about two different rows consisting of numbers that have to be weaved. I have already asked this question at this link, but I have translated my code in English so that it's maybe easier to help me improve it.
It's for an assignment for a course I'm currently followi... |
SDel is an open-source command-line utility for secure file deletion. (For me personally, it is also an attempt to refresh my knowledge of modern C++ after a long period of using C.)
SDel Alpha requires a C++14 standard-compliant toolchain and the Boost Libraries to be installed for Boost.IOStreams, Boost.System and Bo... |
I'm loading products via an infinite scroll in chunks of 12 at a time.
At times, I may want to sort these by how many followers they have.
Below is how I'm tracking how many followers each product has.
Follows are in a separate collection, because of the 16mb data cap, and the amount of follows should be unlimited. ... |
I have been learning c++ for a few weeks now and I attempted this problem on Hackerrank Delete a node. I am aware of a similar post Delete a linked list node but the code seems more of a C structure than a C++ structure. Please feel free to suggest areas of Improvement and shorter way of writing this if any exists. Her... |
I'm working on an Entity Component System library. Right know I'm trying to clean up the Entity/Component part (only the code which manage the data).
But I have a class which I think is not really readable. Maybe the implementation can be improved too, but I reduced the implementation to be small and fast, so it's not ... |
This program I made takes a word as an input and prints all the anagrams of the word in a given word base from a txt file. I would like advice for code style, Java specific practices etc as I'm new to to the Java language (about 2 months).
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Arra... |
Challenge
There are n citizens voting in this year's HackLand election. Each voter writes the name of their chosen candidate on a ballot and places it in a ballot box.
The candidate with the highest number of votes wins the election;
if two or more candidates have the same number of votes, then the tied candidates' na... |
Here is my implementation of Huffman encoding using min-heap approach mentioned in this Wikipedia page. I'm looking for advice, using Python 2.7.
import heapq
from collections import defaultdict
class TreeNode:
def __init__(self, name, left, right, value):
self.name = name
self.left = left
s... |
I coded two answers to this challenge. The first one was a standard attempt, but after it timed out, I figured out the "trick" to solving the problem much more simply. However, I'd still appreciate comments and critiques on my first attempt, because there will be other problems that will need a long approach and I'd li... |
I started implementing algorithms to learn them in order to get better at programming. Here is a merge sort one and criticisms / optimizations are welcome.
import unittest
import random
def mergeSort(list):
"""Sorts a mutable list.
Args:
list: An unordered list
Returns:
The sorted list.
"... |
This is a take on Pebble Solitaire. The user inputs n number of games and after that inputs a strings of length 23 that contains a combinations of only 'o' (pebble) and '-' (empty space). If there are 2 adjacent pebbles and an empty space on either side, ie (oo- OR -oo), then you remove the middle pebble and you swap o... |
I made a class capable of moving Polygons around on a Polygon in a mostly smooth manner. Disclaimer: this was part of a school project (thus the use of Polygon rather than Image), but this code is entirely outside of the scope of the assignment, and the assignment has already been graded.
The project was a Bejeweled cl... |
Based on this question, I have written my own implementation of the Go Fish game, with the following features:
Full trace of all actions that happen in the game
More than 2 players possible
Each of the players can be a computer or a human
As a debugging aid, it is possible to see the computer player's hands by setting... |
I am doing a project and I have come up with some code to swap every letter with every other letter in a string, only the project was to be "efficient as possible".
Example:
"rya" = yra, ray, ayr.. etc
I understand exactly how the code works. I would just like to make it efficient as possible.
public String testSwap(S... |
I am going through "Haskell Programming from first principles" for the first time and I would like to get some pointers on what can be improved in my code, which is the following:
module DaPhone ( stringToKeyTaps
, fingerTaps
, mostPopularLetter
, mostPopularWord
, coolestLt... |
Inputs are two sorted lists (of the same length) of numbers. I would like to return a new merged, sorted new list. I have written the following code, but most lines are used to deal with the end case. I am wondering if there is any better way to write it.
def merge(array1,array2):
result = [0]*len(array1)*2
i ... |
Link to SQLite wrapper
func queryAll() -> [(String, String, String)] {
do {
let sql = try DB?.prepare("SELECT city, zip , temp FROM weather")
var arr : [(city : String, zip : String, temp : String)] = []
for row in sql! {
arr += [(city: row[0] as! String, zip: row[1] as! String,... |
I am trying to improve my object-oriented modelling and programming skills and hence made an attempt at solving the problem statement from this link.
Problem Statement
A teacher wants you to help her write a program that will randomly
assign each of her students to an activity at the various activity
tables available ... |
The textbook problem:
(strictly identical arrays) Two arrays list1[] and list2[] are
strictly identical if they have the same length and list1[] is equal
to list2[] for each[i].
Write a function that returns true if list1 and list2 are strictly
identical using the following header:
bool strictlyEqual(const int l... |
for (long i = 2; i <= numberOfRows; i++)
{
string quarry =
"=IF(J"+i+"<10000,J"+i+"*0.05,IF(J"+i+ "<30000,(J" + i + "-10000)*0.1+500,IF(J" + i + "<70000,(J" + i + "-30000)*0.15+2500,IF(J" + i + "<140000,(J" + i + "-70000)*0.2+8500,IF(J" + i + "<250000,(J" + i + "-140000)*0.25+22500,IF(J" + i + "<500000,(J" ... |
im new in VBA making, so all code below is still working tho but it takes a lot of line of codes. Even it is easier to maintain but if someone can simplify my noob-code to cut some lines and more eye-pleasing?
there are more than 20 toggle buttons in my userform
this is the example of my code, need help for make it sim... |
This is a follow up to my previous review request.
BitEx is a Python module I've been working on for a little over 9 months now, as a side project. It was published 6 months ago on GitHub, and as I edge closer to my 1.0 release, I wanted to take the opportunity to present my code on here, in order to straighten it out... |
I've been writing a basic script to enumerate SMTP users (via a user dictionary) on poorly configured SMTP servers. In scripts like this, I usually see arguments handled as follows:
if (len(sys.argv) != 3:
print "Usage: ..."
sys.exit(0)
I found the if and print statement approach irritating, but without a conc... |
Edit: I made a new calculator after taking your input New Calculator
I made this three-function calculator. I have been learning C for a couple of months, and I learned C++ through the internet.
This is my first "real" program in C++, it started really messy but I did a lot of refining and debuging and deleting unneces... |
I'm working again on the 3D model of a building in order to parse in JSON every parameters of every objects of the model. My program works well but it is too slow because of the huge number of information : about ~10k objects each containing ~20 parameters. In order to get a lighter JSON we organize it this way :
{
... |
I have made a program to weigh bags of money, and calculate whether too many/little coins are in the bags, and the difference.
bagWeight = 0
totalCoinsAdd = 0
totalCoinsRemoved = 0
totalBagsChecked = 0
def inputs():
global bagWeight
global totalCoinsAdd
global totalCoinsRemoved
#The above grabs th... |
Recently I made simple hangman game in Java.
Main.java
package com.company;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Type a passwords");
String word = input... |
I would like to implement service with explicit interface implementation.
I don't want to have public methods in service, only possible way to create instance is trough interface.
I am not sure what is best way to call method of same class if method is explicit implementation of interface method.
You can see in my code... |
I am a newbie to Java. I will be glad to hear your opinion with regards to this LinkedList implementation. The Iterators are self implemented by my decision:
public interface Iterator {
public boolean hasNext();
public Object Next();
}
public class LinkedList {
private Node mBase;
private class L... |
I have coded a very simple error class that will allow me to display errors if they should happen. For example, if a file is missing or a database connection couldn't be established I would display a nice error, instead of revealing an ugly PHP error to them.
<?php
defined('LATRINA') or exit('You cannot view this file.... |
I'm attempting to learn more about Haskell by completing a "hobby" project - a simple API to save/retrieve content for pages - used with Hakyll to generate static sites.
I have got something working for the tasks of retrieving all of the content for a site, and for adding a new page to a site. Hooray!
However, the code... |
Advent of Code is a fun competition. Here is a link to the first day. Each day has two parts.
--- Day 1: No Time for a Taxicab ---
Santa's sleigh uses a very high-precision clock to guide its
movements, and the clock's oscillator is regulated by stars.
Unfortunately, the stars have been stolen... by the Easter Bunny. ... |
I wrote an application that has a modular structure. Each module communicates with different remote servers. Time for execution of a task in each module varies. So communication should be asynchron.
Plus some restrictions like flexibility, scalability and so on are put.
So i decided to use CompletableFutures to build ... |
Update: Here is Take 2.
I want a slideshow with three primary pieces of functionality:
Has text links that act as bullet-points and can jump directly to a slide when clicked.
Pauses when a slide or link is moused over.
Resumes resumes playing from the currently active slide if the user clicks a link.
This is what I ... |
I've got a item inventory that each inventory item is tagged with multiple tags. What I've got is an API that takes a query parameter with multiple comma separated query items and returns a list of all items that match all of the tags.
The following code is working, however this isn't really using the ManyToMany attrib... |
After looking at a post on CR I found that pointers to member functions are incredibly hard to use, especially as callbacks. The current solution doesn't solve the problem mentioned in the linked post, but tries to get rid of the type erasure (i.e. std::function<>) by making the target type explicit. I tried to solve l... |
I'm on my second revision of this workbook and I've brought the run-time down from 37 seconds to 9 seconds on my computer and from 30-40 minutes to 8 minutes on my boss's old laptop.
I'd like to know if there is anything I can do to further increase the speed of this code that I may have missed. I took 3-4 subs and mo... |
I am building a backend APi for which I need to extract query filters from request URL of following pattern:
http://api.com/v1/users?filters=filters=(name like 'Milk' and name eq 'Eggs') and age ge 2.55`
The URL can contain complex filters like:
127.0.0.1:5000/v1/users?filters=(name like 'Milk' and name eq 'mil') and ... |
Running Office 2007, I have master workbook with data, which I:
Split master sheet data to new sheets for every salesmen
Create new workbook (with 1 sheet)
Put sheets of salesmen to an array according their manager
Copy array of sheets to new workbook
Delete first sheet on newly created workbook, save it as .xlsx and ... |
I am fairly new to Factories and Dependency Injection in MVVM.
I've build my View(Window) factory with help from SO, and I would like to know if I had implemented everything properly(code works just fine).
I'm sorry for the length, but there was no other way for me to show my complete example.
First, there is the Win... |
I am attempting to find folders based on their last modified dates.
import os, shutil, stat, errno, time, datetime
srcFolders = "C:\Users\Test\Desktop\Test"
archiveDate = datetime.datetime.strptime("2016/11/20", '%Y/%m/%d')
os.chdir(srcFolders)
for name in os.listdir('.'):
if os.path.isdir(name):
modifiedD... |
Day 5: How About a Nice Game of Chess?
You are faced with a security door designed by Easter Bunny engineers
that seem to have acquired most of their security knowledge by
watching hacking movies.
The eight-character password for the door is generated one character
at a time by finding the MD5 hash of some Door ... |
This function finds the 8 char passcode from a given "doorId".
Is there a way to find the passcode in an undetermined number of steps without using a while? Maybe involving streams? val passcode = stream(logic).take(8).
def findPassCode(doorId: String): String = {
var passcode = ""
var count = 0
while (passcode.... |
Assume I have a cache:
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
trait Cache[K, V] {
def put(key: K, value: V): Future[Unit]
def get(key: K): Future[Option[V]]
def remove(key: K): Future[Unit]
def getOrElse(key: K)(ifNotFound: => V): Future[V] = {
apply(key) ... |
Here is my code for simplifying a Unix path. Any advice is highly appreciated, including higher efficiency from an algorithm time complexity perspective, or any bugs.
'''
Simplify Unix path
Given an absolute path for a file (Unix-style), simplify it.
For example,
path = "/home/", => "/home"
path = "/a/./b/../../c/", =>... |
I would like to re-render my WPF chart control when data source is changed. My minimum requirement for a data source is IEnumerable<Point> but it could be also ObservableCollection<Point> or BindingList<Point>, so collection change notifications are sometimes becoming available.
Chart Serie class (simplified):
class Se... |
I'm working on a problem to sort array by low, medium and high -- in-place tweak original array. I'm looking for advice, especially any algorithm implementation efficiency. My current bottleneck of implementation is that I have to do partition twice, by low+medium and high, then do low and medium partition on low+mediu... |
I wanted to be able to parse Run Length Encoded (*.rle) files into something usable for a cellular automaton simulator (e.g. Conway's Game of Life and such).
Here is my main method which has the code I used for manual testing. The example file is taken from the above linked wiki.
def main():
sample_rle = \
"""#N G... |
This is my crude attempt at implementing a counting sort algorithm. My goal is to be able to sort lists of ints, negative and positive. As you can see I've employed such hacks as return res[1:] to get by. I'd appreciate any feedback I can get to make this a more pythonic implementation.
def find_min(a_list):
min = ... |
I recently got feedback for a programming assignment that was positive but mentioned that 'some things could be done better', and I was wondering if anybody here might be able to give me a more specific idea of what could to be improved & why.
There's quite a bit of code, but as I'm at a very introductory level I'm ho... |
I am learning Rust and finding it quite a difficult but rewarding and fun challenge to learn how to write idiomatic and succinct, clean code in it.
I have written the following simple naive JavaScript scanner code as an exercise to learn some basics of Rust. While it works, it feels like it is far from ideal Rust code... |
I have completed the following coding exercise. However, I got poor result for testing. I need some help to find out what is missed, incorrect, or incomplete in the testing section. I would appreciate it if anyone could please point out any mistake in the testing section or possibly any improvement in the related secti... |
I'm assigning a HEX-Value to a byte in a byte array and then send this byte array to a serial port. If the value is bigger than 255 the corresponding HEX-Value is supposed to be split into two.
Example: 750 = 0x2EE so A[0] = 0x2 and A[1] = 0xEE
Is this an efficient way to do the task that I want it to do? From what I r... |
I have a java application that migrates data from one database to another.
I have to do update data in my database with data from another database. Another database provided by the customer.
Now it is this way:
I make a request from java application to my database(oracle) to get the address and driver of database, user... |
A python program made with a friend to draw n dimensional hyper-cubes in python using turtle. Any suggestions for improvement.
import turtle
from turtle import *
import time
import math
n = int(input("How many dimensions?: "))
length = int(input("How long is each side?: "))
angle = (math.pi/180)*float(input("Angle: "... |
The stepping number:
A number is called as a stepping number if the adjacent digits have a
difference of 1. e.g 123 is stepping number, but 358 is not a stepping
number.
Example:
N = 10, M = 20
All stepping numbers are 10, 12
Return the numbers in sorted order.
The code I wrote does accomplish what is asked, but... |
I didn't know whether it was best to start with the general task I'm trying to solve, or the meat of the programming problem. They're both below but the former is rather long and solving the latter may not require it, so feel free to skip at will.
The task to be solved
I'm running a relatively simple dynamical simulati... |
Following these two SO questions:
Find duplicates for mixed type values in dictionaries
Group similar dict entries as a tuple of keys
I came to the conclusion that the solution I proposed is mature enough to be reviewed here.
The idea is to find duplicates in a dictionary such as example below, but with extended su... |
Here is a code I would need to make far faster: it is made to analyse more than 3000 DNA sequences of more than 100 000 characters each.
The matter is I have to compare it by pair, so that would be around 3000*2999/2 = 4498500 calculation and each takes 1 to 2 seconds...
Could you think of another way of doing it ? I... |
I was testing the RGB color mechanic on Excel, so I did the following:
sub paint()
red = 255
blue = 0
green = 0
Max = 48
For col = 1 To Max
For Row = 1 To Max
Cells(Row, col).Interior.Color = RGB(red - col * Int(256 / (Max * 2)) - Row * Int(256 / (Max * 2)), green + col * Int(256 / Max), blue + Row * Int(25... |
I wrote a script that adapts HTML tabs for different screen resolutions. On a small screen it's an Accordion and on wider ones they're Tabs. The script is for a production site, and I'm not so good in JavaScript yet, so show me any weaknesses.
(function ($) {
// html structure
// div - selector
// // ul
// // //... |
The idea of the program is to serve as a data accumulator collecting monthly expenditure from a user and later display it.
I wanted to implement classes/methods and just basic stuff that I understand to help me get better at writing better C++ programs.
This program works and does what I want it to do, but I figure sin... |
The code I have is based on BFS and a little bit of Dijkstra and returns the shortest path of an unweighted directed graph as an integer. I was wondering if someone could take a look at my code too see if anything could be changed or improved:
public int bfsshortestpath (V source, V target) {
Map<V, Integer> dist =... |
I recently started working with asyncio and coroutines. I have a coroutine that runs every 0.25 seconds to print "running ..." on screen indefinitely. When the script receives a SIGTERM or SIGINT it will exit gracefully.
I figured out that there are two ways to do that.
Method A: Run a while True: loop in the coroutin... |
While solving one question I got stuck with a time limit error. The main objective in question is to count numbers in an array \$A\$ that are either divisible by \$P\$, \$Q\$ or both.
Input format:
The first line contains a single integer \$N\$ denoting the size of
array \$A\$. The next line contains \$N\$ space sep... |
I have this short Python script for making images brighter:
import skimage.io
import math
import sys
def square_root_filter(input_image_file_name, output_image_file_name):
image_data = skimage.io.imread(input_image_file_name)
image_data_height = len(image_data)
image_data_width = len(image_da... |
im using the following code which is working.
The code provide range of random values but unique one i.e. it doesn't return the same values until the full range was provided ,what do you think and doest in ES6 there is shorter way to achieve this?
var range = [10, 20];
var not = [];
function randomRange(range, n) {
... |
What do you think about my code? I am a beginner and just started doing some algorithmic exercises to sharpen up my python skills.
Here is code for problem #1:
"""If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9.
The sum of these multiples is 23.
Find the sum of all the mu... |
I just started learning the basics to Swift 3 about 2 days ago. Since then, I've decided to make a simple calculator that can only do one operation at a time.
I was wondering how efficient this was and what I could possibly do to make it more efficient. Any type of criticism would be helpful too
import UIKit
class Vi... |
Just for curiosity I have done some benchmark for testing the best performance between switch, binary-search, and if-else statement.
here is the code :
package switchStatement
type Badge struct {
score int
badge string
}
func initiateBadges() []Badge {
badge := []Badge{
{score: 4501, badge: "gol... |
I tried to solve the Advent of Code quiz for day 5 in Go, since my brute force algorithm wasn't efficient in Ruby. I solved the first part of the quiz with the following Go code.
package main
import (
"crypto/md5"
"encoding/hex"
"fmt"
"strings"
)
func main() {
fmt.Println("Pas... |
The goal is:
I can add many services as I need.
I can add many taxes as I need (the idea is that services has all of this taxes)
Calculate per services each tax value
Sum all the taxes of each service and throw me the total value per service.
This is the first attempt at making a JavaScript program and I would lo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.