instruction stringlengths 71 95.1k |
|---|
Problem Statement:
Write a server (“Application”) in Java that opens a socket and restricts input to at most 5 concurrent clients. Clients will connect to the Application and write any number of 9 digit numbers, and then close the connection. The Application must write a de-duplicated list of these numbers to a log fil... |
I have written a relatively small msgpack implementation in C++, with performance that is not too bad, so I decided to write a NAPI wrapper around it, but the performance is just horrible. I am guessing this is because I'm having to find the type of everything before being able to pack it, and the performance of Napi::... |
I have come with such a code for checking IP addresses. But would like to know how clean and good it is from 1 to 10. What I care about are readability and simplicity. Please give me any feedback.
Should I go here with unittests?
import re
import logging
logging.basicConfig(level=logging.ERROR)
pattern = re.compile(r... |
This is a short Celcius to Fahrenheit conversion calculator that calculates the average of all entries before exiting. This program performs exactly to the required specification.
I have some concern about the cleanliness of the multiple variable declaration and initialization to zero in a single line. I've seen this d... |
I have been asked to implement a HASHMAP in C++ in a job interview (home assignment).
I'm a bit unsure about exception safety, but this is what I came up with:
Block.h
#ifndef BLOCK_H
#define BLOCK_H
#include <deque>
#include <map>
#include <mutex>
#include <iostream>
#include <memory>
namespace NsHashmap
{
templ... |
I have a energy meter which sends the kWh count periodically every few seconds via a serial port.
To store this data I write the counter value and the calculated average power of the last 10s in a influxdb measurment.
To calculate the power i use a loop that compares the current counter value with the one 10s ago. To a... |
I made a function in which 17 players are counting to number N. Function as a parameter takes a number N and returns which player is going to say N. If current number is divisible by 9 the counting order is reversed, and if current number is divisible by 17 the next player is skipped. I made this code, but is a little ... |
I wrote this ~100 line script recently, where I tried out Python's asyncio library. When it comes to asynchronous programming in Python, I just have 2 days of experience. I spent the last two days reading about it for the first time.
Based on all my readings and understanding, I think, there is no mess-up in the script... |
I saw this post and tried to do my attempt. This is the requirement of task:
Design a coffee machine which makes different beverages based on set
ingredients. The initialization of the recipes for each drink should
be hard-coded, although it should be relatively easy to add new
drinks. The machine should display the i... |
I am attempting to build an Android APP with the custom serializable class User. The public method Save is to save class instance information and the public method Load is to load saved information from the specified file.
The experimental implementation
Project name: UserClassSerialization
User.java implementation:
... |
I wrote this code to make a non-blocking manager along with pipeline operations using asyncio, my main concern is to catch received items producer, and when the received operation is complete. I want to return all together and merged if keys matches, however, I have a doubt where should I have to join the data at the e... |
I'm new to C# and I've just created a passwords generator. I'm not sure if my code is following best practices, etc.
The schematic of the program is simple. How many passwords of x length can be created with y characters, that's it. An example, following [a-z0-9], 2 to the power of 36 = 68719476736 generated passwords.... |
As part of the hiring process (QA position), I received as a homework assignment (which involves independent study) the following task:
Create a full automation test suite (in Python3), so that when
our developers finish writing the code, we will all be able to immediately test the code.
Note: This task should be comp... |
My first implementation of merge sort in C++.
I'm looking for any sort of optimization and/or conventional practice tips, such as using the appropriate data types and naming my variables appropriately.
#include <iostream>
void print_array(int[], size_t);
void merge_sort(int[], size_t, size_t);
int main() {
size_... |
I'm trying to copy data from a worksheet to another worksheet with some modifications made on the fly.
Here are the details of the stuff I'm trying to do:
Open the file from where I'm going to copy data from (xlsPath) using OpenFileDialog
Check the sheet's cell value V6. If it is empty then write something e.g. "na"
... |
We have recently migrated from SQL Server 2008 R2 to SQL Server 2017 web edition. I am not a SQL developer but enthuses to learn.
Since many of our scrips are of old SQL format, I am searching for some alternative to leverage new T-SQL formats to help optimize the codes.
Below is one example which I believe can be modi... |
I've encountered a situation with an if-else clause. Specifically, the positive case has only 1 expression, whereas the negative case is a sequence of statements wrapped in braces. Like this:
if( i >= list->count ) *result = 0; else
{
*result = i * 32 + 31;
while( mask >> (*result % 32) ) (*result)--;
}
I pers... |
I am new at C programming, so I would appreciate it if you could highlight the problems in my code. My biggest concern is wrong memory allocation.
There are some code snippets, where I repeat my code. Is there another way to get rid of them?
Github repo link.
sstream.h
#pragma once
#include <stdlib.h>
typedef struct ... |
The Character class is the base class, which is the superclass of Enemy and Hero.
Here is part of Character.java, the rest of it are just auto generated setters and getters.
public class Character implements java.io.Serializable{
private int maxHp, hp, attack, defense, level;
private int place, xp, gold;
pr... |
My code generates 9 random characters, grouping them into 3 letter groups from an array of permissible characters in the form:
A4b-c56-7de
Ie, 9 upper and lower letters/numbers, separated in groups of 3 with a '-' in between. However, since I need this for other generic stuff later on, the function accepts as argument... |
I'm having trouble on a question from Hackerrank, this solution works for smaller lists but seems to collapse when the list grows to 200,000 where I get the error "Wrong Solution". The problem is here so you could reproduce it. Im not sure if there is an error in my code whereby it would fail. Is there anyway to improv... |
following code below works fine but feels kind of a mess. Any one has a better way to do this?
I am creating a basic "Enter Pin" to unclick screen on an app. So if the user enters the 1st digit, then ellipse1 should be filled. And if the user enters the 2nd digit, then ellipse1 and ellipse2 should be filled. And if the... |
Is this code clean and optimized? When taking memory snapshots, it seems a bit high.
Anything I have done wrong or can do to optimize it?
#pragma once
#include <iostream>
#include <windows.h>
#include <sstream>
#include <Psapi.h>
// Author: https://github.com/TheRacc2
// Other Help: https://github.com/dgoguerra/, for ... |
# get rank which takes the users rank as an argument and determines
# if it is valid input
def getRank(x):
# make a list of the acceptable choices
choices = ['l','m','h']
# convert the users rank to lowercase
x = x.lower()
# create a while True loop that only runs if x is not in the choices
whi... |
char* join(char** strings, size_t num_strings, char* seperator)
{
int cache = 0;
int count = 0;
for(int i = 0; i < num_strings; i++){
cache += strlen(strings[i]);
}
char * joined = malloc((cache + num_strings * strlen(seperator) + 1) * sizeof(char));
for(int j = 0; j < num_strings; j++){... |
Recently, I made this gif opener using tkinter:
import tkinter as tk
from tkinter import filedialog as fd
import time
import threading
def getfile():
file = fd.askopenfilename()
window = tk.Toplevel()
def run_gif():
i = 0
while True:
try:
photo = tk... |
Given any series of numbers, for example 1,2,3,4,5 and given the arithmetic operands + - * / including parenthesis, what would be the most optimal way to build a tree that contains all permutations and all expressions for these numbers and operators? It doesn't have to be in a specific programming language like Java or... |
Link to revised (ver 2) question
This question contains the first version of the code for the task
explained below. The revised version is at C++ exception class for error reporting, compatible with C++98 through C++20 (ver 2).
Original (ver 1) question
I want a custom C++ exception class for error reporting I can use... |
Was given a take-home test as part of a job interview, which I failed due to a supposed lack of tests, logging, error handling and packaging. But I did touch upon all of these.. suggested time spent was only 2 hours. The task was to create a command line tool in Python that integrates with a trading API.
Not the most e... |
I have been learning Python/Flask for the past 5 months outside of full time work and have just finished a first complete version of an app:
Working site: https://rubiks-cube-solver.herokuapp.com/
Github link: https://github.com/samjcox/rubiks
The app mostly uses Python, Flask and Bootstrap, with a small amount of Ja... |
Write a Greeter class with greet function that receives a name as input and outputs Hello <name>. The signature of greet should not change throughout the kata. You are allowed to construct Greeter object as you please.
greet trims the input
greet capitalizes the first letter of the name
greet returns Good morning <na... |
I'm trying to implement authentication with "Remember me" option using Spring and Kotlin. I would really appriciate if someone could help me find potential issues with that implementation as well as improvements to the code.
Let's start with sign in API. It accepts 3 parameters, email: String, password: String and stay... |
I am new to using PHP OOP and decided to start learning by converting something I wrote in procedural PHP. So now I need your opinion and recommendations for my first work.
One of the main reasons I chose this project, is that it has a lot of repetitive SQL queries, with small differences (like a date interval for exam... |
This function should take in a string and a number as parameters and 'rotate' the string to the equivalent alphabet letter that is located at the letter position + 'rotation' parameter.
E.g.: "stackoverflow" --- "fgnpxbiresybj"
def caesar(inputString, rotation = 1):
zNum = ord('z')
alphaLen = 26
result = [... |
This is a follow-up question for Android app class serialization. Some problems have been mentioned in forsvarir's answer. Then, I am following JUnit 5 User Guide to redesign the test cases for User class. Because the part of Save and Load methods are the operations including read and write on storage. It seems that th... |
I have been learning python since being in lockdown, this is the first Tkinter application I've built without consulting the internet or seeking help anywhere.
It is a time converter where you can select the input unit via a checkbox and the other entry windows will fill with the correct conversion.
I'd like to hear fe... |
I wrote a function to return the first n length sequence which occurs twice in the digits of pi. Along with the repeated sequence, I want the indices of the first and second occurrences. For example, if n is 1, code returns (1, 0, 2) and if n is 2, (26, 5, 20).
For reference, here are the first digits of pi:
3.14159265... |
EDIT: I turned down the brightness on my monitor using the graphics options for the video card. This solved the issue. How this setting changed is a mystery...
I am leaving this up because googling it leads down some difficult and unhelpful paths.
ORIGINAL:
Google maps has become washed out. I cannot see roads. I have ... |
I am brand new to Rust and want to know if there are any convention violations in my code and ways how I can make it more readable:
use std::io;
fn main() {
let mut vec: Vec<i32> = Vec::new();
loop {
println!("Enter any number, 0 to terminate");
let mut num = String::new();
io::stdin()
... |
This question contains revised code from the question
What should a C++ error reporting exception class have to be portable across language versions?.
I summarize what is different from that code at the end.
In short, I have designed a C++ exception class suitable for use for
error reporting and would like feedback on ... |
Code
insertAt :: a -> [Int] -> [a] -> [a]
insertAt x indices xs = go 0 xs
where
go _ [] = []
go j (y:ys)
| nextIndex `elem` indices = y : x : go (nextIndex + 1) ys
| otherwise = y : go nextIndex ys
where
nextIndex = j + 1
Questions
How can I make this code more efficient?
How can I... |
I need to validate based on some condition if if failed then I need to return from that block. Please find below code
private String validate() {
String test = validateName();
if (!test.isEmpty()) {
return test;
}
test = validateAddress();
if (!test.isEmpty()) {
return test;
}... |
Good morning guys!
I've just got done fixing my previous version of this code, and here we are with the "final" version. How would I improve it further?
I wanted to create the board, and the players, but my skillset is severely limited. But I'm trying to improve everyday!
from typing import List, Tuple
from random impo... |
As part of my recent transition from c# to java i decided to write a small converter implementation to translate DTO objects to entities. I'm fully aware of already existing solutions, especially in spring boot, but decieded to create this class as part of my learning process to write projects in java.
General note: I... |
I find myself often use warp reduction in CUDA, then needing to broadcast (share) the scalar result amongst all threads. My question is, what is the idiomatic way to do so with clean expressive code that is also efficient? I wrote this simple template to do so, please review and comment. Or if you know a better way,... |
I wrote this code that takes the vessel coordinates and checks them against every possible port coordinates. If the distance between the vessel and the port coordinates is within x meters (in this example, it has to be less than 3 km), then add that port and the distance_to_the_port to the data frame.
Example dataframe... |
What I need to do is to return the prime numbers that are dividers of a some numbers in a list, so if
I = [12, 15] # result = [[2, 12], [3, 27], [5, 15]]
and this is the code that I used for that:
def sum_for_list(lst):
r = []
for num in lst:
for i in range(2, abs(num)+1):
if num%i == 0 an... |
I am working on a small to-do app with Vue (v 2.x.x). I list 5 todos from jsonplaceholder initially.
I can add more todos, delete them or mark them as done.
var app = new Vue({
el: "#toDoApp",
data: {
url: "https://jsonplaceholder.typicode.com/todos?&_limit=5",
dataIsLoaded: false,
isValidInput: true,... |
I have installed Geekworm x735 on my Raspberry Pi, it uses the script below with an infinite loop to determine if the power button has been pressed. I know there are some Linux utils that watch for file changes (inotifywait, watch, fswatch to name a few), I wonder if they are more efficient than this solution or if und... |
I have a Python function like so:
def get_values(n: int) -> list:
"""
:param n: the maximum absolute value
:return: sorted list of all the positive and negative permutations up to size n
"""
if n < 0:
return []
if n == 0:
return [(0, 0)]
out = set()
for i in range(0, n ... |
Hey everyone I was redirected here from Stack Overflow for this question.
I am completely new to thread synchronization using condition variables and pthreads in Linux.
Here is the code I wrote and I will explain the main idea behind it :
#include <pthread.h>
#include <iostream>
using namespace std;
pthread_cond_t bu... |
I stumbled into an idea for creating a simple class that would entirely avoid streaming of any data unless some condition is met. The idea here is that a ConditionalOStream object can be constructed around an instance of a std::ostream * and, optionally, a bool indicating whether streaming should occur. If the bool i... |
I have created simple code in which it takes flat file (txt) and eliminate the noise and error and only return clean rows, i.e. return flat file with the data I am interested in. it works fine but since I am a beginner I am sure my code is not efficient. I would appreciate if you can guide me into making it more profes... |
So I made this script for my calculator, so that I can just write whatever formula I want and the calculator would just ask for the missing pieces to do the calculations.
I made it so that it would be very easy to fill in, I just go to the end of the list, give it a name and the formula. That's it!
The working of it is... |
When starting an ipython repl for my project at work, I pretty much always want it started in the project root, not adjacent to the file for the buffer I'm viewing (this is python and module loading depends on cwd). While I can always start the repl and then %cd /my/project/root that is a pain the 50th time I had to do... |
This is a problem based on the game "NGU Industries" in which the objective is to build a factory. Each tile can hold either a production building or a "beacon" which increases the production of buildings near to it in a given offset pattern. In other words, adding a beacon increases the productivity of nearby tiles at... |
Yesterday I started following the hands-on OpenCL course. I now got to the point where we are requested to reimplement an approximation algorithm for Pi in OpenCL (in steps, up to a vectorized implementation). I have done so and wanted to get a review for it coupled with some questions I had.
My kernel:
__kernel void p... |
Assume a multi-line file (myInput.txt) with lines comprising one or more words.
echo -e "Foo\nFoo bar\nFoo baz\nFoo bar baz\nBar\nBaz\nBaz qux\nBaz qux quux\nQux quux" > myInput.txt
I wish to remove all one-word lines that are identical with the first word of any multi-word lines using Python.
echo -e "Foo bar\nFoo ba... |
Code
if (source.length > 0) {
if (
source[0].mandatory === true &&
this.allInputs.documentsType !== "mandatory"
) {
item.mandatory = !item.mandatory;
} else if (
source[0].mandatory === false &&
this.allInputs.documentsType === "mandatory"
) {
item.mandato... |
Prototype:
char *fgetline_alloc( FILE *fp, bool flush, int *nchars, bool eolend );
I realize this C99 function may be a bit more involved than expected, hence asking for reviews before using it for real (it's tested, but not extensively). I'll post the source code first, followed by detailed description (which I remov... |
I am using this merge sort function to sort table rows by Date, Letter, and Number. It works, but it is super messy and hard for others to read.
The dates are being sorted in two formats YYYY-MM-DD and MM/DD/YYYY which is why there are if statements regulating each format.
And the reason I am differentiating between le... |
Hello everyone!
In today's assignment I had to complete a rather unusual translator, take a look at my solution, tell me what I can do to make it better and show off yours!
Write a function that translates some text into New Polish and vice versa. Polish is translated into New Polish by taking the last letter of each w... |
As the title indicates this is one of the last most problems of Project Euler. The problem is straightforward. However, similar to the rest of the Euler Project problems either Memory Error or long execution times are problems. An explanation of the problem is:
Consider the Fibonacci sequence \$\{1,2,3,5,8,13,21,\ldot... |
I wrote a simple Zoopla real estate scraper for just practicing what I learned so far in Python, Requests, BeautifulSoup and overall web scraping fundamentals. By looking at my code I feel like there would be a better and more elegant way to write it but unfortunately as a beginner I don't know yet. So, I believe I sho... |
I have wrote following solution for one answer but I want to refactor to make it more simple and readable.
I am receiving params
sample_params = [{ user_id: 1, email: 'example1@example.com' },
{ user_id: 5, email: 'example5@example.com' },
{ user_id: 13, email: 'example13@example.com'}]
I want to create following ha... |
I thought this community is better place to ask my question so I ask here rather than at StackOverflow.
Recently, I learned that Numba can make Python function which uses numpy modules and for loops super faster so I was trying to implement it to my code in order to optimize execution time. However, ironically, using i... |
My code for a LocalBinaryPatern in python is running very slow. I tried optimizing it with tips from online. I'am still getting used to python, and programming in General so any tips are very welcome! Here is the code:
def localbinarypattern(image, radius=2):
h, w = image.shape
if radius == 1:
return 0
... |
I need some help to evaluate whether I am doing it right. The scenario is, a 3rd party application is sending a webhook request after a successful payment but the problem is that sometimes this application may send the same notification more than once. So it is recommended to ensure that implementation of the webhook i... |
Solved task is pretty straightforward: mounting partition if not mounted already, to start executable.
There is a couple of checks and notifications because it is supposed to be launched from X and there are no way to see stdout/stderr stream. I have started with much larger version and a lot of error handling, that is... |
I have been playing around with numpy and matplotlib.
My little project was to create a scatter plot ranging from -1 to 1 on both X and Y, but where the shading is done with the XOR scheme.
The following is the code that I have implemented (it is in a cell of a jupyter notebook, hence the trailing ; after plt.scatter):... |
I am writing a Python code for KMeans clustering.
The aim of this post is to find out how I can make my below mentioned code optimal when the number of clusters is very large. I am dealing with data with tens of millions of samples and scores of features. The number of clusters that I am talking about is of the order o... |
I have a simple class that listens click and draws two points on the page.
If first point is not exist it is drawn. When second point is present it should be changed after each click.
I dislike this part of code:
this.point2.element.style.left = `${e.x}px`;
this.point2.element.style.top = `${e.y}px`;
Full code:
export... |
I have the following working code to get IPv4/v6 addresses from host names:
#include <array>
using std::array;
#include <iostream>
using std::cout;
#include <netdb.h>
#include <stdexcept>
using std::domain_error;
#include <sys/socket.h>
#include <string>
using std::string;
#include <vector>
using std::vector;
#i... |
I've made a program which reads from the console and writes it in a .txt file. This programm should write in a file with \n.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
ofstream fich("file.txt");
if (!fich)
cerr << "Error!\n";
char fst = 'l';
st... |
I have an inner class for filtering:
private class RegSpecification implements Specification<Reg> {
private final transient RegFilterDTO filter;
private transient Predicate predicate;
private transient CriteriaBuilder cb;
public RegSpecification(RegFilterDTO filter) {
this.filter = filter;
... |
Problem:
Given a string aaabbcccaad print the no. of occurrence of the character in the same order in which the character occurred.
Expected output:
(a, 3), (b, 2), (c, 3), (a, 2), (d, 1)
The approach:
Loop through each character.
When the next character is not same as the current character, record the next character ... |
I have been trying to write a number guessing game and I am trying to condense the second while loop when guess =! random_number. I can't figure out if there is any better way to shorten the code but to still achieve the same result. I wonder if someone is able to help me out. If there's anything else which is redunda... |
This is a follow-up question for Android app class serialization. The implementation of User class has been updated and the functionality of null string checking, password strength checking and the correctness of date formatting are considered in this post. The part of password strength checking has been implemented in... |
I made this c# hangman game...
I would like to know what you all think about it.
This is a pretty basic but still gets the job done let me know what you think.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace idontknow
{
class thehangedman
{
public bool st... |
C++ has the function std::sample which randomly samples from a range and places the results via an output iterator. My goal is to create a utility that directly returns a single value in the event that we only want to sample a single random element from the container.
#include <iostream>
#include <random>
#include <alg... |
I'm new to C as in I've only studied it for a year and it's my first language. I still don't know how to handle real world code and so would like to see how a real world programmer would write up a program that can find and replace text in a text file.
It took me 3 days to figure this out and I've tried my best to writ... |
I have made this small checkout stepper with Vue (v 2.x.x):
var app = new Vue({
el: "#cart",
data: {
stepCounter: 1,
steps: [{
step: 1,
completed: false,
text: "Cart"
},
{
step: 2,
completed: false,
text: "Shipping"
},
{
step:... |
I'm looking for any sort of optimization and/or conventional practice tips, such as using the appropriate data types and naming my variables appropriately.
#include <iostream>
#include <vector>
#include <cstdlib>
#include <ctime>
constexpr short MIN_ELEMS = 3;
constexpr short MAX_ELEMS = 15;
constexpr short LARGEST_EL... |
I created a system that allows individuals to ask questions about code, and chat. I wanted to make this system smaller and better because this is easy to bypass for some reason.
The modules/packages I used for this chatroom project
import os
import time
Now the actual script that contains about 56 lines of code!
print... |
Recently wrote a brainfuck interpreter in Go.
Here's the Github Repo Brainfuck
Areas that need work
The parsing for brackets [] is still buggy and is known to fail when dealing with nested loops i.e [[]] any hints on how to approach the problem would be greatly appreciated.
After looking at this repo. He creates a comp... |
I have a fundamental but interesting question.
I have written this python code which checks the payload sent from a specific IoT topic.
First, I would love to get honest feedback and learn how to improve my code to be most efficient, readable, and straightforward.
Second I would like to know when you are using classes ... |
I have made a simple contact management in C++.
It's my second project; I'm pretty sure it can be done more better and I could decrease its runtime, but I just joined the C++ community this year. So can you review my code?
It's a CUI-based contact management system through which you can add, delete, edit or search co... |
As far as I test, there is no any bug point tested. However, I wonder that if there is a problem with the usage of arr.Length or arr.Length - 1.
Further, as to the boundaries like begin <= end with end = mid - 1 or begin < end with end = mid as in the codes.
// size is array length
private static int BinarySearch(int[]... |
I'm programming Tic-Tac-Toe using minimax algorithm with alpha-beta pruning after taking Harvard's CS-50. My logic is working perfectly, except for the return time of minimax (especially on the first call, when only one player played). I was thinking of replacing the extra recursive call of minimax to max/min value. I ... |
I have an endpoint in my RestAPI which can receive 3 optional parameters and then find information in the database with these parameters, also it is possible to combine the parameters. So, in my controller I take a Map<String, Object> which contains these parameters and then pass it to the service level, where I check ... |
this is a kata from codewars, here is the description of the kata:
think of a Quadribonacci starting with a signature of 4 elements and each following element is the sum of the 4 previous, a Pentabonacci (well Cinquebonacci would probably sound a bit more Italian, but it would also sound really awful) with a signature ... |
I am trying to plot heatmap with three variables x, y and z, each with vector length of 932826. The time taken with the function below is 28 seconds, with a bin size of 10 on each x and y. I have been using another program where the same plot happens in 6 - 7 seconds. Also, I know that the plot function of that program... |
Write an improved code to identify a valid straight of eight cards, e.g. 4H,5S,AC,7C,8H,AH,0S,JC. Note that the card combination may include Wilds (as we see in our example, with the Ace of Clubs standing in for a Six and the Ace of Hearts standing in for a Nine), but must include at least two "natural" cards (i.e. non... |
I'm developing a RPG game and being blocked by the settings of HP(hit points/health points/health power), attack and defense for the characters - Assassin, Tank and Warrior
I'd like to figure out the values so that the Assassin is guaranteed to defeat the Warrior, meanwhile, the Warrior is guaranteed to defeat the Tank... |
The Locker Problem is as followed:
Twenty bored students take turns walking down a hall that contains
a row of closed lockers, numbered 1 to 20. The first student opens all the
lockers; the second student closes all the lockers numbered 2, 4, 6, 8, 10, 12, 14,
16, 18, 20; the third student operates on the lockers numb... |
The live version is at my github
Lingo is a game where the host secretly picks a 5 letter word, then provides the first letter to the player. The player then guesses a word, and the host gives feedback on what letters are right, wrong, or in the wrong position.
I call this feedback match_string and use the following fo... |
I recently completed the following exercise, but wanted some feedback on how idiomatic etc. my haskell program is. This is from a course which introduces us to file IO before we cover the theory of monads, so my monad-knowledge is still in its infancy. Any feedback much appreciated.
Here's the task:
In StudentTeacher.... |
I am writing a credit card generator. I have method GenerateVisa() who will return either a 13 or 16 numbers string.
This is the default value but GenerateVisa can also take a parameter. THis parameter will allow us to force the output to either 13 or 16.
What is this parameter? I could use a int like GenerateVisa(int ... |
I have been working on porting my PowerShell 7 scripts to Python 3.9.5 lately, re-implementing the same logic in a different programming language, keeping what makes it work and removing unnecessary parts, improving the code, and this is one of the scripts that has been re-implemented.
The code is simple, and I know t... |
I have a list of path I want to filter out. I want to keep only paths matching a specific pattern and remove all paths matching another specific pattern.
To achieve this I pattern matched on each pattern. Here is the code:
let stringToSpan (s: string) =
System.ReadOnlySpan<char>(s.ToCharArray())
let matchWildcard ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.