instruction stringlengths 71 71.9k |
|---|
Whilst scanning my C programming textbook, I saw this practice problem from a very early chapter:
I got to thinking that the problem probably wants you to draw each shape separately, which would be very easy.
But to do literally what the question asks (print them on the same line), I couldn't see any easy way! The rec... |
After reading way too much into what fizzbuzz was I though PowerShell could easily have its way with this.
Function Get-FizzBuzz{
param(
[Parameter(Position=0,ValueFromPipeline=$true)]
[int]$Number
)
process{
$result = switch($Number){
{$_ % 3 -eq 0}{"Fizz"}
{... |
I'm just starting to learn C++ (not my first language), and started with working on a program to simulate the classic "Guess My Number" game, and am mostly looking for feedback on optimization and/or general tips. I wanted to write it to allow the player to either guess like normal, but also allow the player to choose ... |
I made this temperature converter when I first started getting into Python. After a year of regular programming on my own I decide it was time to revisit my old program. Now that I finished my first semester of computer science I took my old code and made it more efficient.
New:
# Declares the variables need for the co... |
This script makes it possible for badges to onebox in Chat.
The install requires Tamper/GreaseMonkey. Click here to install,
and it's on GitHub and StackApps!
// ==UserScript==
// @name Badge Oneboxer
// @description Converts tag-like badge comments to badges
// @version 0.24
// @match *://chat.stackexchange.com/room... |
As a solution to the B. Wet Boxes problem :
B. Wet Boxes
Bob works in a warehouse which contains a large pile of boxes. The
position of a box can be described with a pair of integers (x, y).
Each box either stands on the ground (y = 0) or stands on top of two
boxes with positions (x, y - 1) and (x + 1, y - 1) (s... |
Can you help me to review my "mailto:"-parsing function ?
Since I'm trying to write less code, that is as simple as possible.
I'm not sure there if there is some bug or better solution.
var href = 'mailto:hello@world.com?subject=My+Subject&body=My+Body';
function getMailto(s) {
var r = {};
var email = s.match(... |
How can I improve this code? I wanted to know if there's a possibility to remove the for loop, and UPDATE a different uniqueID for each ID in my database.
<?php
$reponse = $bdd->prepare("SELECT MAX(ID) FROM tuto WHERE title=''");
$reponse->execute();
$IDnow = $reponse->fetch(PDO::FETCH_ASSOC);
$IDnow = $IDnow... |
This code pings 1 time every IP while using TTL to identify if it's a Windows PC. If so, it outputs it. It's very slow, so is there any way to make it go faster (1-255 in 12 min)?
@echo off
echo running, it will take a long time to scan
(
FOR /L %%N in (1 1 254) DO (
FOR /f "tokens=1,3 delims=: " %%A IN ('ping ... |
I have written a simple script for managing our Tomcat and Apache instances for deployment. What this script basically does is, when called, it copies the ROOT.war from its pwd and pushes them to two Tomcat instances. Before that, it removes the old ROOT.war file and ROOT folder, restarts them, cleans the log files, re... |
I am writing a portable library function, which is a generic "remove characters" function. Language standards used are C11 and MISRA-C:2012.
TL;DR: it should either remove all occurrences of a specific character in the beginning of a string, or it should remove all occurrences of the specific character no matter where ... |
I made this IRC client ages ago in Python, and thought I'd revisit it for Python 3.5 (I'd like to play with asyncio). Before I start, I'd like to have an overall design review about this.
Known issues, although feel free to comment on them:
I do too much in one class
There is a fair bit of repetition that could proba... |
This is my "naive" implementation of a convex hull algorithm. By naive I mean that I am not using any of the advanced algorithms that exist to solve this problem.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
namespace SO
{
static class Extension... |
This question is kinda similar to mine. However, I am using C++ with Qt instead of C#.
How would I efficiently and easily remove all accents and special characters like !"§$%&/()=? etc. from a QString?
So "áche" should turn into "ache" or "über dir" to "ueber dir" (in german ü,ä,ö can be changed into the normalized ch... |
This is the (hopefully) final version of my script for my file comparison problem mentioned previously in two posts on Stack Overflow (here and here).
I have come up with the code shown below, which does what I need it to do, but I'm wondering if it can be written in a more pythonic (read elegant) way, especially the ... |
I decided to learn generic programming in C (and take a break from templates in C++) by implementing my first simple data structure in C: the singly linked list.
What I'm looking to gain out of reviews is:
Clarity/quality
Algorithmic correctness
Code style for C
Structure and design
Any bugs or issues you can find
I'... |
Lets say I have a string like this:
string s = "A }{ B { C } }{"
//Indexes: 0123456789ABCDE
Just consider the indexes beyond #9 are 10,11,12,13, and 14 respectively.
My code turns s to "A ", because whatever is inside matching curly braces gets removed.
How the matching works:
When you find a closing brace (}), ... |
I would like to receive review on my code. It has only depth first search (DFS) and bidirected graph is the only member of the hierarchy. I added name member for the BiGraph to make it easier to debug in the future, because there might be several BiGraph instances. Also, I would like the review to primarily focus on n... |
I've made a card flip with CSS keyframes but instead of flipping clockwise and then flip counterclockwise to it's original position, I've two separate keyframes that will cause it to rotate in the same direction each time I rotate.
I have jQuery checking if either class exists and adding the first one if neither exists... |
The application's aim is to transfer drawings from the client canvas to the admin canvas using web sockets, as smoothly as possible. At every mousemove event, the client canvas is compressed to .png and sent to the server through a websocket to finally arrive in the admin window where the image is drawn into the admin ... |
Basically I need to order a list, so that an element is not the same as the element that comes after or before it.
For example [1,2,2,3,1,3,3] should come out as [3,1,2,3,1,2,3], [3,2,3,1,2,3,1] or [2,1,3,1,3,2,3] and so on.
I searched for a solution but couldn't find one so I wrote this function myself.
def unorder(al... |
In the past I posted a question that tried to implement a nice API to support RBAC authorization to resources. And due to the epoch and probably to the bount it was moderatly well received by the community. Althought even I myself can now spot how fundamentally flawed was that question due to the following reasons:
Th... |
Problem statement
After 10 sec of execution of a program, start reading the property descriptors of each property of an object and continue reading all remaining properties each, every 3 seconds until done.
Solution
function Timer(obj, startTime, interval) {
var PDO ={
obj:{value: obj, enumerable: true, w... |
I've implemented a Tic Tac Toe game with a public method checkWin() to check if the game has a winner. This is my code.
public class TicTacToe {
int size;
int [][] board;
public TicTacToe(int size){
this.size = size;
board = new int[size][size];
for (int i = 0; i <size ; i++) {
... |
In a toy language I wrote (very LISP-like), the most inelegant part is the parsing.
The language is organized as one class per programming construct, each class with its own parsing method. If the parsing method returns nil (meaning it could not parse that block in the current position of the token stream) the next par... |
I have three checboxes in my form. I have to check which one is checked and start the action. What do you think? Is this the easiest way of doing it?
Checkbox 1 = cat
Checkbox 2 = dog
Checkbox 3 = dog
Only cat -> form action
Cat & any of dogs -> play music
Dog & dog -> play music
Nothing -> ... |
I try keep an eye on any questions or answers that I have posted here within the StackExchange network and I like to prioritize my updates and improvements based on ones that get frequent visits.
I previously used a paper sticky note attached to the side of my monitor with question titles and view counts scribbled on t... |
I want to know what do you think about the structure of this code. If you think that there is some structural improvement to be made, tell me!
Here is a github link: https://github.com/LucianoPolit/LPDropdownMenu
Here is the code:
//
// LPDropdownMenu.swift
// Created by Luciano Polit on 1/8/16.
// Copyright (c) 201... |
I've been working on learning about irregular arrays and thought making a generator such as this one would be a good exercise in applying what I have learned.
The following class generates an array containing \$n\$ arrays which themselves contain arrays of integers of decreasing length, of which the maximum length is \... |
I have a Web API 2 using Dapper.net, and it's accessed by various client with their own database. Currently, I'm using custom header called Client-Id to identify the client.
This Client-Id contains a ConnectionString name and I passed this connection string into my constructor.
Here's my project structure:
Api.Persent... |
I just started programming, and something is telling me that this working function looks to big for what it does. Can you give a better version of the code so I can understand how to code faster, shorter code ?
import os, rarfile
xpath= "/root/tree/def/"
dpath="/root/tree/down"
def unrar():
for rf in os.list... |
I need to divide scoreResult into pages (which is already ordered by score column from highest to lowest), and each page cannot contain too many records (e.g. 12 is a limitation in my example), and each page cannot contain duplicate id1, and each page needs to be ordered by score from highest to lowest.
Here is my work... |
I'm using BFS to see if a given path exists in a graph:
static class Node{
int data;
Node next;
public Node(int data){
this.data = data;
}
}
//Adjency List to store the reference to head of each Node/Vertice
static class AdjList implements Iterable<Integer>{
Node head;
public void add(... |
I would like to know how can improve my solution.
import java.util.*;
public class prog{
public Map<Integer, Integer> findList(int[] array1)
{
Map<Integer, Integer> list= new HashMap<Integer, Integer>();
int start_index= 0;
int end_index = 0;
int length = array1.lengt... |
I wrote this entire program earlier today, and would like to get it reviewed.
It is an arcade style math game, where you are presented with two expressions on the left and right side. You will determine whether or not the first expression is less than, equal to or greater than the second expression.
If you get the ques... |
The gamma function is one of a couple nice continuous extensions to the traditional factorial function. I used this Python program as a reference, which in turn, uses this Ada program. As the Ada program describes:
The implementation uses Taylor series coefficients of $$Γ(x+1)^{-1}, |x| < \infty$$ The coefficients are... |
For loops are the devil. I can't see a way to speed this up with apply or other more speedy functions though...
pred <- read.csv("predictions_from_external_multinomial_model.csv")
pred$id <- test_users$user_id
pred$first <- "a"
pred$second <- "b"
pred$third <- "c"
pred$fourth <- "d"
pred$fifth <- "e"
for(i i... |
I have a simple application reading IO and plotting chart on UI. There is one instance that I need to plot three graphs at a time, and to make this easier, I made a graph form where I declared all non-fixed chart settings during form load and load it to chart as settings when the graph form is called as a new child for... |
My Code uses a data set which has been modified using another script Calculating Time Difference and then inserts and populates a Chart with that Data.
Save a Macro enabled WorkBook as Book1.xlsm with a Sheet named Book1.
To setup data values for testing copy the data below and paste it to cell B19 in your Excel Sheet ... |
I've written a small npm module. It is my first module. I'm asking you to review several things:
The code. I am rather starter, so any wise critic will be super.
Any suggestions or ideas on the library.
About module
Module is made to provide more comfort in using websockets via node.js, to help in organizing websocke... |
I have fetchData method which fills my imagesArray:
func fetchData(){
let imageQuery = PFUser.query()
imageQuery?.whereKey("username", containedIn: namesArray)
imageQuery!.findObjectsInBackgroundWithBlock { (objects: [PFObject]?, error: NSError?) -> Void in
if error == nil {
for obje... |
I've written some code for testing Gilbreath's conjecture in python (2.x). The conjecture was shown (in the 90s) to be true up to n=1012. My code uses the primesieve module to quickly generate primes and, by ignoring blocks of 0s and 2s, only calculates values in the array when necessary. However, it's quite slow; it m... |
I had to write a function to split a string that goes into a field if it(the string) were too long for the field, as it would disappear and be unreadable.
How's the code lookin' ?
function splitText(instr, fieldSize) //instr = string to split into two lines, fieldSize = the width(in characters)of the field where the st... |
This is the iterative depth-first search, that does not abuse the stack. Also, I gathered some information from DFS that may be useful; for example, I am able to do topological sort using the result information of DFS, and use topologically sorted graph node set in order to solve the shortest path problem in directed a... |
I'm practicing a 1000 point algorithm problem on the topcoder.com arena.
The problem is as follows:
You work for an electric company, and the power goes out in a rather large apartment complex with a lot of irate tenants. You isolate the problem to a network of sewers underneath the complex with a step-up transfo... |
I have workbook having multiple sheets and having same data on it. Currently I am using macro that .autofilterand copy paste on respective sheets. I am using looping process like:-
Sub SCRIPT()
Application.ScreenUpdating = False
Sheets("SCRIPT").Range("A3:P100").ClearContents
Dim ws As Worksheet, lrc As ... |
One of the things that's straight-forward in JavaScript is Unicode support. If you want to return ϝ (lowercase digamma, not a simple f), you simply tell it to do so. No look-up, conversion or unreadable Unicode codes required.
I want to build a translator between Arabic and Greek numerals. Since my projects tend to tak... |
I have built a light version of a battleships program and would love for anyone to critique it. The game does not feature OOP, AI nor multiple boards. I aimed more for functionality than correct variable names and other related things just to get it working temporarily so I'm sorry if some things are named badly.
The p... |
In the past few days i have started to learn python 3 in my spare time and i am really enjoying it so far.
I have attempted many simple programs such as a palindrome checker and reverse a string in an attempt to improve my skills.
I was hoping that someone would be able to provide some feedback on the following program... |
I've got a part of my application which deals with tracking the dates a particular item is worked on. It is a single aspnet page, which displays controls to either start or stop tracking, depending on the state of the work item.
There are up to three controls on the page. A calendar to enter the date that work was stop... |
I need improvement on solution to the following problem:
Generating random string keys in SQA is relatively simple, something
like:
request_id = Column(String, default=lambda: uuid.uuid4().hex, primary_key=True)
However, I need to to get request_id have format like
DIVISION_ABC_REQUEST_223 (this is because PK is ... |
In my ongoing quest for an IRC client, I'm working on more stringent validation per RFC 2812. As with everything else I'm doing on this project, I'm trying to implement it all from scratch for the sake of joy/frustration and education. Thus I'm not going to be using any other libraries or tools designed to work with ... |
I hacked together a way to make a small graph using Braille unicode codepoints by abusing unicodedata:
def plot(timeline):
ret = []
for r1, r2 in zip(timeline[::2], timeline[1::2]):
character_name = "BRAILLE PATTERN DOTS-"
dots = [x for x, y in zip("7321", range(r1))]
dots += [x for x, y in zip("8654",... |
I am currently for a program I am writing needing to compare two associative arrays by key and value in PHP and get the common elements as well as the difference between the common elements.
I have currently arrived at the following solution:
<?php
$newArr = [0 => ['id' => 'UT5', 'qty' => '4'], 1 => ['id' => 'WRO', 'qt... |
I completed an exercise from the Cracking the Coding Interview:
Design an algorithm and write code to remove the duplicate characters in a string without using any additional buffer. NOTE: One or two additional variables are fine. An extra copy of the array is not.
Follow-up: Write the test cases for this method.
I w... |
Is this code a good solution for the question, or is there a better way to do it?
package ArraysAndStrings;
import java.util.Arrays;
public class anagram{
private boolean isAnagram = false;
public boolean Anagrams(String str1, String str2){
if(str1.length() != str2.length()){
return isA... |
I'm updating a bunch of PHP code that relies on register_globals and uses request data globally. In the process of fixing/updating I spend a lot of time writing code that looks like:
<?php
$x = isset($_REQUEST['x']) ? $_REQUEST['x'] : $xdefault; // other times loaded from $_GET['x'] or $_POST['x']
$abc = isset($_REQUES... |
This:
Is a data table we get from our financial platform with lots of useful information. For reference, "--" is also the string they use to denote empty values.
This:
Is a spreadsheet I built (and had reviewed here) to track our customers' regular income requirements.
The code produces reports to show:
Whether ... |
I have been using Python for only a few days, so I am trying to learn about some best practices. An explanation of what this code is supposed to do is at the bottom of this post. It is an exercise to rewrite a script I made in VBA a while ago and I am doing it to learn Python.
Basically the strings of seemingly random ... |
I have some parameterized queries in Access 2010.
They are often used in VBA functions having the same parameters.
In such cases, I give the query and function the same name.
The following is such a function (from my actual project):
Public Function get_assignments(e_id As Long, yr As Integer, wk As Integer) As DAO.Rec... |
This question is follow up to Object Oriented Graph Hierarchy with Depth First Search. I tried to fulfill every point which @LokiAstari mentioned. I think I succeeded in everything except Visitor Pattern.
I came to implementation of a function void BiGraph::addAdjacentImpl(int fVertex, int sVertex) in different way. N... |
I am practicing a problem in "Cracking the Coding Interview". The problem is to remove duplicates in a linked list without the use of a buffer. I interpreted this as not using a list or any large data structure such as a hash to store unique nodes.
My algorithm is inefficient I think. It iterates an anchor across the ... |
In order to better understand functional programming in Javascript, I thought I'd try to recreate (as well as extend) some of the higher order functions on the Array object. These methods don't intend to be identical but to have the basic functionality. Any tips/suggestions/feedback would be greatly appreciated!
// Arr... |
I created a program that will convert a 3-character combo into a 3-string combo. I used a lot of if statements to accomplish the conversion. I'm wondering if there is any way to reduce the lines of code and possibly make it more efficient.
using System;
using System.Windows.Forms;
namespace Adow
{
public partial c... |
I'm not even sure if this is how you're supposed to do it, but this is what I have so far:
$.getJSON("/api/get_categories", function(data){
var items = [];
$.each(data["categories"], function(key, value){
items.push('<div class="card"><div class="card waves-effect waves-block waves-light"</div><div class="c... |
I have this list of results which I display with the jQuery Datatables plugin.
This is the Result class and list of results being returned in the JSON format:
public class Result
{
public int articleid { get; set; }
public string Name { get; set; }
public string Position { get; set; ... |
I am reading text files that contain data from observations. The format is not Fixed Width or Delimited, so I built a generator that gets Key, Values pairs and yields a dictionary when it has read a full observation record (~75 pairs in my case). The main loop builds a list from these dictionaries and then loads them i... |
I have the following code I am working on, but I think it can be optimised further probably by improving the min/max variable selection, (see below).
The idea is to not use actual division, ('/'), to get the quotient and remainder.
I think there could be a way to improve performance by further minimising the number of ... |
I am writing an application for work. This application will sit on a closed network but I still have to be concerned about security. There will be a maximum of three types of user for this application: User (read only), admin (data edits only) and super admin (access all areas). But at the moment I am trying to get a f... |
Type erasure is giving me nuts recently. I'm designing a class that performs symbolic differentiation on a math expression represented as a binary expression tree. The question is more on the design part than on the actual code part so I'm only giving out the method that looks awful to me.
public Node derive(final Node... |
I'd appreciate if someone could cast an eye over my dodgey coding and give me some feedback.
The use / purpose of the sheet/script is to quality grade calls, emails and chats with customers. A form is filled out and then the script takes over.
We feed in a persons name, it grabs the last 9 forms for them.
It sorts the... |
I have implemented a "infix-to-postfix" function that takes as input a list representing the parsed expression, resulted from applying a certain regular expression to an expression, and I would like to have your opinion regarding its correctness and efficiency. Good suggestions are of course more than well-accepted!
F... |
I would like to improve my code. I am not a Python expert, so I am glad for any help. I would like to remove redundancies, unnecessary code, and change things that might shorten it.
#!/usr/bin/env python3
import skilstak.colors as c
import random as r
def computerPlay():
while cscore < 17:
chand.append(deck... |
(See the next iteration.)
There was a question in Quora about an interview question that asks to write a function for computing integer square roots, so I rolled two of them for fun:
Main.java:
import java.util.Random;
import java.util.function.Function;
public class Main {
public static long intSqrt1(long number... |
In order to convert a code such as:
Company company = new Company();
if(currentToken.equals("employee_list")) {
company.setEmployees((ArrayList<Employee> parseEmployees(reader));
}
else if(currentToken.equals("contractor_list")) {
company.setContractors((ArrayList<Contractor> parseContractors(reader... |
I have been using this site for a couple of years for great answers and a ton of help. I wrote this program for my class project due 1/23. I am just wondering what you would recommend me changing or improving. I think I have some repetitive code, but I have not learned about defs in Java yet.
package project2;
import... |
Can someone give me advice on cleaning this code? It's more messy then I expected. I got like 10-15 more ifs to be added.
I've thought of adding the error messsages in methods and then just check if method returns true, or false it'd throw error..
if( isset($_SESSION["access_token"], $_SESSION["user_email"], $_SESS... |
I wrote a chess game in Ruby using object-oriented principles.
One of the challenges was deciding which particular methods/actions belonged to a particular class, as there were some that felt as if they could go in any class.
General rationale for OOP choices:
Pieces should be as dumb as possible. They should return... |
I have this code that is working as intended. Since I am still learning VBA and coding, I was wondering if anyone could look at this at let me know if there is another way to write this. This is part of an Add-In I created and is used by several other people (meaning that I installed the Add-In onto their PCs).
Sub Ex(... |
I was reviewing the following code block and noticed there was validation check at the top. The 3rd line in the function checks if the invoice belongs to the logged in customer.
I am wondering what the correct way of doing this might be. Some options that come to me head are:
GetInvoice should take an overload and... |
I'm new to programming and just made a basic calculator on my own.
Can anyone see if there is any room for improvement in the code, like stuff i should do different.
package calculator;
import java.util.Scanner;
public class Main {
static Scanner userInput = new Scanner(System.in);
public static void main(String[... |
I did an exercise (open-ended - without an answer) from a JavaScript book (chapter about functions).
Given array of passengers of a flight with their names and ticket types and one need to emulate stewardesses asking passengers for service during the flight depending on their ticket type (first class or coach) (stewa... |
Here's what my task is:
Dependant on the "Logged In" user, they'll have different access rights and will see different menus.
I have tried using the .get() function.
choices = {1: "| Student Details", 2: "| Student Grades", 3: "| Finance", 4:"| Staff Details", 5:"| Staff Payments"}
print(choices.get(1))
print(choice... |
I have solved problem 185 on CodeEval, Glue Shredded Pieces.
The solution got a 100% score on all tests (edit: see comments), within the allotted time and memory constraints. I'm looking mostly looking for tips to reduce memory usage (and improving speed) but all comments are welcome.
Description
Imagine that you are ... |
Golly is a cross-platform, Python and Perl extendable (like in this case, Python), free Conway's Game of Life simulator written in C++ (or Python) that runs in arbitrary speed and large, marvelous patterns.
Herschel is a pattern named after William Herschel (the heptomino resembles Saturn's planetary symbol ♄, and some... |
Write a method named hasMidpoint that accepts three integers as parameters and returns true if one of the integers is the midpoint between the other two integers; that is, if one integer is exactly halfway between them. Your method should return false if no such midpoint relationship exists.
Here are two different ve... |
The following code fragment constructs different types of neural networks outputs based on the options supplied. Currently, my code just has a huge note that describes what all the options are supposed to do. I wanted to learn how I can make this code less complex or perhaps break its complexity into simpler pieces. An... |
I'm very new to Haskell, I've read most of learnyouahaskell.com and played around with some simple things, but this is probably the most 'complicated' bit of Haskell I've written so far. I have an implementation in PHP that does basically the same thing, but it is much much faster.. I'm guessing my bottleneck here is t... |
In my sample data table below, all datatypes are varchar(255).
| event | timestamp | traceid |
| accepted | 2016-01-16T09:35:48.653418931Z | AIP1452936948-44467 |
| published_event | 2016-01-16T09:35:48.659767348Z | AIP1452936948-44467 |
Here is the expected output:
... |
Very often on Stack Overflow, and even on Code Review, I've seen questions and answers that have code that begins by persisting Excel properties like DisplayAlerts and ScreenUpdating to public or private variables, and the restores them at the end of the procedure.
Public bScreenUpdating As Boolean
Public bEnableEvents... |
(See the previous iteration.)
My two previous methods for computing the integer square root of a number \$N\$ ran in the \$\mathcal{O}(\sqrt{N})\$ worst case time. Now I have added a method (intSqrt3) that runs in \$\mathcal{O}(\log \sqrt{N})\$ time:
Main.java:
import java.util.Random;
import java.util.function.Functio... |
I'm using Ed scripts to track changes in a web app I'm developing. Ed scripts are probably the easiest kind of patch file for a computer to parse: detailed explanation of Ed scripts.
I quickly put together the Ruby code below with extremely little thought. I'd like to know what kind of high-level patterns I could use f... |
Here is a small project to implement a basic shell. It is a personal ongoing project to keep system call usage fresh. It currently does background processes and some basic signal handling.
I am actually looking for code feedback in regards to professionalism. I want to know if my code is clear and easy to understand. I... |
I need to examine an application port to see if it opens and I need to put the retry count as a parameter. Since I'm new to Node I wanted to get your feedback on it
for improvements.
checkAppPr: function (port) {
var result = Promise.defer();
var checkStatus = function (next, result, times) {
... |
I am writing some C# that will be running on Linux and will extract values from a kernel generated system file that represents readings from a sensor.
The file contains two lines of text, and I have a method which will extract two values from the file.
The file looks like this:
$ cat /sys/bus/w1/devices/28-00000*/w1_sl... |
I am doing a function that pixelates black and white images. The function must be called pixelate(img, (pixel_width, pixel_height), mode).
The parameter (pixel_width, pixel_height) is a tuple which indicates the size of the resulting pixel values. the function must return a result in any event, even if they are higher ... |
I just finished making a Blackjack program, and I hate my global variables in the program. Is there any way to change the code to not use globals and still work?
#!/usr/bin/env python3
import skilstak.colors as c
import random
import time
def bet():
global tokens
bet.cBet = input("How many tokens would you like... |
Given a 2D array of digits, try to find the location of a given 2D
pattern of digits.
Input Format
The first line contains an integer, T, which is the number of test
cases.
T test cases follow, each having a structure as described below:
The first line contains two space-separated integers, R and C,
indicating... |
I have been using ROS alongside Python to enable my built robot to walk. I am aware that my code needs some improvement such as classes etc. This is my first Python / ROS program so any help and pointers would be hugely appreciated.
#!/usr/bin/env python
#
## launch start_robot_controller.launch before running this.
... |
I need to process the data contained in a (relatively) large binary file.
The file has the following structure:
40 bytes of initialization,
4 bytes, 1 byte,
4 bytes, 1 byte,
...
lots of such 5-byte blocks
...
The number of 5-byte blocks (to which I'll refer to as 'timetags' in the following) may vary, but the total si... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.