instruction stringlengths 71 95.1k |
|---|
It's my first time here, so please accept my apologies in advance if something is wrong with my approach to asking.
I've been learning Python for a couple of months and I decided to have a go at a small project that I felt able to complete on my own: a version of the card game UNO, using PyGame for the graphical interf... |
Since I had to almost start all of the code again with first refactor and an eye opening advice on a random Overflow question, here it is again:
This is a code that selects the right sheet according to the day of the week(date) and time(Now).
The code finds the day of the week (in French), determines if we are in night... |
I was hoping to get some input on a class module I'm designing to abstract away the boilerplate of utilizing asynchronous queries in VBA. cQueryable supports both synchronous and asynchronous queries. So you could do something like call a package to populate temp tables. This would be done synchronously because you'd w... |
I have a working code as below. Is there any better way to return nil after the each loop and unless else in the below example?
def find_member(member_name)
unless members.empty?
members.each do |member|
if member.name == member_name
return member
end
end
nil
else
nil
end
end
... |
I tried to do a tic tac toe game, so, to base myself in something, I searched through multiple tic tac toe codes and took some ideas from them to implement on my code. Here's the result and I would like anyone to make an analisys of it and tell me your opinion about it!
It's almost completely funcional, the only thing ... |
I have coded more in Python but I am learning Ruby now. So I am trying to write a solution to create a family_tree and add and get relationships. The code below is of the file that contains the main function which is called from the command line. The below code works and solves the problem but I have written methods wi... |
A similar question was asked here, and I'm trying to do the same thing. But
I'm trying a different approach by deriving from std::array, and
This is a very focused question about constructors only.
Here is my gl_wrap.h:
// header guards snipped
#include <array>
#include <algorithm>
#include <cstring>
#include <GL/gl... |
I have a form on a page to add a Post (parent), before submitting the form, a user should be able to add 1 or more Sections (children) to the Post.
The form:
<form asp-action="AddSection">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group">
... |
I am having a bit of difficulty in designing my Go code.
I'll try to demonstrate things with a very simple example of adding a new user to the database.
My Handler is only doing one thing: Calling a service.
The service is managing all the business logic and then calling the DAO to interact with the database.
The DAO a... |
I'm working on WPF photo broswer app as a personal project. I realise my current strategy for thumbnail handling is poor as I read in the full image each time -- this shows when browsing a folder with more than a few images. If anybody can suggest changes that might improve this aspect of the code, or anything else, th... |
I'm new in Golang and haven't done concurrency in a bit. I would love to hear your opinion on my Dining problem Go solution. Description here, with a tl;dr below:
Five silent philosophers sit at a round table with bowls of spaghetti. Forks are placed between each pair of adjacent philosophers.
Each philosopher must ... |
I've been teaching myself Python over the last few weeks, I have an interest in cryptography, codes, etc. so I figured starting a Morse code translator would be a good project. I know my variable names could be different, it's not really encrypting, decrypting, etc. I'm mostly looking for advice on how I can make the ... |
I would like some feedback on my code, I'm new to coding with C# but I do have some knowledge on Lua and Python. Is there anything that I need to change/clean up to make it more simplified?
using System;
using System.Linq;
class MainClass {
public static void Main () {
int[] cards = {1, 2, 3, 4, 5, 6, 7, 8, 9, 1... |
I have two table. I want count how many times a value is in other table. So the codice from table "sorgente" is different in table contatore, because I have the suffix 'BRANO-' before the code.
sorgente
| codice | nome |
| 15 | mario |
| 16 | mary |
contatore
| nome_evento | data |
| BRANO-15 | 2020... |
Description
A WinForms application has a function to export objects of the following type, in various formats:
class Item
{
public int id { get; set; }
public string description { get; set; }
}
At the click of a button in a window, a SaveFileDialog is shown, and currently it provides the option to save the dat... |
Basically, I have 20 very similar objects and most importantly I want to do the same thing for all of them.
This is the ImportProcessor class for AutomobileExpense (AutomobileExpenseDataImportProcessor). And in this scenario I would need another 19 ImportProcessor classes for the other similar objects.
I have made comm... |
This is some code written in a course I'm busy taking on Udemy. It serves as a basic toggle switch to flip between light and dark mode. This includes the nav bar, background, images and the icon that changes from a sun to a moon.
The objective after the lesson was to clean up the code and make it DRY. I've done so to s... |
I recently started learning C, though I have some experience in other languages. I recently wrote a TicTacToe AI using the Minimax Algorithm in C. I would like to know how I could write better C.
#include <stdio.h>
#define X -1
#define O -2
#define MAX_SIZE 50 //This is the Max size of the Input Buffer
int turn = O; ... |
recently I wanted to create a morse encoder/decoder with playback ability, the program needs java version >= 11 to run.
the program requires a couple of jars :
com.google.common.collect.BiMap
javazoom.jl.player.Player
I used the BiMap for the following reason:
A bimap (or "bidirectional map") is a map that preserv... |
Given a text I have to find the preceding words to all numbers up to a stop word belonging to a check_words list (kind of stopwords).
My code:
check_words = ['the', 'a', 'with','to']
mystring = 'the code to find the beautiful words 78 that i have to nicely check 45 with the snippet'
list_of_words = mystring.split()
In... |
Problem
I'm writing a simple shell, and I want to have the nice autocomplete feature that bash has when you partially type a word then press tab:
Right now it can work independently from a shell, but it has features that allow it to find commands on the system. Examples:
>>> table = make_lookup_table_from(["hell", "wa... |
Ask user to input 10 integers and then print the largest odd number that was entered. If no odd number was entered, print a message to that effect.
I've been trying to solve this problem with python and I think I've figured out a way that covers all the cases that are possible given the mathematical definition of an od... |
Currently Rubberduck VBA files all the VBProject VBComponents in that do not have a Folder Annotation in a Folder named after the VBProject. It can be time consuming to manually organize the components for the first time and a inconvenient to add annotations to every Worksheet, Userform, Class, ...ect. When ran my co... |
A simple terminal blackjack game written in Python.
Follows basic blackjack rules: Blackjack pays 3 to 1, Hit, Stick, Double Down and Splits
Dealer hits until 17
Keeps track of some data
Wrote it for working on my object-oriented programming, i am recently new to coding, if anyone takes a look please comment could be d... |
So I have made 2 games without any internet when on vacation. I have used turtle because I did not install pygame. I was wondering how I could improve my games. Here is the code:
Pong:
from turtle import *
from time import sleep
import random, keyboard, math
setup(width=800, height=700)
if(input('Do you want to have ... |
I'm self-learning and pretty new to coding and created a Mastermind game in Ruby.
Any general feedback or advice whatsoever would be greatly appreciated.
The game is completely functional right now, and has a simple AI. At the beginning the player chooses which role they want to choose (codebreaker or code maker).
Chee... |
Getting my feet wet with Game Development, and was wanting to see where I could improve in my usage of Rust as well as Game Development concepts.
use rand::Rng;
use sfml::graphics::{Color, Font, RectangleShape, RenderStates, RenderTarget, RenderWindow, Text, Transformable, Shape};
use sfml::system::Vector2f;
use sfml::... |
Im finally done with my project and im going through my code and optimising it and trying to cut down on the chunky lines of code, how would i optimize this, it a series of if statments that matches text and adds value to a corresponding text box
private void btnfinalize_Click(object sender, EventArgs e)
{
... |
I am building a tool that interacts with a batched stream of incoming data. This data needs to be processed and the result returned. To split up the work I have created a class that has inbound (_in) and outbound (out) queues and workers that are getting, processing, and depositing the work.
This example takes an itera... |
The code below if launched on the command line is a simple guessing game.
A random character 'a', 'b' or 'c' is chosen, and the user is prompted until they guess correctly.
It's arguable that invalid input and a win is not necessarily exceptional. Should exceptions be used in this manner?
I am not sure what's a sensib... |
Simple star designer for HTML canvas. Allows you to change every variable about how to draw the star.
This can be used to create squares, triangle, circles, hexagons, etc. But isn't an efficient way to create them and is only recommended for creating star shapes.
Note! the rotation is purely for show and isn't included... |
I use Java8, I have a subclass of Thread called DelayedThread which wraps a Runnable and executes the Runnable after certain amount of time. It has a method called cancelOnlyIfStillSleeping() which interrupts Thread.sleep but I don't want to interrupt it once Runnable has been called because I'm afraid of interrupting ... |
Currently, I have a code which downloads a file from FTP to local hard disk. It then uploads a file in chunks to Azure. Finally, it deletes the file from local and ftp. This code is very slow though. Just wanted to know how to improve it.
private async Task UploadToBlobJobAsync(FtpConfiguration ftpConfiguration, Bl... |
I'm brand new to Ruby.
The function takes in a string of any number of words, and reverses the order of the words. Also, for each word, it takes the vowels and moves it to the end of the word. It also downcases everything. Thus, Hello World! would become wrld!o hlleo.
I am trying to use some Ruby features, hence why it... |
I've just finished implementing a Generic RecyclerView adapter in my Android app, written in Kotlin.
BaseAdapter.kt:
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
abstract class BaseAdapter<T>(
private var dataList: ArrayList<T>
) : RecyclerView.Adapter<BaseViewHolder<T>>() {
... |
Recently I've been learning about concurrency/parallelism and I decided to implement the Michael&Scott lock-free Linked queue (PDF) as practice.
I'm not entirely sure how to test this data structure or even if my implementation is concurrency safe, but any feedback is appreciated.
#![crate_name = "cqi"]
//! # cqi
//!
... |
I'm looking to simplify controller logic where multiple validation steps will either result in redirecting the browser or re-rendering the current view.
Overall I'm looking to:
Avoid excessive nested if statements
Avoid multiple calls to Controller::redirect with the same arguments
Avoid using "return $this->render();... |
From HackerRank "Repeated String" challenge:
Lilah has a string, \$s\$, of lowercase English letters that she repeated
infinitely many times.
Given an integer, \$n\$, find and print the number of letter a's in the
first \$n\$ letters of Lilah's infinite string.
For example, if the string \$s=abcac\$ and \$n=10\$, the ... |
I've written working LZ77 algorithm implementation which uses linked lists (they help to look for matching substrings faster). I'd like to get some feedback on my code's quality and also information about mistakes and dubious places in my program (if I have any).
#include <iostream>
#include <fstream>
#include <cstring... |
An array A is monotone increasing if for all i <= j, A[i] <= A[j]. An array A is monotone decreasing if for all i <= j, A[i] >= A[j].
Return true if and only if the given array A is monotonic.
public class MonotonicArray {
public boolean IsMonotonic(int[] numbers) {
if (numbers == null || numbers.length ... |
Posting my code for a LeetCode problem, if you'd like to review, please do so. Thank you for your time!
Problem
For an undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible rooted trees, those with minimum height are called minimum hei... |
I have built a website in Django in which I tried for the first time to create a complex app. It's an app that scrapes weather conditions on a peak in mountains, which are 17. I wanted to show a detailed forecast in separate templates, so I have 17 views which look almost the same.
Only 4 views:
class KasprowyWierchFor... |
I am creating a social network and I want to know if this is a secure way of uploading pics/gifs and videos.
if(isset($_POST['post'])) {
$uploadOk = 1;
$imageName = $_FILES['postToUpload']['name'];
$errorMessage = "";
$picdate = date('Y-m-d_H-i-s');
if($imageName != "") {
$targetDir = "ass... |
ceil_constexpr is is based on: https://stackoverflow.com/questions/8377412/ceil-function-how-can-we-implement-it-ourselves/8378022#8378022
ceil_constexpr2 is a simpler version that takes advantage of truncation.
WARNING 1: Both ceil functions uses from c++20.
WARNING 2: ceil_constexpr uses bit_cast - a c++20 function ... |
Seeking to learning and have fun, I wrote out this script (what I expected to be) self explanatory and would appreciate some comments on that.
I published it as a gist and tried to do my best on what I understand about object-orientation, documentation, code readability and python best practices, so to speak. The idea ... |
On Linux there is the cat command which outputs files concatenated but on Windows there exists no such command. As a result I decided to attempt to recreate a simple version of it but with challenge which was that I could not use any part of the C runtime library.
#include <windows.h>
/* global variables */
HANDLE std... |
I was inspired by this answer to make this.
ex[0] = 1;
ex[n_] := ex[n] = ex[n - 1] + 0.5^n/n!;
The double assignment in the second line is very important. This causes all function calls to be evaluated only once. Once it has been initially evaluated, it will be saved in ex[n].
After a little research, it looks like ... |
#include <functional>
template<typename return_type, typename... argument_types>
struct stateful_function_pointer
{
using function_type = std::function<return_type(argument_types...)>;
using function_pointer_type = return_type (*) (argument_types..., void*);
function_pointer_type callback ()
{
ret... |
I need to set different __table_args__ for the mapped class depending on the backend DBMS, e.g. mssql and mysql - and this attribute cannot be set after the class definition, e.g. class Repository(Base) has been evaluated.
Ideally, my db/models.py module would take a parameter db_type, when it's imported, but this is n... |
You can find my original post here on SO. I was very surprised that I couldn't find a pre-coded function doing a mean square error between a signal (array A, size a) and a pattern (array B, size b<a) in a sliding window fashion. Thus I made one... and obviously it needs a lot of code improvement. I don't really know ho... |
I'm trying to create a setup script for our projects in an ubuntu server. This is what I have now, but I don't know if its correct, or can I do it differently/better ? If someone could take a look pls. Thanks
#!/usr/bin/env bash
set -e
# ==================
# Step Functions
# ==================
# create_user() {
# ... |
I am working on a small internal app that works along an external API for provisioning purpose.
The code essentially is comprised of a series of forms where the user inputs data, this data is then sent to the API to register new customers.
This is somewhat quite a linear process I will try to explain:
Contact Creation... |
I have a block of code that is re-used and I want to use functional programming to remove this duplication.
My code takes an array of items, splits the items into batches of 500 and then does some kind of work on them.
In the first function it deletes items from a database:
Delete function:
const deleteDocuments = asyn... |
I was looking for a solution for a way to easily merge maps of serialized Yaml and came up with this.
Reference to a similar question (not asked by me):
https://stackoverflow.com/questions/25773567/recursive-merge-of-n-level-maps
Here is my take on how to handle this.
MapUtil.java:
import java.util.*;
static class Map... |
I want to get my code cleanner and more efficient. This code gets variables form a PHP file and filters it to show the selected user name, all available usergroups on a list box and the groups he is currently into in another.
<script>
function saveGroup(type,id){
$('#useridgr').attr('placeholder', '').va... |
I work as a front-end developer, mostly with Typescript.
But now i decided to learn Elm as well, more out of curiosity than for any practical reason.
My first program is a Connect 4 game, and in the code below i have implemented the following:
Initialize a 7x6 grid of numbers (7 columns, 6 rows)
In the grid, 0s repres... |
(Also, see the next iteration.)
I have this small program for terminating processes via their respective process image names (.exe files):
#include <stdio.h>
#include <windows.h>
#include <TlHelp32.h>
int main(int argc, char* argv[]) {
if (argc != 2) {
puts("processkiller.exe PROCESS_NAME");
return... |
I'm a beginner at C.
I'm currently implementing atof to build a raytracer, however I'm still learning how to efficiently write programs.
Assignement
Instructions
The program takes a scene description file as argument to generate objects. Some of these paramaters are float. Example of the file.
I'm parsing through the... |
I saw a guy who fit snake in a qr code and I wanted to do the same thing but with minesweeper. The maximum amount of data a qr code can hold is 3kb. My c program, without any compiler magic, takes up 58kb.
A tiny bit over the limit, haha. So before I started performing alchemy with the compiler and compression program... |
I'm looking for critiques to see what I could have done better or different ways I could approach writing a script for finding even or odd numbers. I am new to programming with JavaScript, and programming in general. This is one of the first challenges I wrote for finding even or odd numbers.
var numList = [];
... |
I am looking for any feedback for this first script I have written. It is a mix of openpyxl and pandas, where it takes employee times from different Excel workbooks, then creates a weekly sheet for each person in a new workbook, and fills in the individual sheets.
Somewhere else that I had asked about this code suggest... |
I am trying to create an application that on the front end presents the user with a text editor to input code into and then I will run that code and return the result. I thought it would be a fun project to try and build my own version of leetcode as a learning project.
Right now this is what I am doing to run the prov... |
In order to learn web server programming in Node and JavaScript, I decided to implement a simple web server that only does one thing:
Display data of the HTTP request as an HTML table.
The actual data to display is arbitrary. In this example I'm displaying the contents of the header, along with the method, url, and h... |
I wrote a B-Tree implementation in C++20, based on my previous Red-Black Tree implementation.
Unit Test Demo : https://wandbox.org/permlink/Brw6TgAhdy89OIyj
Any feedback will be welcomed!
#include <algorithm>
#include <cassert>
#include <concepts>
#include <cstddef>
#include <functional>
#include <iostream>
#include <i... |
This bit of code is looking for the pair of integers that make up a product.
You can input any integer and it returns the pairs of numbers that, when multiplied together, make it up.
I have done a pretty bad job at explaining this, but the code it pretty simple.
All comments welcome.
num = 498
num_1 = 1
while num_1 < ... |
Similar to this question, I implemented the independent cascade model, but for a given networkx graph (including multigraph with parallel edges). My focus is on readability, pythonic-ness, and performance (although the problem itself is NP-hard).
I cannot wait to hear your feedback!
def independent_cascade_model(G: nx.... |
Any improvements to this welcome, I have got it working and I'm happy with it. I'm not really all that proficient with bash shell scripts though.
Problem:
AWS can copy multiple files pretty much as quickly as it can copy one file, so if you have a lot of large files then the best way is to get Amazon to copy them in p... |
Description
I've written the snake game using C++ and FLTK. For simplifying the use of FLTK, a built-up library written by Bjarne Stroustrup was used. Bellow located main parts of the code written by me, a whole project can be found on GitHub: https://github.com/WumpusHunter/Snake-game.
Source.cpp
/*
Snake game
... |
I'm refactoring functions trying to do more of a in-line aproach.
private int GetRandomNumberHigherThanHalf()
{
double randomNumber= Random.NextDouble();
if (randomNumber < 0.5)
throw new Exception("randomNumber is lower than 0.5");
return randomNum... |
A day ago I started a c# project where I bruteforce passwords. Passwords can be both integers and strings. In the code I check how many characters the password has. Whilst this is kinda cheating it would take too long to crack otherwise. I am posting it here to see if it's good enough.
using System;
namespace Hacking_... |
I have a requirement where I get totalAmount and how much parts to divide that amount into as inputs. For the outputResponse I am using builder pattern and also avoiding null fields. Total amount is a big decimal (if null or less than 0, throw exception) and number of inputs can range between 1-3 (if outside of this ra... |
I has div block feedList which contains feedItems. Now to fill feedList with data (feedItems) i am using while loop. In future it will js which get data from backend dynamically.
I created 2 buttons, which is used to border num of feedItems in feedList. One is "5", another is "10". To border num of feedItems i use func... |
In another question the user was determining the probability of having a streak of 6 heads or 6 tails in 100 coin flips. To find the probability they would generate 100 random coin flips and determine if there was a streak. They would test 10,000 such sequences of 100 flips to find that there was about an 80% chance of... |
This is citty.py, part of the citty repository. It's formatted using black, so I'm not super worried about small style items.
I'd like a review with suggestions for other, better practices -- choice of technologies or implementations (e.g., "use xml instead of json", or "use goodpackage instead of badpackage"), approac... |
This exercise is from jshero.com.
Write a function parseFirstInt that takes a string and returns the first integer present in the string. If the string does not contain an integer, you should get NaN.
Here is my working solution. I'm posting in hopes of receiving pointers on how I could have written the code more effec... |
I programmed a tic-tac-toe game using pygame. It's the first game I make. I'd really appreaciate any comments you have about the coding style and any improvements that could be made.
import pygame
import graphics # External module graphics.py
import logic # External module logic.py
# Setting up window
HEIGHT = 600
... |
Code review scope
My goal with this review is to receive big-picture observations and suggestions for improving the efficiency / ease of writing the front end of a web application with this basic framework. I want to focus on what it looks like it should do rather than the details of what it may or may not unintentiona... |
My code writes data and then receives data back. I want to log that this has happened, and I also want to inject a delegate so that I can get a callback to trace the data that is going in and out. This is example of the classes for reading and writing data in a request-response style.
public class IOExample
{
priva... |
The following codes purpose is to generate an array of bytes that represents some user defined data. This array of bytes will later be used for sending over a network.
WelcomePacketWriter is a concrete subclass of PacketWriter. Subclasses of PacketWriter can use methods provided by PacketWriter to write to the list of ... |
I was working on writing a fast implementation of a simple Huffman code compression of text. The idea was to write it using only the standard library, but I can't seem to find a way to make it faster. I am also looking for advise on how to write it more "Pythonic", without sacrificing speed.
I am aware that if I want s... |
(See the previous (i.e. first) version of this tool.)
(See the next follow-up.)
After taking into consideration all the advice by Martin R, I ended up with the following tool for terminating all the processes with given process image names:
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <TlHelp32.... |
The question is:
Given a non-negative int n, compute recursively (no loops) the count
of the occurrences of 8 as a digit, except that an 8 with another 8
immediately to its left counts double, so 8818 yields 4. Note that mod
(%) by 10 yields the rightmost digit (126 % 10 is 6), while divide (/)
by 10 removes the right... |
I've been writing a modular sandbox that has a web front end. Modules are discovered with reflection and could have parameters to them. When parameters are presented to the UI, I pass them through a set of JavaScript utility methods that map them to display elements which utilize Bootstrap 5 for styling.
function creat... |
I recently gave a coding test for a job which failed. It had two problems and one of them is shared in this question along with my solution.
Problem: Get balance of all transactions in a given category within specified period.
This is how a typical transaction looks like:
{
id: 123,
sourceAccount: 'my_account',
t... |
I have decided to create a program that can factor and solve quadratic expressions in micropython, where the standard library is limited, and i have no idea how to implement external modules onto it, so i had to bake this program from scratch.
The simple premise is, that it can factor and solve most quadratic expressio... |
I would like a code-review. Not so much on if the implementation is good or effecient, it's probably not, more on code style and readability.
import java.lang.Exception
import java.nio.ByteBuffer
import java.security.MessageDigest
import java.util.*
import kotlin.math.abs
fun main() {
val filterSize = 1_000_000
... |
I am working on a turtle project where the user can draw their own avatar.
The thing is, I want the user to be able to decide whether the turtle they drew will be filled, or not.
The filled part is simple, as by default, the polies will get filled,
but the only way I know how to avoid filling is to retrace the lines so... |
Using only Python 2.7 and the standard library (no imports):
Determine if a point is inside the rotated rectangle.
Test point 1: 670831 4867989
Test point 2: 675097 4869543
Rectangle:
Vertex 1: 670273 4879507
Vertex 2: 677241 4859302
Vertex 3: 670388 4856938
Vertex 4: 663420 4877144
Can th... |
To learn the ropes of Node.js and Express, I'm trying to implement a very simple REST API. The API says what it should do instead of doing it, so I can focus on the framework's structure. The requirement for the API is the following:
Mock API for a question and answer game.
/qanda endpoint: Repository of all question-... |
I am writing a lambda function to make a request and fetch data from API.
I am using as a class based approach which I think could refactor it and write in correct way.
May be we can change this class based approach if required. Below is the approach which I have implemented.
app.js
const apiService = require('./apiSe... |
I have three main questions:
Am I using std::unique_ptr correctly here? Using std::move and get?
Is there any way for me to make my _insert and _delete functions iterative?
I'd like for it to be something similar to my search function.
Do I need a destructor? Or since I am using automatic memory management, will all... |
Before you read the code below, note the following explanation:
I have three classes: Driver, Vehicle, and Itinerary.
They have attributes Driver.behavior, Vehicle.pRange, Vehicle.pBattery, Itinerary.destinations, and Itinerary.startTime.
The function findCand takes all these class attributes as input and returns as an... |
I have overridden setAnchorView() of MediaController class to display full screen option icon using below code.The code seems to be working fine in devices I tested but I have few doubts for which I need review-
The class assumes the anchor view is a FrameLayout to position full
screen imageview.
Should I use try catc... |
I tried to parse command line arguments. The program requires four arguments. I iterate over the arguments. If the argument is an option, I process the option. Otherwise the argument is one of the required arguments. In order to read the required arguments I need some kind of state machine. In the first case the first ... |
The code below will store a base64 image on another website and create an event to display the image on a Vue page in real time. It works fine and all.
My question is, is this a good way of doing it or there's a better way to structure the code? I've thought about placing the logic in a listener but it doesn't seem tha... |
I'm working on my first Rust project of any particular size, a rudimentary IRC bot. So far I've found solutions to most of the problems I've encountered, but something I'm now getting tangled up in as the project grows is my attempts to apply DI/IoC principles for testability. (I'm coming to Rust from PHP, so I may be ... |
I'm learning Rust and have decided to code up a toy YANG parser as an exercise. In case it's relevant, I mainly work in C and Python.
While working on the tokenizer/lexer, I tried to make it Rust-y, but have ended up with some rather clunky-looking match statements. They're of the form:
match fn_which_returns_result_my... |
A Sudoku solver that works recursively. I'd appreciate your comments about coding style, structure and how to improve it. Thank you very much for your time.
Code structure
The Solver works by accepting a string of 81 digits for the Sudoku puzzle input. Zeros are taken as empty cells. It parses it into a 9x9 Numpy array... |
I got this test online last week.
here is an example:
given this array:
{ 1 , 2 , 4 , 5 , 1 , 4 , 6 , 2 , 1 , 4 }
on condition that
index(x) < index (y)
find the number of possible pairs (x,y).
where x = y.
the answer would be:
count = 7 - (0,4), (0,8), (4,8), (1,7), (2,5), (2,9), (5,9)
Edit3: added picture to cl... |
I stumbled upon a post on Reddit a few days ago and I thought I make my own! It's a program to extract from a movie file (.mkv, .mp4, etc.) and stack them horizontally next to each other and make one picture of all the frames available in the movie file. how can I make it more pythonic, readable, and sufficient?
Also, ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.