instruction stringlengths 71 71.9k |
|---|
I wrote this code which adds children to nodes according to the weight of the heading of a non-binary tree. I am a novice programmer, so I would love to know how this code can be improved.
import java.util.LinkedList;
public class Sample {
public static void main(String... args) {
Sample buildTree = new S... |
My company uses an Excel workbook to schedule our manufacturing jobs. I'm attempting to log job positions on the schedule and import them into Access on a semi-regular basis (twice a month?). This will enable analytics of lead times currently impossible with our current system.
The schedule is made up of a 19-row-heade... |
I have written a small HTTP downloader using
boost::asio
Beast library (proposed to be included in Boost)
network::uri library for handling URIs
It's nowhere near completion but I would like to get some feedback from you guys. I wanted to use as much of async interface as I could.
The idea is that it gets a std::vec... |
I am studying software engineering and we just started learning about object oriented programing. I wanted to be a bit ahead of all others, so I decided to write a little text-adventure using classes.
I would be very glad to know what I can improve and what I can do better. Should I do something differently?
Main.cpp
#... |
The Challenge:
A valid string is one in which all distinct characters occur the same
number of times. Given a string S, check if the string can be made
valid by removing less than or equal to one character. If yes, output
"YES". Otherwise output "NO".
Constraints:
\$1 \le \lvert S \rvert \le 10^5\$
String S con... |
Just looking for a way to include a single validation function inside of another function, that will stop any other lines from executing if it fails.
NOT an if statement... I'm trying to avoid nesting, because.. idk, I want to try to avoid it as much as possible.
So.... Is it bad to throw an Error to do this? I can't ... |
I have a String with a double number. Unfortunately, the number is created on backends with different locals, so it could be both 101.02 and 101,02 (different delimiters). I need to get the position of this delimiter if it exists and get 0, if it is not.
I've come to two options:
int pos = amount.indexOf(',') == -1 ?
... |
I have a problem with generation of my report. Data is read from other sheet in report. Most time is wasted on execution of LineColor() and LineGroup(). Those operations are based on hierarchy, which is copied and pasted into cells parallel to every row.
CoreElementCode CategoryCode SubcategoryCode BMCCode Produc... |
I'm a beginner in Android and I've been experiencing "Skipped xx frames" everytime I load up my activity which is a list of languages. I tried optimizing the listview following tutorials (applied recycling and viewHolder pattern) but still can't get rid of the issue.
ListLanguagesActivity.java
package com.experiment.wo... |
I am using SAP BPM API's to fetch currently running process instance and the task belonging to the running process instance. I have return below method on an EJB Class which does the job, however it is extremely slow and have n2 complexity which is making it dangerous to move on production system as the process instanc... |
The below code is run on a routine rather than say login time but being new to using FETCH NEXT I can't help think maybe there is a trick here to merge at least one of the SET lines.
The end results should give me the total unique users, how many completed a module and how many passed.
Fields are indexed on the table... |
Could someone tell me their opinion on my leaderboard system?
library
#!/usr/bin/env python3
def write_score(score, name, scores, filename, splitter=','):
"""writes a score with a name to a file, in a specified format"""
score_tuple = (score,name)
scores.append(score_tuple)
with open(filename,'w') as f... |
I wrote a generic data converter that takes one kind of data and converts to JSON and XML types of file. Now, it reads data from the given CSV file hotels.csv. The first line is a header which describes all field names and, follows the rules given below:
a. A hotel name may only contain UTF-8 characters.
b. The hotel U... |
I have a well functioning Nagios Core system set up. I wanted to make our alerts both easier to read pertinent information quickly as well as provide additional details from custom host and service variables. While I have touched on Perl in the past this is my first real Perl script. The larger portion of CSS and HTML ... |
I'm practicing this question where I'm supposed to make a table programatically and although I'm not getting any errors the table is not showing.
var ROWS = 13;
var COLS = 2;
window.onload = function go() {
var out = document.getElementsByClassName("funky")[0];
var table = document.createElement("table"... |
I have created an object to handle all my database manipulation needs. Here is my object constructor and one of its functions:
class dataMonster{
var $sn = '';
var $un = '';
var $pw = '';
var $dn = "";
function update($table, $records, $set_value, $compare, $compare_value){
$table=preg_re... |
I have written a pop song generator which uses the Markovify library to produce lyrics based on (just for testing purposes) songs by Avril Lavigne.
In order to make the generator a bit more competent I have adapted some code which uses the nltk library to determine whether or not two words rhyme. I have used this to m... |
Today I present some code for finding all words that
begin with a given prefix and some simple test cases for review.
from itertools import chain
sentinel = object()
def insert(tree, word):
for letter in chain(word, [sentinel]):
tree = tree.setdefault(letter, {})
def words_beginning_with(start, tree):... |
I am leaving my first job because I always worked alone on projects from my day one, which was both useful but also taught me some bad practices some of which I managed to realize but many others are still there. Not being able to learn from colleagues, constantly being pushed with deadlines because it's a really small... |
I've created a scenario below, in which a user can build a pizza and choose their toppings, then order their pizza:
require 'active_record'
require 'logger'
ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:'
ActiveRecord::Base.logger = Logger.new $stdout
ActiveSupport::LogSubscriber.color... |
I have written some code which works out which sums of reciprocals of whole numbers sum to one, e.g:
\$\frac 12 +\frac 13 +\frac 16 =1 \$
\$\frac 17 +\frac 18 +\frac 19 + \frac1{10} + \frac1{11}+ \frac1{14}+ \frac1{15}+ \frac1{18} + \frac1{20}+ \frac1{22}+ \frac1{24} + \frac1{28}+ \frac1{30} + \frac1{33}=1 \$
RecipSum... |
From SICP
The sum procedure is only the simplest of a vast number of similar
abstractions that can be captured as higher-order procedures. Write an
analagous procedure called product that returns the product of the
values of a function at points over a given range. ... "Also
use product to compute approximat... |
I had to build a cash register that included a Coin class that allowed for all types of coins to be used. Please note that for this, no control structures can be used and no data structures such as arrays, lists, and what not. Any constructive criticism is welcome.
public class CashRegisterTest
{
//Test the methods... |
I have a data set where leaf mass (MASS) was measured in 30 different tanks (TANK) on 3 dates (DATE). The tanks were also assigned to 5 different treatments.
I want to calculate the regression slope of the mass loss for each tank so I wrote the following function in R
k.tank <- function() {
k <- numeric(0)
tank ... |
I am still a beginner in CSS and am trying to make a tiles/cards design. I have reached this code, and I want to know if my layout this way is good or if there are any improvements I need to make.
Is writing margin and padding auto is the right practice? How about using flexbox as am doing?
html{
font-size: 12px;
... |
What I mean by displacing an enumerable is skipping the first n items, then returning the next n items, then returning the first n items, then returning the rest of the enumerable.
What do you think? Does this idea have any value?
using System.Collections.Generic;
public class EnumerableDisplacer
{
public virtual... |
This is a variation of the Dining Philosophers Problem. The task is to coordinate several students inside a gym. All students try to obtain their desired training weights from a shared weight rack. During runtime, the user can issue commands to:
block a student (b + student id)
unblock a student (u + student id)
proce... |
I have built a small script that provides touch screen right click context menu with long touch press in my ELAN touchscreen.
There is no need to remove your finger in order context menu to pop up.
System Specs: Debian 8 Sid, with XFCE and Nautilus as WM.
Some environments handle right clicks differently:
Environments... |
My employer gave me a sit-stand desk, but I was forgetting to use it: I just sat almost all day. So for fun and learning I wrote a simple JavaFX reminder app to remind me to alternate between sitting and standing. The app is pictured below:
In the screenshot the app is telling me to stand, and it shows the time the re... |
I have written my first JavaScript program from scratch and am looking for advice to check whether it is efficient and effective or how it could be improved.
var apiURL = 'https://services.domain.com';
function dataPlanOutput(countryCode) {
document.getElementById("dataplan_list").innerHTML = "";
... |
I am writing an app to copy the contents of a directory to a removable drive. I'd like to know if there is a better way of structuring this.
The UI layout is a TreeView for selecting the source directory, a CheckedListBox which lists the removable drives, and a copy button.
Here is the code I have for when a user click... |
I have this Huffman compressor that can compress both text and binary files by treating each as binary files. (By the way, it is fully compatible with this Java implementation.) See what I have:
Code
main.cpp
#include "bit_string.hpp"
#include "byte_counts.hpp"
#include "huffman_decoder.hpp"
#include "huffman_deseriali... |
I am a Java programmer and very new to Perl. I decided to work on a simple script that could solve a problem I encounter in my day to day work. This script will search the log file for a pattern and print the complete potentially multi line log statement that has a match for this pattern. Additionally, the matched patt... |
I'm trying to implement a sparse vector (most elements are zero) dot product calculation. My major idea is to represent each sparse vector as a list (which holds only non-zero dimensions), and each element in the list is a 2-dimensional tuple -- where first dimension is index of vector, and 2nd dimension is its related... |
I'm working on a problem to select k nearest points for a given point. Any advice for bugs, improvements are appreciated, including general advice to implement find nearest k points.
My major idea is using the select-rank algorithm (similar to quicksort, using a pivot value, and divide-conquer the distance array). I th... |
I feel like there would be a better way to this. Essentially, I am transporting the data from an excel file to a DGV, and then from a DGV to an Access database. Should I cut the middle man or is this fine the way it is? The problem here is that my cells structure has to match access very closely to work.
private void b... |
Overview
I wanted to create a small console app that would point at a given directory, evaluate the last accessed date of each file within that directory, and if the last access date was below a certain threshold, archive that file. The archive folder structure should match that of the source directory. I also decided ... |
I want to create a new Excel files from an Apache POI object. The filename should contain the standard name, the current date and a counter, if necessary, to prevent collisions. I have a working solution here:
private File createFile() throws FileNotFoundException, IOException {
LOG.debug("Create File");
DateFo... |
I have been making a script to interact with a library I created before. I have ended up with a working script, but feel that the argparsing could be done a lot cleaner, and better.
First of all, some details about the script. These are the different processes that I try to support, using * to show it's required:
Logi... |
I need to work with stored procedures, with the help of Entity Framework Core. This is my function:
public async Task<bool> CheckIfUserRegistered(string phoneNumber, DateTime dateOfBirth)
{
if (string.IsNullOrWhiteSpace(phoneNumber))
{
return false;
}
using (var cmd = _db... |
I am trying to write a simple reusable pool of curl handles. I found this wonderful implementation of the blocking queue.
The pool itself looks like this:
class curl_pool
{
private:
int m_size;
queue<int> m_queue;
CURL **m_handles;
public:
class connection
{
friend class curl_pool... |
I often perform a lot of reshape(), transpose() or squeeze() operations on numpy arrays for numeric calculations. Often, this obfuscates the code. The initial shape as well as the resulting shape is unknown.
Prior solutions involved:
Comments (which may outdate).
Tiny functions with somewhat helpful names from_tbf_to_... |
Is there a more elegant way to do this in JavaScript?
function swapKey(obj, oldKey, newKey) {
if (obj[oldKey]) {
obj[newKey] = obj[oldKey];
delete obj[oldKey];
}
return obj;
}
(I understand that it mutates the original object and is not functional and makes the returning of obj somewhat redundant and tha... |
I decided to code a simple Hangman in Python today and wanted some feedback on the code since I only started programming three weeks ago.
I intentionally didn't add a lot of whitespace, it just doesn't make it any more readable for me - but feel free to give me reasons to start doing so.
Any tips and suggestions are ap... |
Sum Lists: You have two numbers represented by a linked list, where each node contains a single digit. The digits are stored in
reverse order, such that the 1 's digit is at the head of the list.
Write a function that adds the two numbers and returns the sum as a
linked list.
EXAMPLE
Input: (7-> 1 -> 6) + (5 -> ... |
I've implemented a promises in mongoose to reduce the amount of callback hell but I am not sure whether my technique is correct.
The scenario:
Before I can save my schema I want to run some functions in specific order. These functions update other collections in mongodb. So I have used promises to implement this.
Code:... |
Assign equal number chores to each person (assertion made elsewhere to ensure chores % number of people == 0) with the stipulation that each chore must not be one which the person was assigned the previous time.
My simpleton solution (there has to be a cleverer way):
import random
chores = ["hoovering", "dusting", ... |
I was wondering if you can give me advice / and your opinion on the following code. I'm aware there are a few things that it doesn't presently deal with that could be enhanced (I don't have time, this is part of an assignment and the basic functionality is complete).
Notifying user of their guess count has to be incre... |
kinda new to OOP, and I wanna know if i'm heading into the right direction. Also I should mention I'm not using AJAX
AnswerVoteManager.php
<?php
require '../config.php';
interface voting
{
public function voted();
public function redirect();
public function vote();
public function deleteVote();
public function addVote(... |
Implementing OAuthAuthentication with OWIN and Identity to secure Web API and let external application like Chrome Extension to access our self hosted API for getting and posting data through our server.
I know this is the basic implementation of OAuth. Could this still be improved in terms of security and best practic... |
I have a little class for loading a config file:
// index.js:
class Config {
constructor(path) {
this.path = path || this.defaultPath;
this.config = fs.readFileSync(this.path, { encoding: 'utf8' });
this.config = JSON.parse(this.config);
}
get() {
return this.config;
}
}... |
On one of the projects I'm working on, we have many objects that store (small) strings, loaded from database. I know std::string's have small string optimization (SSO), but the overhead, in my opinion, is too big; most strings are < 16 characters, and on my platform sizeof(std::string) is 32, wasting 50% of memory. Als... |
I want to write a cleaner version of the code shown below. It's about two different rows consisting of numbers that have to be weaved.
It's for an assignment for a course i'm currently following. This is the assignment:
Traveler, if riches are to be achieved, the solution only has to be weaved.
5,4 4,5 8,7
Weave 6... |
For Advent of Code Day 1, I found myself needing to use a tuple as a key in a dictionary. Seeing that I can't extend tuples in Swift, I decided to extend CGPoint to conform to Hashable:
extension CGPoint: Hashable {
public var hashValue: Int {
return hash()
}
func hash() -> Int {
var hash ... |
This heap will be used for A* search pathfinding in my 2D isometric game engine. It uses lambda functions (instead of std::less or std::greater) to allow me to dictate min-heap or max-heap more dynamically. It also uses lambda functions for FindByKey, ReplaceByKey, and RemoveByKey so that the search key can differ from... |
I am reading about algorithms and got to the binary search trees. I wanted to ask if the following implementation of a Binary Tree is correct.
import random
class Tree(object):
def __init__(self):
self.root = Node()
def insert(self,data):
self.root.insert(data)
def delete(self,data):
... |
I was requested to make a Sign-in program for the LGBTA Center at my university. They wanted something where anyone that came by and visited could leave their name and email, but also so that no one that came behind them could see who else has come in, like an Excel sheet or regular piece of paper would do.
The progra... |
I wrote a function in VBA for Excel that finds the highest row and highest column number in a range, which may include multiple, non-contiguous areas.
The function contains a parameter I call rowOrColumnOptionand I want to only allow values r or c (to return either a row or column number).
I was able to do this with an... |
I've recently started learning OpenGL and thought that a great way to start using it in its simplest form would be to create a Chip8 emulator using the keyboard callbacks and graphics that GLFW and OpenGL provide. As this question would be too large to request a review on my classes used with OpenGL and my Chip8 emula... |
Below is a sub I wrote to dynamically resize all the controls on a form. It utilizes the Tag property of each control. In that Tag property, I put four numbers separated by colons. So for instance, the Tag property of one particular control might be 03:10:20:10. These numbers represent Left, Top, Width, and Height (as ... |
Background
I am authoring pulley.objective, an Open Source library that provides an object system inspired by Python's object model. I have some features implemented, and would appreciate feedback before I continue.
Ultimate goals include:
Support for calculated properties
Allow methods to be attached to an object an... |
I have this function I've written to encode strings of binary data as base64 strings. I'd like to see if there are areas where it could be improved, specifically:
Is the function correct? Are there edge cases I haven't accounted for? (Handling arbitrary UTF-8 correctly is a "nice-to-have" but not a "need-to-have" if i... |
I have this code I am doing to make my code modular js:
$(function(){
var url, settings ={};
var language = mainSettings.getLanguage(); /* there is an object in the page called mainSettings with current language */
function applyLanguageSettings() {
if (language == "en") {
settings.web = "... |
I am trying to self study algorithms and this is my attempt at topological sort using Tarjan's version of DFS. It runs correctly for the graph I included. Can someone tell me if this is correct and if/what optimizations I can make?
graph = {
'A':['C'],
'B': ['C', 'D'],
'C': ['E'],
'D': ['F'],
'E': ['F'],
'F': ['G'],
'G... |
This is an update of Using an API to obtain JSON data and get the date string and determine if data is stale
This is a Nagios check that will use an API URL, get JSON data, flatten the data into a usable Perl hash, and ultimately obtain a date string. Once the date is obtained, it should recognize the strftime format b... |
I already solved it in JavaScript, where I'm more comfortable. I pretty much ported the algorithm from there.
I wanted to try the first Advent of Code puzzle in a new language and I picked Racket.
It's a taxicab geometry navigation problem. Given input R3, L5 you:
turn right 90 degrees
move forward 3 steps
turn left ... |
Following is basic JS code to create a YouTube search bar, search of query and load the results in a dropdown menu.
I am new to JS programming and I am seeking advice for how to write better code.
main.html
<html>
<head>
<link type="text/css" rel="stylesheet" href="https://golden-layout.com/files/latest/css/goldenlayou... |
I'm trying to generate a random time between now and 3 years ago. To my knowledge, Go doesn't have a random(min,max) feature in either math/rand or crypto/rand where min > 0. To naively combat that, I generate a slice containing every time stamp within the relative now and 3 years ago, and then select the index at rand... |
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.