instruction stringlengths 71 95.1k |
|---|
I often come around a requirement where we have to perform a repetitive task on the user's screen (for eg, updating a counter like flash sale/ live class timer, autoscrolling the banner, etc) .
I have written this small file which performs a basic task of pressing a button every 2 seconds for a total of 4 times as a ge... |
My code is working fine...
but I want to remove below those(1) lines of code from my example code(2) (JS Code). If I remove those code then a tag is not working. (a tag do not open link or href is not working).
Is it a good approach to done it by writing those code? ( if any problem will occur for ajax request for this... |
I have a text adventure game and I need to use OOP so I've chosen to use it when getting the player's name and age. I need to keep the OOP; but was wondering if there are any ways to clean up the code or simplify it while still getting the overall output.
class Player:
def __init__(self):
self.get_name()
... |
For example, given [10, 15, 3, 7] and a number k of 17, return True since 10 + 7 is 17.
How can I improve the below solution?
from itertools import combinations
def add_up_to(numbers, k):
c_k_2 = list(combinations(numbers, 2))
return any([True for pair in c_k_2 if sum(pair) == k])
|
This is a follow up to my previous post.
I've used a BCrypt library to create a key from the passed in password. I then separated out the salt from the hash. The encryption is done using the salt concatenated to the hash, but only the hash is returned to the user. The salt is prepended to the encrypted data.
The key... |
I was seeing alot of machine learning applications calculate fitness via 1.0 / x. Division in computers is slow so I came up with a version that is about ~36% fast on my architecture (-march=x86-64).
#include <cmath> //std::exp2, std::log
#include <numbers> //std::numbers::log2e
#include <stdlib.h> //rand, srand
#i... |
Edit:
By adding the restrict keyword I was able to get my memcpy up to speed with the library implementation (and in this particular test, exceeding the library implementations speed). New results:
Test case
mem_cpy
mem_cpy_naive
memcpy
big string (1000 bytes)
2.584988s
3.936075s
3.952187s
small string (8 byt... |
I am attempting to implement a GetNeighborhood function in order to get a specific region from inputCells by sizeInput and centralLocation parameters in 3D cells structure.
The experimental implementation
The experimental implementation of GetNeighborhood function is as below.
function [output] = GetNeighborhood(inputC... |
I usually like to use entr when developing on my own hardware to run commands when a directory changes.
However, sometimes I'm working in an environment where I don't have much control over the availability of helpful programs so many of us take for granted.
I've been using Git Bash on Windows, and I've been getting ti... |
So I got this short awk invocation wrapped in a bash script. unfortunately the bash script is kinda unreadable. Do you have any pointers?
#!/bin/bash
action="printf \"$1 \" \$1 \" \""
awk {"$action"} $2
Invoking it like this joinargs -s tmp if the tmp file looks like:
a
bb
ccc
would create this output -s a -s bb -s c... |
Here is a code for BST that I have written , that does not use pass by reference. Help me to find flaws in its design. Also I do not like the function getReqNodes, can it be made more elegant.
#include <iostream>
using namespace std;
struct node {
int data;
node* left = nullptr;
node* right = nullptr;
... |
I have written a simple program to represent the computer is doing an operation. It is suppose to show a rotating slash character to the user with every second passed however the program does not work as intended. It shows all the characters instead of cleaning the screen and show just the spinning slash character.
#in... |
I am creating a metaclass which ensures that instances of an actual class A are kind of singletons. But rather than having only single instance of A, I would like to have one instance per argument set given to A.
That is
class A(metaclass=ArgumentSingleton):
pass
r = A()
s = A()
t = A(1)
u = A(1)
v = A('hi')
prin... |
I'm trying to develop a text-based game. Here is the concept-demo version.
class Arena {
public static void battle(Hero h1, Hero h2){
h1.setHp(h1.getHp()-h2.getPhysical_attack());
h1.info();
}
public static void main(String[] args) {
System.out.println("Entering Arena ...");
... |
A couple of weeks ago I had to do a coding challenge for a job interview. I did the challenge using Python, the code was working and I got the job. But I would like to know how (if possible) I can improve/refactor the code I've written.
The reviewer told my future employer there were too many if statements and that I c... |
I wrote the following Chess logic in Kotlin and am looking for feedback to make the code cleaner and follow good software design principles. I tried to adhere to object-oriented design.
Some notes:
• I ignored special moves like "Castling" and "en pessant" for simplicity.
• I put the last when branch into a separate wh... |
I'm a beginner to intermediate in programming, and created a Tic-tac-toe game in python. I plan to add an AI player and a GUI using pygame.
Any improvements I could make to the code, especially with the logic, or just formatting in general?
my_board = [
["1", "2", "X"],
["4", "5", "6"],
["7", "8", "9"]
]
... |
I've been working on this for a while, and now that I've got a working program I thought I'd see what other people think about it.
Basically if there is anything you think would make it faster or make it simpler, or make it better in general, please share your thoughts. As for actual strength, I have no idea how to tes... |
I am trying to write a python script that can search through Fortran code
ignoring comments. I didn't find a simple way of doing this using grep. So I startwed writing my own.
The rules for comments that I am following are:
the first character is not a space or a number. It is usually a c, C but I've seen * and other ... |
I wrote this code that's supposed to implement a 1-dimensional (!) EM algorithm with k-means initialization:
begin
import Pkg
Pkg.activate(temp=true)
Pkg.add(["StaticArrays"; "Plots"; "BenchmarkTools"])
end
using Printf
using LinearAlgebra: norm
using Statistics: quantile
using StaticArrays
"Density of st... |
Background: I had created a macro few years ago and when I was reviewing this now, it was hard to understand.
I recently went through all the articles from RubberduckVBA and started learning that VBA can also be Object Oriented language and, I tried implementing this concept in my macro.
Purpose of Macro: we have new f... |
I made this super basic autoclicker using Python (v3.7) and the pynput (v1.7.3) library.
Are there any changes that you could recommend to make the code more efficient, faster, and overall better?
Here's the code:
from pynput.keyboard import Controller
import time
# Autoclicker Functionality
def AutoClick(inputClickK... |
I often see nested loops as a solution to the bubble sort, but my solution involves a recursive function. Is the following solution less efficient than the traditional method?
public static int[] BubbleSort(int[] arrayOfValues)
{
var swapOccurred = false;
for (var i = 0; i < arrayOfValues.Length; i++)
... |
I have been trying to learn c++ for the sake of being comfortable with a second language. I found a project that seemed relatively easy, although it may not be implemented perfectly, it was a simple project.
I create a std::map<double, std::string>, which will represent the tax rate as a double, and the required income... |
I've started to get far more familiar with C (and coding in general) and the way to use function to my advantage to create more complex programs. As a way of doing something actually useful instead of my "Starting Programming with C: For Dummies" book I decided to make a simple program to help me cheat my way through m... |
How does the following look to list the directories on a posix system? This is actually the first piece of C code that I've written where I've actually been able to use for a real-world problem!
#define _GNU_SOURCE
#include <dirent.h>
#include <string.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#includ... |
I am a total beginner in Python and I am trying with the modules Turtle. I am currently trying to code for 3 sliders (R, G, B) for adjusting the colors of the turtle screen. However, I found parts of my codes filled with redundancies, could anyone please tell me how to trim the code to make it more compact and clear, e... |
I am writing a benchmarking tool from scratch in Python.
However I can't get the performance of other benchmarking tools like wrk or wrk2. Using wr2 I can make 42k requests/s while my code can only create up to 2200 reqs/s. I have tried multiple ways to parallelize the code execution. I have tried using multiprocessing... |
I am trying to find a N number of leading zeros from the output of the sha1 hash function. I would like N to go up to 10 or 9. Currently I can get to 7 in about 7 minutes (even though is not always that fast), but already 8 takes forever. The input to the sha1 must be a combination between an input_str and a random gen... |
This is an updated version of my first question:
Chess game in Kotlin
I wrote the following Chess logic in Kotlin and am looking for feedback to make the code cleaner and follow good software design principles. I tried to adhere to object-oriented design.
Some notes and questions I still have:
• I ignored special moves... |
I have the following bit of code in a service worker that checks to see it the url contains any of the values in an array and if so it breaks out of the function. As it is run for every asset on a webpage, it can be run a lot of times so I was wondering if it could be optimised in any way:
const urlsToIgnore = [
'... |
To improve my Python knowledge I started a small coding project: A telegram chat/quiz bot that is based on official questions about basketball rules. The bot reads them from one or multiple .csv files.
The bot has two modes:
Exercise mode: Questions are asked until the user selects to see the results. After each answe... |
I am making a simple file explorer with tkinter Python.
This is the file repository on github.
I know that this is pretty much long code and it took that much time to write but i have somehow added the comments.
And I want someone to test my code.
Also the additional mechanisms are not here and this is only for show pu... |
I am developing a system for runtime macro executions in an automatic test environment. Macros are defined in an xml and are for configuring multiple devices/DUTs for a specific use case.
The xml parsing of these macros is outside of the scope of this question.
For building the macros in code I created the code shown b... |
After I have been doing some improvements from my Previous code review. I have taken the knowledge to upgrade and be a better coder but now im here again asking for Code review where I think it could be better.
The purpose of this code is a monitoring that checks for a special site every random 30 to 120 seconds. If th... |
Currently working on a pre-solve collision library. My goal is to have it be potentially usable in potential video game projects of mine, so time constraint is small as this should be used in a game loop: this algorithm currently takes too long. I am aware of broadphasing, but I believe there is gains to be made here ... |
The purpose of this code is to use it to calculate some number theoretic function efficiently for the numbers from 1 to 1000000, but I am not sure if it will be really useful. The main purpose was to program a piece of C++ code because I have almost no experience in this language. So it would be nice if you could give... |
I have this code:
Sorted=False
while not Sorted:
Sorted=True
for x,y in enumerate(List[:-1]):
if List[x]>List[x+1]:
List[x],List[x+1]=List[x+1],List[x]
Sorted=False
However the use of
Sorted=True/False
being repeated is quite ugly and it would be much nicer to write the code is... |
Been looking into some simple algorithms, I came up with the following piece of code in C to implement the Euclidean algorithm iteratively (I like to be clear here, I don't want the recursive implementation for now).
I've seen various other implementations and in fact most books prefer a different pseudo code.
I'm wond... |
I implemented a key:value format file parser in C, or something that comes close to it as there is no such thing as dynamically creating structs in C.
Assumptions: we are creating a C program that needs some config options (e.g. the number K of threads in a concurrent server that handles requests using a pool of K work... |
I am running a PowerShell script that shows disk usage for drives into HTML reports. While this works quite well it has a problem on some file servers with a massive amount of files. It can sometimes take up to 1 day in a worst case scenario which obviously isn't ideal. I'm wondering if there if there any way to optimi... |
I have a set of Italian words in a txt file hosted on GitHub.
I use it as stopwords vocabulary for further NLP tasks.
When I dump from GitHub it returns me, obviously, also \n
Better or more efficient way to replace the special character compared with my working code?
import urllib.request
stopwords_link = "https://ra... |
I'm making a top-down dungeon minigame where you are a knight and can attack zombies by swinging a sword.
So far I haven't implemented collision, player rect(), enemy rect(), a game over screen, or the player sword animation, but all the code I have so far is working well, even though the main loop is crowded.
I was wo... |
I have an event handler function which every time is triggered should clear a setTimeout() and set a new timeout.
Now the callback for the timeout has to take few arguments, for example the event object received by the handler.
And that's it. I did it, but I believe that my solution is not optimal, nor the cleanest:
l... |
My objective with this code was to create a class and call it from other .py files. The code itself is working, but I would like to know what could be improved or be better implemented.
I wrote another program just to call this class and its methods and it worked. I'm using functions that will only work on Windows beca... |
Question:
Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0.
Notice that the solution set must not contain duplicate triplets.
Here's my pythonic approach to leetcode 3Sum, it passes and actually beats 93% in tim... |
This is my current code to check list of urls for response code within same domain.
I would like to know if there's a way where i can improve my code performance more better.
import argparse
import logging
import os
import smtplib
import time
import httpx
import trio
from email.mime.multipart import MIMEMultipart
from... |
I am trying to calculate some values using numpy. Here is my code,
x= np.zeros([nums])
for i in range (nums):
x[i] = np.mean((Zs[i :] - Zs[:len(Zs)-i]) ** 2)
The code runs perfectly and give desired result. But it takes very long time for a large number nums value. Because the Zs and numsvalue having same len... |
I have a single producer and single consumer, and the producer never stops, but the consumer might not keep up. There's no need to consume every item, as long as we always access the most-recently produced item, and never process an item twice. In other words, we should drop items if the consumer isn't keeping up, bu... |
I am working on the subject of the French championship 2019, composed of 20 teams, and each team plays 38 times, if team A plays with team B, whatever the result, each team plays another time with another team determined by the draw.
If team A plays with team B, that means there are three possibilities 1/3 team A wins.... |
This is my first month learning HTML and CSS, I have built a working download page for one of my Java projects and I wanted to see if there is anything to improve on my website.
The website works as I expect, but I'm unsure if I'm doing anything wrong.
Here is my code snippet, any feedback is appreciated!
* {
margi... |
I am working on building a management interface for an ESL (English as a Second Language) institute, basically it is a language school where people learn English.
I have prepared my models for each app and I really would like someone to review them and provide me with suggestions and possible mistakes in the design.
t... |
Motivation
I and the company is working on building C++ SDK automatically for several platforms, including Windows.
In summary, I have to test somehow if the private member of function pointers' type is correct, since LoadLibrary in Windows API only uses function names, ignoring its type.
There is some real-world restr... |
I've always struggled to create and sustainable, organizated, clean code.
I tried to use a Factory method and it's working better now that I created another class.
I know I should write documentation, but that's not the advice I'm looking for yet. Because I don't think documentation will help with organizating my code... |
Given a two-card poker hand and a board of 5 cards, I want to evaluate the player's hand strength as listed here.
The evaluation of a poker hand was measured to be ~100 microseconds on average. Existing free equity calculators are able to perform this calculation in under 1 microsecond (for example, Equilab). I would l... |
I have written a class library for creating timer-based bacground operations in .NET projects. The idea is to be able to create and manage (start/stop/resume/cancel) recurring background operations and also to be able to poll and/or react to changes in the background operation's state.
The library consists mainly of tw... |
I'm preparing for coding interviews and I wanted to get feedback on this question which asks you to write a simple ratelimiter that can handle 5 requests every 2 seconds for example. Since it is for a coding interview setting, I don't think it needs to be perfect.
I looked at the guava Ratelimiter for inspiration for t... |
I wrote a simple softmax classifier to classify MNIST digit handwriting data set. Feel free to comment anything!
#include <algorithm>
#include <bit>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdint>
#include <execution>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <iterat... |
I have made an Android Tic-Tac-Toe adaptation as a weekend-project.
Here's the Kotlin-code.
MainActivity:
package com.mizech.tictactoe
import android.content.DialogInterface
import android.content.Intent
import android.graphics.Color
import android.os.Bundle
import android.view.View
import android.widget.ImageView
... |
As per the title, I'm making a webapp that is intended to use as a JS exercise platform. Problems are shown to users, they submit code, that code is run against a few test cases, and a report of the outcome is given back to the user.
I'm using Django for my backend, but to run the code I have also set up a node script,... |
I am a beginner, and I'm trying to secure a sign-login system on my website. Is my code good/enough to prevent SQL injection?
THIS IS THE SIGN FILES
This is the index.php that takes user input:
<?php
require('some_path\autoload_class.php');
$pass = $_POST['passwordd'];
$card = $_POST['cardd'];
$hashed_pass = passwor... |
I have wrote a MutableLiveList class for android, similar to existing MutableLiveData, but this class instead handles a list and notifies its observers on structural changes like adding items and removing items. It is intended to be used inside viewModels similar to MutableLiveData. Class implementation is like this:
c... |
I have a object list like below. I want to join every two rows into single row based on column B. It is sure that only two rows would be there for every single column B value.
Input
Output
However, my solution works. but I am looking for more better solution. I am not much happy with my solution.
My solution:
var gro... |
I wrote a working program in C that takes an array with size 2ⁿ, and separates all the even numbers from the odd numbers.
For example: Input: {1,2,3,4,5,6,7,8}, Output: {8,2,6,4,5,3,7,1}
I want my program to be as efficient as possible and to have space complexity O(log n) and time complexity of O(n log n).
This is the... |
I made a function that directly calculates the discrete Fourier transform in dimension two, as well as functions that automatically initialize a 2D array to either something random, or specific basis elements (when viewing multidimensional arrays as tensors, but that's not important). Also an approximate equality check... |
I've been assigned the following Python homework:
Implement myrange that acts like range using iterators. Define a function myrangeand define a class MyRange.
We've just seen iterators, so I think I'm asked to use them. I am not required to write a sophisticated code, but only something that allows the range-for loo... |
This is a follow-up question for GetNeighborhood function for 3D cells structure in MATLAB. Based on the existing 2D non-local algorithm, I am attempting to implement 3D non-local mean algorithm in MATLAB and GetNeighborhood function is used here for extracting sub-region of 3D cells.
The experimental implementation
Th... |
I would like to have a minimal storable class in Python that I can use as ORM. I quite thinking my approach is bad, but I would like to have your opinion.
I do not want to use SQLAlchemy or PeeWee as it is too complex for my application.
I wrote a Model class from which I can derivate storable items:
from tinydb import... |
This small programme is an exercise that my teacher gave us.
n is an alphabetic input that its length must be between 5 and 10. You have to insert the characters of the input one by one to a list called T. Then, add the reverse case of letters to another list called V. So if there is a capital letter in T it would be l... |
As a purely pedagogical exercise, I've been trying to use Rust's (very expressive) type system to define the bare minimum one might expect from an ordinary list type.
While there's likely a higher-level argument here about mutable vs immutable lists, and how lists should be implemented in Rust, please note that this is... |
Create a class template named ValueStore that has a member variable,
to store a value and a member variable, hasValue that holds a true
value if there is data in the value member variable and false
otherwise. Use the class to store three values of different types.
#include <iostream>
using namespace std;
template <t... |
I have extensively consulted Raku documentation and have tried many combinations to finally arrive at this working solution.
#!/usr/bin/perl6
use v6;
my $a;
my $b = 34;
my $c;
$a = prompt "enter number: ";
$c = ($a * $b);
say "$a multiplied by $b is $c";
|
I have written a merge sort in C and would like any advice on how to improve it. Any advice helps to make the code better!
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
static void mergesort_helper(void *array, uint32_t index, uint32_t length, size_t size_element, int32_t compare(void ... |
I am trying to filter the events table to get ongoing events and complete events, but pycharm keeps underlining my code because of duplicated code. How do I prevent for loop code duplicates on the two functions below?
Better yet, how do I optimally refactor these two functions?
Thanks
def get_ongoing_events():
ong... |
I have the problem, my methods become slower and slower after many data. My methods can generate 100 rows with 20 columns around 1-3s, but after that my methods become slower and slower.
And for another information, i'm still using NPOI ver 2.4.1 in ASP.NET Web Form (Target framework 4.6.1)
Here's my code:
this is the ... |
Any suggestions on improving the speed of below code. My dictionary is rather large in fold of * 100000 and expected to grow larger every day.
I am open to completely new ideas or approaches to do the below operation.
from pyxdameraulevenshtein import damerau_levenshtein_distance, normalized_damerau_levenshtein_distanc... |
I wrote a C++ program that merges two convex hulls in linear time.
The algorithm is based on http://cgm.cs.mcgill.ca/~godfried/teaching/cg-projects/97/Plante/CompGeomProject-EPlante/algorithm.html
Feel free to comment anything!
Point.h
#include <cassert>
#include <cmath>
#include <iostream>
constexpr double tolerance ... |
My primary coding language is C++, but I occasionally use C. I wrote some simple image segmentation using Union-Find algorithm. Feel free to comment anything!
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#include <string.h>
static size_t const MERGE_CRITERION = 50;
... |
I have a database, with tens of thousands of records, which I wish to represent in python. The python 2.x version has tables in which each record is an instance of a class and the values in the record are held in attributes of the object. Some of the attributes are terms which are used to classify records. The classifi... |
I have made the decision to move the storing of session data to the database.
Any new ideas, suggestions are welcome.
Please also give security suggestions.
Like SQL injection is possible here, etc...
<?php
/**
* MySQL/MariaDB Session Handler - Handle Sessions using Database
* Copyright (c) 2021 Baal Krshna
* PHP V... |
If you already know the start and ending character positions of text you want to replace, this bypasses the need to calculate the length. It just helps eliminate a step by not requiring you to calculate the length because this uses start_num and end_num directly as parameters. It can be used as an Excel function or a V... |
I have been working on where I create a payload of dicts with different values as store, name etc etc which you will see very soon. The idea is that with the payload I send to this script, it should see if the values is in the payload (dict) and if it is then add it into discord embed. As simple as it sounds.
I have do... |
I have implemented Battleship in Python by using lists. I have used threading to prevent KeyboardInterrupt, so the player can't cheat by using control-c and stuff.
How can I simplify this code?
import random
import sys
from threading import Thread
import keyring
master_break = keyring.get_password('ship', 'break')
ena... |
I want to implement a function take_upto_n(A, n)
such that for e.g.
take_upto_n([1,2,3,4], 8) returns [1,2,3,2]
take_upto_n([1,2,4,3], 8) returns [1,2,4,1]
take_upto_n([1,2,3,4], 100) returns [1,2,3,4]
take_upto_n([1,2,3,4], 3) returns [1,2,0,0]
Assume A contains non-negative values only. n is also non-negative
This i... |
Would someone review this code, and confirm that it is indeed recursive? I'm learning computer science and going through different types of algorithms. Right now, I'm focusing on recursion want to ensure that this 'recursive palindrome' method is truly recursive. I've passed six different strings as a test, three that ... |
For a small project of mine, I will be needing to work a lot with braille translation. To do that, I have already finished a small program that I can use to translate braille into English letters. To make the whole thing a little more modular, I exported all my braille logic into a small module:
from typing import NoRe... |
I’m currently building myself a website using GitHub pages.
I wanted to have a theme system, and recently rebuilt my implementation.
It now manages a <style> tag with ID theme in the <head> tag.
I rebuilt it to add support for custom themes, but the in-site UI doesn’t support it yet.
The code maintains two stores of th... |
I've been practising trying to write my code neater, so decided to build a practice GUI, the code works, However, how could I tidy this up in terms of separating out the different parts of the GUI, such as a separate defs for labels, Combobox etc? or using a function for the 'with open' section.
from tkinter import*
fr... |
Introduction:
So far, the game works well, and my only major concerns, are a bullet system (including a function where you click the mouse to shoot the bullets), and a collision system between the zombies and bullets, as I've tried many different ways to go about those two issues, with no luck. Anyways, if someone were... |
I have a start and end date. I would like to return a list of tuples, which have the start and end dates of each month.
Input
start_date = '2020-10-14'
end_date = '2021-03-26'
Output
[('2020-10-14', '2020-10-31'),
('2020-11-01', '2020-11-30'),
('2020-12-01', '2020-12-31'),
('2021-01-01', '2021-01-31'),
('2021-02-0... |
I am checking three elements on the DOM to see if they are empty or not so that I can run only the Ajax calls that I should run and save on overall bandwidth. The code works but it "smells bad". Here is my source.
const processValues = (area, city, text) => {
if (area.val() && city.val() && text.val()) {
re... |
I live in the buildings that have 50 people in it and for each floor splits into 2 groups each group is from ~9 people. I'm trying to build an Xamarin app (IOS, ANDROID ,Win10,maybe web app) to make it easier to us to communicate.
Explaining the way i did my DB as it is:
The shopping table{ if someone by something the ... |
I am using PySpark in Azure DataBricks to try to create a SCD Type 1.
I would like to know if this is an efficient way of doing this?
Here is my SQL table:
CREATE TABLE dbo.Countries (
CountryId bigint IDENTITY,
ShortName nvarchar(max) NULL,
FullName nvarchar(max) NULL,
CapitalCities nvarchar(max) NOT NULL,
I... |
This is a follow-up question to this one.
I have tried to implement all the recommended things in the answers (except commenting, and not being OS specific). Again, if you see anything that needs improvement, or would make it faster, please tell me!
Here's the code. Only 222 lines this time :).
#!/usr/bin/env python
#... |
I made Tic Tac Toe in Python. Standard code review, please tell me ways to improve. I am very new to Python, so please do not criticize very roundabout ways. Thanks.
board = []
for x in range(3):
board.append([' '] * 3)
def print_board(board):
x = 1
print(' A B C')
print()
dashes = 0
for ... |
I previously implemented a Merge Sort for arrays, so after fixing up my code for the array-based merge sort I have now implemented a merge sort for a basic singly-linked list data structure which only contains the pointer to the data and a pointer to the next "Node". I have tried to use the advice given on the previous... |
This code should query the github api and filter, out of the last 1000 commits, which ones include and exclude certain words from the top 3 repositories in a given organization.
For example, I could query the endpoint /search with parameters such as org:facebook and include:fixed exclude:try. This should then return, o... |
As a way to learn PySimpleGUI, and eventually tkinter, I re-implemented a computing cluster CPU load monitor I wrote long ago. I'm looking for any feedback on whether it's well-written, but in particular I have concerns about two areas:
One, whether the organizational structure is correct. As objects, Cluster contains ... |
I created a quick function to convert n bytes into binary for my student.
She is not on that level yet, but I think it would be best for her if my demonstrative functions aren't trash.
void binary (void* p, size_t nBytes)
{
int iBit = 0;
int iByte = 0;
putchar('[');
for(iByte = 0; iByte < nBytes;... |
I'm a beginner trying to get a better understanding of golang so I decided to write an atom feeder that runs from the terminal.
I am using the gofeed library to parse the atom feeds and the tview library to make the terminal ui.
I would like to get some advice on better ways to separate my code from these libraries so ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.