instruction stringlengths 71 95.1k |
|---|
I wrote a library and two related scripts to wrap notify-send from libnotify.
I need this script, since I am remotely administering workstations and wanted to automate desktop messages.
Since notify-send needs a DBUS session address configured in the environment variables and to be run within the context of the user th... |
Interrogating a web API using query-url's, for each query I can get either zero hits, one hit, or multiple hits. Each of those categories needs to go into a separate CSV file for manual review or processing later. (More on this project here and here).
The input data (from a 14K line csv, one line per artist) is full o... |
I'm writing a C# extension-method that converts any object to a type. E.g. the method shall convert a string with value "y" to a true-boolean - so there will be some specific castings like bools, chars, DateTimes,...
Here are some examples of my target:
int number = 3;
string stringNumber = number.To<string>();
string... |
I have the following Data.json file and I would like to update some of the values.
{
"A0_Water":"-306.3",
"A1_Water":"0.0",
"A2_Water":"0.0",
"A3_Water":"0.0",
"Barometer":"100.8",
"Bar_Offset":"0",
"Temp":"29.95",
"ip":"192.168.2.47",
"serial":"02:42:52:bf:82:27",
"A0_Sensor":"PS30A",
"A1_Sensor":"None",
"A2_Sensor"... |
I want to detect $number substring in std::string and then replace it with $number + 1.
For example, the string Hello$9World$1 should become Hello$10World$2.
Here's my code:
#include <iostream>
#include <string>
void modifyDollarNumber(std::string &str)
{
for (size_t i = str.length(); i --> 0 ;)
{
if (... |
I got this question from the interviewbit site test.
There are n horses and you are the kth person in the line to ride on the horse. All the persons in the queue will go with the lowest numbered horse available i.e if horse no.1 and horse no.2 are present , the person will choose horse no.1 .All the horses have their o... |
Our business intelligence suite outputs data as an indented hierarchy, as below:
Level 1 1000
Level 2a 600
Level 3a 500
Level 3b 100
Level 2b 400
Level 3c 400
I've written a macro that converts this into a 'database' format, where only rows with the base (mo... |
I have an application that needs to contact a remote API many times to request information about various products. It was taking around a minute with synchronous programming. I adjusted all my methods to be async and I still do not see a performance enhancement. I suspect it's because I'm awaiting each result from the ... |
I've already made a version of this game which was supposed to be played on the console. I got it reviewed and applied almost all of the recommendations I received in that topic. Thus you can consider this topic a follow-up from this one. This would be the first time I got in touch with SFML. I must mention that all th... |
This is a question from the book "Cracking the Coding Interview".
Write a method to decide if two strings are anagrams or not
I think interviewer will not be convinced with this solution because here it is no test of logic. Please help me to optimise this solution.
#include <iostream>
#include <string>
#include <algo... |
I am making a game in which the player has a certain amount of available boost. To show this, I am using a blue bar inside a black frame. The bar can grow and shrink at different rates as available boost goes up and down. It works well and looks nice, but it almost halves my FPS.
The relevant snippet:
var boostStyle... |
I did the following Excercise from Stroustrups PPP-Book (CH10 EX6)
Define a Roman_int class for holding Roman numerals (as ints) with a << and >>. Provice Roman_int with an as_int() member that returns the int value, so that if r is a Roman_int, we can write cout<< "Roman" <<r <<" equals " << r.as_int() <<'\n';
I rev... |
For some of the algorithms that I am implementing it turned out to be useful storing ids in order to iterate on objects, while also avoiding having to think about reallocation and invalidation of pointers.
It turned out that being able to iterate on sets of ids is something which is quite useful in general (at least to... |
I have written a simple packet-framing class, for converting un-encoded 'packets' into encoded/delimited 'frames,' to be sent over a P2P serial connection. The functionality is based on the RFC 1662 "Point-to-Point" protocol, and the general design was inspired by the article "Framing in Serial Communications" by Eli ... |
I was given a question during interview, and I decided to code it up and learn the difference way to implement this problem. Find the Maximum Sum of a Contiguous Subsequence in a List. I was wondering if you can code review the different ways of solving this problem.
Given a list consisting of both positive and negati... |
I have a need to take in a payload that looks like this:
{
"Registry":[
{"Token":"@!!!@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","ProcessId":"1"},
{"Token":"@!!!@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","ProcessId":"2"},
{"Token":"@!!!@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx... |
I was trying to solve this problem called lattice path from Project Euler:
Count the number of unique paths to travel from the top left to the bottom right of a lattice of squares.
How many such routes are there through a 20×20 grid? It takes me forever to get an answer...
(source: projecteuler.net)
# Input: ... |
This game has 4 people moving randomly, one unit in one of the four directions (up, down, left, right), with a fifth person as a designated tagger. If this fifth person tags someone, the person is out. Game ends when there is one survivor left.
import random
class Player:
def __init__(self, name, status, speed, h... |
I've created a program that translates any word into the form of igpay atinlay or pig Latin!
I got the project idea from here and you can read the rules here.
My program outputs the same translation as in the rules section in the link above, except for the word "always". It isn't really a big deal as the program transl... |
I have decided to rewrite what I did here, following the suggestions to use smart pointers. I will rewrite the other data structures as well using smart pointers where appropriate.
I just want to see how my code stands now, I am sure there are still areas I need to improve or fix. I again want to thank this community ... |
I wrote this function to map value to a color
I am looking for some general feedback on how I can improve the efficiency of the function. and if there is better way to do it.
function getColor($value, $values_range, $opacity = '0.7') {
$deltaS = ($values_range['max'] - $values_range['min']) / 2;
$ds = ($... |
I created a small Python utility to analyze multiple same-size files and report on the difference byte-by-byte (i.e. Hamming distance, not Levenshtein distance.) I am planning to extend the capabilities to allow a GUI display. Mostly, I'm interested in scalability and usability, with efficiency still being a high prior... |
open class Heap<T>: Iterable<Heap.Data<T>> {
data class Data<T>(val item: T, var priority: Int) {
operator fun compareTo(other:Data<T>): Int {
return priority - other.priority
}
}
protected var positions = mutableMapOf<T, Int>()
protected var data: Array<Data<T>?>
prot... |
I've made a useful PowerShell script to automate our code deployments to Salesforce. After a couple of afternoons learning PS and some try/error, I finished my script and it's working.
Nonetheless, since it's my first long PS script I was hoping you guys could tip me in how I could do things better, make the script mor... |
By applying the get_name and get_mac functions to the specified IP address, it is possible to estimate the network availability of a segment:
#include <Winsock2.h>
#include <iphlpapi.h>
#include <cstdio>
#pragma comment(lib, "iphlpapi.lib")
#pragma comment(lib, "ws2_32.lib")
bool get_name(unsigned char* name, char de... |
I saw this question on MSE and went ahead and wrote a solution to it:
https://meta.stackexchange.com/questions/313561/determining-users-reputation-as-of-particular-date
This calculates the reputation a user should have had at a certain date. I attempt to factor in everything that SEDE allows me to see. So -1 events fr... |
I have written this program to find anagrams in a "pile" of letters (it'd be an effective way to cheat at Scrabble...)
Run it like anagram abcedeede to get a list of all the words that can be made from the letters abcedeede (you might want to pipe to head, since there will be many).
This is my first "major" attempt to ... |
I made a function to censor a certain word from a piece of text. Is there anything I should fix or do more efficiently? What are some other approaches I could have taken to detecting words and censoring them?(This took me a lot of time to brainstorm)
Also, I would appreciate it if you told me how you brainstorm how to ... |
I have the following code:
let id = '';
let text = '';
// Note: `match` = [full match, id (first group), text (second group)]
if (match.length > 1) {
[, id] = match;
}
if (match.length > 2) {
[, id, text] = match;
}
return { id, text };
match could be null, or lengths between 1-3.
id and text need to be empty str... |
The aim of this script is to snapshot the current working directory of a git repository to another branch. Afterwards, it switches back to the original branch and restores the original state, including the working directory and staged changes.
#!/bin/sh
function git_snapshot() {
# Usage: SNAPSHOT=$(git_snapshot <bac... |
I am working on a university project that consists of creating a map application with openlayers as well as the necessary User-Interface. I am using jQuery, native JavaScript, PHP and of course HTML/CSS
The problem I have (mostly because I am not that experienced in web development with jQuery and JavaScript) is that ... |
I am creating a playbook that takes a variable ver at runtime and then runs tasks based on that variable. If that ver is defined, it takes the version number and installs a version according to that. If the ver is not defined, it defaults to a default version.
My playbook for now looks like:
- name: Download Maven from... |
I'm a C++ developer trying to learn Rust for fun and XP.
I decided to implement some of the Unix tools for practice.
Below is a simplified implementation of the find command. The program takes 0 to 2 arguments: The first being the file to find, the second being the directory to start searching (I'm aware that the args... |
I created a simple Pomodoro timer using React JS.
In my example:
Timer should count down seconds until it reaches 00:00
Timers should switch between 25 and 5 minutes
Timer should be able to start, stop, and reset
My questions:
how can I improve the switching between the "work" and "relax" modes? Now I use 2 functi... |
I'm trying to understand conception of creating unit tests for the frontend applications.
I have created higher order reducer:
// @flow
type action = {
type: string,
payload?: any
};
/**
* Async Reducer Factory to reduce duplicated code in async reducers.
* Higher Order Reducer.
*
* @param {String} name -... |
I written code to solve this problem which I found on leetcode. My solution worked for the vast majority of the test cases run against it but failed on 2 for some reason. The first test case it failed on had a extremely large input size for the tree so it's really hard to determine what is actually wrong with the algor... |
I'm working on a product category page where the product images have inconsistent heights so I've been asked to improve the page appearance without changing the images.
The page contains x number of products in a 3 column grid.
I decided to set the height of the image wrapper to the height of the image with the maximum... |
I want to use Python and Matplotlib to create a data set of images. I want to do this by transforming the plot to a numpy matrix. At the moment it takes about 0.1 second to generate 100 images of size 50x50 pixels:
Question: How can I speed up things a lot?
This is my code:
import matplotlib.pyplot as plt
import numpy... |
Write a program to sort an array of 0's,1's and 2's in ascending
order.
Input:
The first line contains an integer 'T' denoting the total number of
test cases. In each test cases, First line is number of elements in
array 'N' and second its values.
Output:
Print the sorted array of 0's, 1's and 2's.
Constraints:... |
This is a very simple concern, could somebody take a look at a few lines of my code? I'm writing a simple Java multi-user messenger, it is structured in a desktop client with a Swing GUI, a java server based on plain sockets and a service library holding general utilities... At the moment I transmit messages through a ... |
Given the CSV data:
,fan1,fan2,foil1,foil2
0,0.0,0.0,0.0,0.125
1,0.0625,0.0,0.0625,0.125
2,0.0625,0.0,0.0,0.3125
Which I want to turn into a kind of annotated pivot-table which can be plotted as a bar-plot:
,Err,PairType,StimType
0,0.0,Target,1
1,0.0625,Target,1
2,0.0625,Target,1
0,0.0,Target,2
1,0.0,Target,2
2,0.0,Ta... |
I don't get to write multithreaded applications very often, so be gentle with my threads :-)
I have an API input which contains a "score" and then a bunch of child nodes which also have scores, and perhaps child nodes of their own. I need to quickly sum up the total score of the entire tree.
I've elected a newWorkSteal... |
The program is written mainly for the status bar in dwm (a window manager for Linux), but it can be used for any manager that takes input from the root window in X. It queries different resources in the computer and displays the formatted information in the status bar.
This is a full, tested, ready-and-waiting program.... |
I want an integer parser so fast it risks discovering time travel.
I'm stuck in C# for a language, but that doesn't mean I can't try to use c++. So I wrote the following:
The best I could do
public static unsafe bool FastTryParseInt(string input, out int result)
{
fixed (char* cString = input) {
unchecked {... |
I have a DataFrame with values in columns a and b and a third column with the count of that row. I would like to convert this into a DataFrame (either new or remake the old one) with columns a and b repeated the number of times as is in the count column. It's probably more clear with an example. I have this DataFrame:
... |
Here is my code for the below packet time simulation problem using queue. My code works correctly but it's slow, please help with suggestions to improve run time and other suggestions for performance improvement.
Problem: You are given a series of incoming packets in an array of [t_a, t_d] pairs (one pair for each pack... |
First of all, I have my basic main method which does pretty much nothing:
public static void main(String[] args) {
higherOrLower HOL = new higherOrLower();
HOL.playGame();
}
Then I have the class and methods where all the action happens:
import java.util.Arrays;
import java.util.Scanner;
public class higherO... |
I have written a disassembler for Intel 8080, able to translate binaries into opcodes and parameters. Sorry for posting so much code, but everything posted here is useful for the understanding of the code (and I hope that you will criticize all of it too).
Thanks a lot for your time.
FileReaderHelper holds some functio... |
I wrote this function in order to create unique url's for my site. Using these urls, visitors could demo site functionality without having to create a login. The function was intended to return a unique string of characters which could be added to a url like this:
http://www.mysite.com?temp_user=dd5vbrk4ax4v4o09l2bm
M... |
So, I've been working on a very simple MVC framework and I wanted some feedback on how it works. I've worked it slightly differently where the controllers don't need to extend the base Controller class (I really didn't see the need to).
Firstly, you'll see the main classes Controller.php, View.php and index.php.
Contro... |
I use ASP.NET Core 2.1 and would like to fetch User at a service level.
I've seen examples when HttpContextAccessor gets injected into some service and then we fetch the current User via UserManager
var user = await _userManager.GetUserAsync(accessor.HttpContext.User);
or in controller
var user = await _userManager.Ge... |
I am a student and I am implementing data structures concept by myself using C and C++.
I have implemented the concept of hash table here by making a "Phone book" program that takes input which includes the user's name and his phone number and saves the data in the hash table.
The implementation covers insertion and se... |
I've implemented a simple AVL binary search tree. For no real reason I decided to implement this without multiplicity, so if we try to insert(5) twice, it's only stored once in the tree. I've also left out the in-order traversal and a few other methods I want to use this for, because I want to implement those elsewhe... |
I was doing this JavaScript problem called "Minimum steps to 1." You can find the problem here.
Given a positive integer - num, Following is a list of possible operations which can be performed on it:
num / 2, If number is divisible by 2
num / 3, If number is divisible by 3
num - 1
With these 3 available operations,... |
Lets say i have 3 tables: users, posts and comments.
users - contains information about registered users
posts - contains information about posts that were created by users
comments - all comments on one or multiple posts created by one or multiple users
.
This image is how my comments table looks like. user_id and po... |
The problem
We want to use a very large array for some computations. When created, all the elements of this array have to be initialized to some value. We'll only use a few values from the array1, so we don't want the runtime of the algorithm to be dominated by the initialization time.
In other words, we want to creat... |
I just wrote this password and password confirmation validation code function that checks to see if a password is empty or not, and is it match (password = confirmPassword). I'm not sure this is the best way to do it, but for now it dont works really well.
private void checkDataEntered()
{
if(isEmpty(RegisterFirstN... |
I recently started on C++ multithreading. Here is my code to print odd and even numbers in two different thread. Can somebody please review this code?
#include <iostream>
#include <thread>
#include <mutex>
#include <condition_variable>
using namespace std;
int x = 1;
mutex m;
bool evenready = false;
bool oddready = tr... |
I just started learning Racket as my first lisp dialect so after getting used to the syntax I implemented the Recamán's sequence.
Apart from the style, I'd also like to know if my code is a linear iteration or not. I kind of get the idea but I don't know how to be sure it is.
#lang racket
(define (recaman-seq size)
... |
Because neither sklearn nor Pandas provide a straightforward and complete one-hot encoder, I decided to write one myself. Both Pandas and sklearn do have an encoder with no option to decode, and the sklearn.LabelEncoder that has the decoding only produces that, labels.
Here's the class:
import numpy as np
class OneHot... |
A Minesweeper library in C#. To be included with any GUI stack.
Did some breakpoint tests and unit testing, seems to work fine.
I'm asking if the code makes sense to everyone, and if there can be improvements.
Three classes: Tile, Board and Game.
Tile
public enum TileStatus
{
Revealed,
Flagged,
Hidden
}
p... |
I'm looking for advice on implementing many-to-many. I'm modeling a site such as stack exchange: each Member has many Groups, each Group has many Members. I've introduce a Membership class. This class diagram summarized the code belowEventually there will be question and answer classes, but I want to get this part corr... |
I would love to get some feedback on my implementation of "Simon Says." I have not followed the original in that I have created a new sequence each time, rather and adding a new item to the pattern.
I'm particularly interested in the overall structure of my JS/JQuery - did I make good choices for the methods, is there ... |
I started learning Python by making an IRC bot, as it took some pains in another language. I've improved it now over time. As it involves networking, I'd also like some comments on that side.
# -*- coding: utf-8 -*-
import socket
import os
import importlib
plugins = []
class Bot_core(object):
def __init__(self, ... |
I have been working on credit problem for edx CS50 and got it working as intended. an issue I find with it is the way I have to reinitialise the cardNumber variable each time it enters a loop, and there are plenty of loops in my solution. Same goes for my bool value. Is there a better, cleaner way to go around this?
#i... |
Explanation
I started learning Haskell about a month ago. As an exercise, I recreated a little command line tool, which I had previously written in PowerShell. In the current state, it displays a list of videos in a specific directory and its subdirectories. Later I will add the functionality to play or delete those vi... |
I have looked at some previous posts and changed my code accordingly. Do you have some suggestions about my current code?
Here are my specific questions:
What should top() return if the stack is empty?
Why it’s better to use size_t for count?
I didn’t use new to create the stack in main(). Do I need to call the de... |
I use Python daily for long-running simulations (yes, very very optimal, I know). As you could probably guess, my coworkers and I have issues with simulations running for several minutes before finally bombing out. Part of what occupies my free time is finding ways to make out simulation framework detect and report err... |
I created a Greasemonkey script to allow me to quickly fill a specific form on a specific URL, for testing/dev purposes. If the current URL matches any of the urls found in the formsDefault array a button is added to the page that allows the user to auto fill with the default values.
This is my first time using arrow f... |
I am extending this post following from here. I made some of the changes that I could make in the previous post. Although, I have not been successful in creating iterators for my class.
The reason for the new post is to see if there is any additional changes I need to make to my code. As well as steps in creating itera... |
The Helloworld class executes all of the methods. Human is the interface, and Nate & Ryan are two classes that implement the Human interface. Are there any deficiencies or faults that my code contains that could help me in the long run?
public class Helloworld{
public static void main(String[] args) {
Hum... |
Looking to improve building UI in pure ES6.
This is the pattern I have adopted and has worked fairly well. This code increments the count, sets a data attribute to toggle the button, and issues a POST to the server with the vote payload object.
import axios from "axios";
class Vote {
constructor(el) {
this.el ... |
I recently read "The C++ programming language" chapter 22 and I thought the example given in chapter 22.2.4 was quite interesting. I thought it should be possible to make this system caching, so it could be used as a resource cache. It's unlike most other approaches I found on the net, and I got it working (the code in... |
I have following task, form a given array, I want the longest ascending array.
I will give you an example
int[] a = {19,12,13,1,2,3,4,5,14,23,24,25,26,31,32};
will return array of {1,2,3,4,5} - that is the largest sequence of ascending numbers in the given array.
Below is the sample code:
int[] a = {19,12,13,1,2,3,4,... |
I have a table of users, where each user has a group (or multiple groups) he/she is part of.
Currently I'm handling the users group via a Users class:
<?php
/**
*
* User (class) Model: Handles users (not system users).
*
*/
class User{
/*=================================
= Variables =
====... |
I am developing a microservice that enables business partners to order systems for common customers:
/*
ordering.js - Terminal ordering JavaScript library.
(C) 2017 HOMEINFO - Digitale Informationssysteme GmbH
This library is free software: you can redistribute it and/or modify
it under the terms of the GNU G... |
As many suggestions were given for the code I posted here, I decided to show you the new version for review.
I Removed the OpenCatalog class, Disassembler now has the responsibility for handling the catalog of OpCode that is now stored in an std::map.
OpCode is now a struct and AssemblyLine handles the generation of t... |
imaging a folder structure like:
Peter
|- Cats
|- Mini
|- Maunz
|- Tippsi
|– Dogs
|- Brutus
Eva
|- animals
|- Mini
|- Brutus
I'd like to delete all subfolders in Peter/*/ if they not present in Eva/animals/ (Maunz and Tippsi).
This is what I have so far. It's working but it feels as my combination... |
Problem:
We are interested in triangles that have integer length sides, all of
which are between minLength and maxLength, inclusive. How many
such triangles are there? Two triangles differ if they have a
different collection of side lengths, ignoring order. Triangles with
side lengths {2,3,4} and {4,3,5} diffe... |
I have the following Python output class that I'm planning to use across a number of modules in a terminal application:
from colorclass import Color
from colorclass import disable_all_colors, enable_all_colors, is_enabled
from time import gmtime, strftime
class OutputHelper(object):
def __init__(self, color, domai... |
In my architecture I have service layer, and for my question two relevant classes in this layer:
UserManagementService
EmailSenderService
In first service there is method: UnsubscribeUser which unsubscribes the user from a mailing list, and after user is successfully unsubscribed it dispatches event UserUnsubscribedF... |
I have written some code that computes flexural moments imposed by different trucks for a bridge with 300 ft length. Truck data are contained in two lists: ax_list and sp_list, which are the axle weights and axle spacings, respectively.
There is nothing much to the code, however, this needs to be repeated for millions ... |
I want to implement for_each_in_tuples that takes a functor and one or more tuples of the same size and applies this functor to i'th elements of each tuple for i = 0, ..., size - 1.
Example:
#include <iostream>
#include <tuple>
std::tuple t1(1, 2.2, false);
std::tuple t2(3.3, 'a', 888);
std::cout << std::boolalpha;
f... |
I have started to code Snake in C++. I am finding it hard to make progress on this project because the code is quite messy. How can I improve the structure of my program?
main.cpp:
#include <iostream>
#include "Game.h"
#define FRAMERATE 500
int main(void)
{
Game game;
int count = 0;
while (game.program_... |
This app register where you click on the screen, then it writes the inputs on the page. The text is responsive, you can change the dimension or orientation of the webpage and it still will be in the middle with the right size to fill the entire page. With a double click the program will restart.
http://jsfiddle.net/Diq... |
Problem
I'm writing a verilog program that does the trapezoidal integration method (where a review is also welcome, wink wink). But turns out you need input for these kind of things, so in the overly complicated setup I'm doing, I'm writing a python program on a Raspberry Pi to output inputs for the FPGA which then out... |
I need help with optimizing my Python code. I have a bunch of orders and each order has several SKUs. This is what my data looks like:
ORD_KEY ORD_DT_KEY ORD_TM_KEY QTY SKU_KEY
10001 1 0 1 1
10001 1 0 1 2
10001 1 0 1 3
10002 2 ... |
I want to efficiently calculate Spearman correlations between a Numpy array and every Pandas DataFrame row:
import pandas as pd
import numpy as np
from scipy.stats import spearmanr
n_rows = 2500
cols = ['a', 'b', 'c', 'd', 'e', 'f', 'g']
df = pd.DataFrame(np.random.random(size=(n_rows, len(cols))), columns=cols)
v = ... |
In this example I've a refresh method that might be called by multiple threads. Requirements are:
refresh() method must be processed by only one thread at a time (blocking)
If already a thread is waiting, skip any new thread tries to acquire the lock to avoid processing multiple times
The refresh() method not return... |
I'm working on this kata from Codewars. The task is:
Given a certain number, how many multiples of three could you obtain with its digits?
Supose that you have the number 362. The numbers that can be generated from it are:
362 → 3, 6, 2, 36, 63, 62, 26, 32, 23, 236, 263, 326, 362, 623, 632
I've written the following ... |
I'm working on a web form that functions with numeric inputs. I have <input type="number"> input fields and with Chrome and Firefox things work nicely since they only allow numeric data to be filled in.
However, I need to support IE11 and it does not enforce the number type when inputting data (but does when submitting... |
I built a workbook to help me extract data from a MSSQL database into Excel. I realize that this is fairly easy to do with Microsoft SQL Server Management Studio, but I can't easily get that installed on my machine at work, so I first have to remote to the server every time to get any data, which becomes a mission if y... |
I created registration system with PHP. I have User class that will handle all the input and insert the user input into database, and i created Database class with Singleton pattern that will connect to database. After user submited his data, new User object is created.
This is my Database class with singleton patter:... |
I have written this module that takes input of configuration of multiple lines with first item as available storage and remaining are the process at different rate using sys.stdin .
#! /usr/bin/python
""" this script calculates the time remaining for available storage to get filled up.
"""
import sys
def time_to_mel... |
Is there a nicer way to write the maybeWhen portion of displayConnectionAction ? I want to conditionally display an Action depending on whether or not the player is connected.
This bit of code is lifted from a wider system where there are multiple calls like displayConnectionAction (conditional actions built up by a R... |
I was solving this dynamic programming problem, and I was wondering if I can get any code review and feedback. You can find this problem online.
# Coding Problem: Minimum Steps to One
#
# Prompt: Given a positive integer, you can perform any combination of these 3 steps:
# 1.) Subtract 1 from it.
# ... |
I'm writing a function that renders a grid using ASCII line-drawing characters, based on a provided 2D array (or array of arrays), with each top-level array representing a row, and the items inside those arrays as columns.
The function works, but it is absurdly ugly and hard to read. I want to resolve that somehow, but... |
You can find the problem here.
The example:
Column A, B, and C are each 3 and together equal 9:
| A | B | C |...| Total |
+----+-----+----+...+-------+
| 3 | 3 | 3 |...| 9 |
Columns A and B are edited to equal 2 each, but I still want to maintain the total of 9, so I want column C to automatically change t... |
Over the past few weeks, I've been doing the Google Foobar challenges and I've been progressing quite well. I'm currently ⅓ of the way through the third level. However, there were plenty of times over the past few weeks where I felt that my code could have been a lot better. So today I stumbled upon this community and ... |
If you press the damage button, it will damage armor before health. If you press the heal button, it will heal armor before health.
The project is here: https://github.com/austingaee/DamageHealth-Armor
Are there any improvements I can make?
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.