instruction stringlengths 71 95.1k |
|---|
int* binary (int nBits, int number)
{
int* bits = calloc(abs(number)+1, sizeof(int));
int i = 0;
int l = nBits - 1;
while(number > 0)
{
while(l >= 0)
{
int ln = 1 << l;
if(ln < number)
{
bits[i] = ln;
... |
Well, I am recently learning data structures and algorithms and I came across the Binary search tree and decided to first time use my own logic to make the delete function. I have not come across a code similar to mine in the delete function, although it is possible someone already used this logic, please share if you ... |
There are no syntax errors in this code, and so improvements could be in the areas of performance, maintainability, and usability.
class Program
{
static void Main(string[] args)
{
int shift = 5;
string output = "";
Console.Write("Input: ");
string in... |
I saw that strftime is deprecated in PHP 8.1.
I saw I can use a class include in intl but I'm not sure to understand how to use It.
On my site I use this function with the array $datesToConvert{020222, 030222, ...} which means "02 Février 2022"
function compareDate($date1, $date2){
return strtotime($date2) - st... |
I have written a program in C that calculates local g, by using height from the sea level and latitude.
NOTE: I have to add an image of the equation because that website is no longer active.
Here's my code:
#include <stdio.h>
#include <math.h>
double local_g(double latitide, double height_sea_lvl);
double local_g(doub... |
I'm working on an astrology project, and I have a component for each sign:
function Sign({ name, image }) {
return (
<div class="tile is-parent">
<article class="tile is-child box">
<div class="card-image">
<img src={image} alt="Image"></img>
</div>
<p class="title">{name}</... |
I wrote a function in Typescript which takes required parameters, optional parameters and parameters with default value. I want to use this function for error handling of http requests. I am not sure, if my solution is good, so I wanted to know the opinion of the Code Review community.
Here is my function:
public han... |
I previously asked for a review for a Vending Machine implementing State Pattern in this linked post.
And received an answer from @radarbob. The code below is my revised attempt based on some of @radarbob's answer.
Notes / Changes from my original attempt:
VendingMachine internals no longer public
protected properties... |
My implementation is based on the incremental prime sieve described on Wikipedia. I'm relatively new to lisp so I would appreciate any comments on my coding style or on the algorithm.
The below code implements a min-heap and uses it in the prime number generation algorithm:
(defstruct heap
; (cmp x y) should return t... |
I'm a self-taught programmer and I haven't really followed industry-standard coding classes. I'm currently coding my own game engine for android, though and I was wondering if my coding style could run me into big troubles. Here's my newly written custom button class:
package com.glu.engine.GUI;
import android.opengl.... |
I've been working on some kind of mapper that would allow me to map between types.
My objectives:
it should allow mapping between two enums
it should allow mapping enum to string_view
it should allow reverse mapping using a single configuration (enum1 <-> enum2, enum <-> string_view)
the fewer resources it uses the be... |
I wrote this to help manage the code in a bunch of distributed workbooks. Maybe someday I will re-write this as an add-in, but for now, I just needed a way to manage the code without having to manually update every workbook everytime I made a change.
I'm hoping to get some feedback on any major red-flags / things I sho... |
How would you make this piece of code more simple/efficient? The problem should not be solved with one print statement, rather with functions
Could you also give me any advice how I can come to your simplified solution next time?
Code Used
def draw_pattern_1(p,m):
print(p, end=' ')
print(m, end=' ')
print(... |
I am currently writing a bitboard-based Chess Engine in C++, and I recently finished the move generation. I am using move-lookup-tables that get pre-calculated at application startup for sliding and non-sliding pieces. For the sliding pieces I implemented magic bitboards, which get handled in the MagicBitboards class (... |
I've been learning Python for about 4 days now. Python is my first programming language, so I'm not that good at coding yet. I have been programming a little random number game as my first project and came to a state of code with which I'm kind of happy.
My code does what I want: it generates a random number between 1 ... |
Background Story
I crafted a simple single-threaded coroutine in C, running on Linux x86-64.
Short Technical Explanation
1) Task
There are two types of tasks in this implementation.
Main task. This is the main context that is responsible to enumerate all coroutine tasks. This task uses the main program stack that's gi... |
For interfacing with C-API that requires data in one contiguous block
I came up with the following, which seems to work nicely, but I wanted
to see if I didn't miss anything crucial. Drawback is of course the reserved
size, which is double - but fine within my use cases.
Requirements for the ring buffer:
access to dat... |
I made a program for fun that tries to roll a perfect statline, i.e a statline with two groups of only 18s, for a role-playing game. I'm still a newbie in python so mainly trying to learn how to make the code more "pythonic" and efficient.
Background and explanation: The tabletop role-playing game pathfinder has 6 stat... |
import re
from collections import Counter
def reader(filename):
with open(filename) as f:
file = f.read()
regex = r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'
final = re.findall(regex, file)
return final
def count(final):
print(Counter(final))
if __name__ == '__main__':
... |
I've been working on the below function which compares two input strings and returns a similarity score. I've managed to tweak it down to a level of performance I'm pretty happy with, but I'm relatively new to C++ and wondering how I might push it further! In particular if there's any way to cut down on redundancies.... |
Update Feb 2023
This solution is no longer maintained here or on GitHub, mainly because I do not need a timer solution anymore. As seen below, the only purpose of this approach was to get a reliable, crash-free call that can get Excel out of UDF mode - which I've eventually achieved by posting a WM_DESTROY message to a... |
I have created a C++ program that changes the color of a pixel to another color. But the main feature is that it not only changes 100% accurate colors; instead it matches two colors by using a method in which it takes the difference between the two colors' BGR values and then, the differences are squared to compare it ... |
I just solved this exercise from Think Python, 2nd edition:
Python provides a built-in function called len that returns the length of a string, so the value of len('allen') is 5. Write a function named right_justify that takes a string named s as a parameter and prints the string with enough leading spaces so that the... |
I am working on a project that requires a directed weighted graph data structure. It looks like this:
graph.h
#ifndef COM_GITHUB_CODERODDE_PERL_GRAPH_H
#define COM_GITHUB_CODERODDE_PERL_GRAPH_H
#include "unordered_map.h"
typedef struct GraphVertex {
size_t id;
unordered_map* p_children; // Maps a child to the... |
I have implemented the code for finding the longest common substring between two strings in C language.
Syntax: int compute_lcs(char *first_string, char *second_string, struct lcs_result *lcsr, int *error_num_ptr);
I know that I can declare/define variables anywhere in a function but I don't do that. I use K & R style ... |
As part of a university assignment, I have been tasked with populating and rendering a provided Django template with COVID-19-related quarantine data retrieved from a government API. To challenge myself, I wanted to write the code in a professional manner (to the best of my abilities): e.g., using features such as type... |
I am trying to practice C++, so I decided to implement canonical algorithms in C++ as a way to learn best practices and idioms of the language.
I started with merge sort. How could I improve this routine?
I especially want to focus on ways of better using the features of C++. I've also included my tests, which I've wri... |
This is my draft implementation of Huffman encoding & decoding. I'd appreciate any feedback, but have a couple specific questions:
I wrote the code assuming vector represents each bool with a single bit. Is there a standard way to check whether the STL used by the compiler actually does that? With concepts would be be... |
We were asked to create a Base64 encoder for Assembly x86-64 on Linux. Was wondering how my code below could be improved, be it notation or anything else. We only had Assembly for 3 months so I'm not really that used to any kind of particular notation. That's a reason why I'm asking. Thanks for your help !
SECTION .dat... |
I know this may be a silly question (I'm just learning about recursion, and I think there are still things that are still not clear to me.), but... is this a good implementation of a recursive function to find the maximum number in an array?
#include <iostream>
#include <cstdlib>
using std::cout;
using std::endl;
/* ... |
So, I needed a priority queue for D* lite and I wanted to know whether this is an acceptable implementation or not.
#ifndef BCC940D8_CEDF_4B76_8CE4_D8C9A4D1A787
#define BCC940D8_CEDF_4B76_8CE4_D8C9A4D1A787
#include <queue>
#include <vector>
#include <list>
#include <functional>
#include "Node.hpp"
#include "Key.hpp"
... |
This program is designed to work on the command line by piping stdin to stdout and encrypting or decrypting the input using a symmetric key.
Any suggestions for improvement would be greatly appreciated. Error checking tips would be especially helpful.
encrypt.c
#include "lib/encryption.h"
#include <stdio.h>
#include <u... |
I've been working on this project for a day. Any feedback on the code would be appreciated. The code is for an assignment. The main concern I have with the project is that I'm not using abstract classes correctly.
Expenses.cs
using System;
using System.Collections.Generic;
using System.Linq;
using ValidateTypeLibrary;
... |
Let's get right into it, I have a function downloadFile(url, path); Downloads file and saves it.
donwloadFile.js
module.exports = function donwloadFile(url, path) {
return new Promise(res => {
return axios({ url, method: 'GET', responseType: 'stream', })
.then(({ data }) => {
con... |
I am working my way through an algorithms course online, and the assignment is to implement Karatsuba's multiplication algorithm. I am also trying to practice C++, so I wanted to implement it in that language. Looking online, I notice a lot of people solve this using strings.
Is there a benefit to doing that?
If so, ca... |
How can I further optimize following student average coding challenge?
Statement:-
Given a list of N students, every student is marked for M subjects. Each student is denoted by an index value. Their teacher Ms. Margaret must ignore the marks of any 1 subject for every student. For this she decides to ignore the subjec... |
I have written this program to search for a value in an array using sequential search. And well, I've been trying to implement the same algorithm using recursive structure. is this a good implementation? or is there any other way to make it a little more...? (I'm not sure if..., to say if there is a better way to imple... |
I wrote some code to extract the information from a table, but it takes an extremely long time.
The table is in the format of a calendar.
I need the information on an Excel sheet with column 1 as the day number and column 2 as the accommodation type. On the accommodation type, I only want the “Camp” types and the numb... |
This is my first program i write after i finished the c++ tutorials, that program can login and register,
the program ask the user to choice login or register after user choice and write his username the program will choice if this user already exist or not than will take him to next step to write the password and con... |
I've refactored a function from the pygc library used to generate the great_circle. The Vincenty's equation below can be found here.
Destination given distance & bearing from start point (direct solution)
Again, this presents Vincenty’s formulæ arranged to be close to how they are used in the script.
$$
\begin{align}
a... |
I am sure this is not ideal code, basically I am checking a condition at a time and exiting if any of them are true. This will then disable refund functionality.
public bool ShouldChangeBookingBeDisabled(bool isLoggedIn, bool hasRefundedBookingsAtCinema, VistaBooking booking, SitecoreCinema cinema, ODataAttribute exper... |
Need some feedback on this implementation of LFU cache in python3.
Original problem : https://leetcode.com/problems/lfu-cache/
Would really appreciate some feedback on readability, understandability and areas of improvement.
""" ListNode class to create new nodes objects
@variables: key - Key from key,value pair stored... |
I have inspired from the recent blackjack question here and decide to code for simple blackjack console application
Please review and let me know What can improve on the code?
Rules for the application:
There's a single dealer and a player
Initially both get two cards
Number 2 to 9 cards have their numerical value tha... |
Problem :
Imagine you are a developer and get a job in which you need to create a program for a teacher. He needs a program written in c# that calculates the average score of his students. So he wants to be able to enter each score individually and then get the final average score once he enters -1.
So the tool should ... |
I created a Python script that solves Wordle (more specifically this version: https://mywordle.org), it uses a wordlist of all possible answers, it is working perfectly and it rarely loses, you can see it in action here (Google Drive).
You will need this file, I obtained it by editing this file: https://mywordle.org/f... |
I wrote this code in 4 days, I want to see if I can optimize this code some more, and have some suggestion on what can I improve.
This code takes in any number of points then naming them alphabetically, when the points exceeds 26 the letters will repeat themselves AA BB CC, AAA, BBB, CCC, etc., then through combination... |
For the purpose of writing MarkDown documentation, I wanted to extend Vim with the ability to slugify selected text and to replace it with an anchor URL. The idea is to copy/paste a heading and use it to create index.
Example: say I have this text:
Some header
---
The text.
I want to copy Some header to the beginning... |
Over the last year, I have been slowly building an abstract class for deserialisation, and it has sort of morphed into a lightweight JSON-SQL modeler targeting PostgreSQL with psycopg2.
The code:
from __future__ import annotations
from dataclasses import asdict, dataclass
from enum import Enum
from typing import Any, ... |
This is a challenge from Think Python 2nd Edition:
Fermat’s Last Theorem says that there are no positive integers a, b,
and c such that aⁿ + bⁿ = cⁿ. for any values of n greater than 2.
Write a function named check_fermat that takes four parameters; a, b, c and n. And that checks to see if Fermat’s theorem
holds. If ... |
This question is carried over from StackOverflow... First time posting here, so bear with me.
The topic is constructing a search made up of a given string, and a series of letters, where each of the letters individually mutates the string into all possible forms by prepending, substituting, and appending to the base st... |
I am relatively new to C++ and I had this task to solve, where you are given a number and you have to create an nxn array of integers, where you would have to continually switch directions (right, down, up, left) until you fill it.
Example:
1 2 3 4
12 11 10 5
13 14 9 6
16 ... |
I have written a C program that calculates Shannon entropy for a C-String (const char *). It works well but in many implementation the code uses some-kind of map like structures which are available by default in their respective language. But we all know C does not have maps. My code is very fast even for 100 megabytes... |
I have WinForm C# application that every time you press on the green button:
It opens a new WinForm window. This is the code after pressing the green button:
private void toolStripButtonFilter_Click(object sender, EventArgs e)
{
ColumnFilter columnFilter = new ColumnFilter(listView1);
columnFilter.FilterOKUpda... |
I am reading the book Advanced Programming in the UNIX Environment and I have tried to solve the following exercise: Write a function that performs the same actions as dup2, but without using fcntl
My question: What can I improve? What problems may arise?
#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
#incl... |
Introduction and context
I am working on a small application which involves sorting 20GB files as one of the operations. This is being done, due to memory constraints, by breaking them into ~1GB chunks, sorting in memory and then writing back to disk. Then, as stage 2, reading the head of each file and picking the smal... |
I have this logic that I wanted to see if there is any better way to build this select control. I am using the includes to look for data in the array and then I have a if statement to build the selected flag.
$.each(guidelineMeetingDates, function (index, value) {
var b = selectedMeetingDates.includes(value.Meetin... |
This is a simple desktop pager for UNIX/X11 environments. More information in the manual:
PAGINATOR(1) General Commands Manual PAGINATOR(1)
NAME
paginator - X11 desktop pager
SYNOPSIS
paginator [-w] [-c corner] [-g geometry] [-l layout] [-o orientation]
DESCRIPTION
paginat... |
I want to get better at commenting
# The current volume of a water reservoir (in cubic metres)
reservoir_volume = 4.445e8
# The amount of rainfall from a storm (in cubic meters)
rainfall = 5e6
# decrease the rainfall variable by 10% to account for runoff
rainfall -= (rainfall * 10/100) # First, you want to calculate ... |
I was solving this:
Write a compare function that returns 1 if x > y, 0 if x == y, and -1 if x < y.
Writing the code, it seemed that after the first if statement, either elif, else and if could be used. (I wrote examples on the code comments).
Which one is better and why? (Even if it's just to be closer to the best p... |
I'm trying to optimize my JavaScript code to be a short as possible (this is just for fun). Any thoughts would be appreciated!
Basically, the script automatically clicks an "I'm still here" button on a website. To do that, it checks every 100 ms for the prompt (class .dialog-box), and if it sees it, it waits between 1 ... |
Note: I'm aware of this existing post which is similar. However, it does not address all my questions sufficiently.
I have the following three functions, all of which do the same thing: reverse a domain name string.
std::string reverse_domain(const std::string& s) {
std::stringstream ss(s);
std::string segment... |
I am working on a library for algorithms for multiway number partitioning.
One challenge I face is that some users need the entire partition, while other users need only the sums of the parts. For example, suppose the input is the following list: [1,2,3,3,5,9,9], and the goal is to partition them into two subsets. Then... |
I want to be able to create a dark overlay on top of other widgets that can be turned on or off with animation. I managed to get this to work.
But I think I'm doing it in a wrong and inefficient way; for example, in OverlayWidget class I use setAttribute multiple times to enable and disable the MouseEvents and I'm not ... |
the problem being - On component loads, I have this statement which is essentially three flags that determine what is displayed on the page, is there a more elegant way to achieve this? it doesn't feel right checking the ordertype 3 times. I have trimmed down the component as much as possible.
function Component({ disp... |
I have made a function which takes in an end point and a step, then produces a list of integers with the step in mind. For example, if the end point is 10 and the step is 2, the function should return the list [0, 2, 4, 6, 8, 10].
Can I make this function more efficient?
Here is the function:
fun numberStepsFromZero(en... |
In my example, Method1 uses a variable to store the return values and then assigns the variable to the function. Method2 adds the return values directly to the function.
Questions:
What is the pattern of Method2 called?
Is one method prefered over the other and why?
Function Method1(FirstNumber As Long, LastNumber A... |
This code imports data from a separate sheet and matches it based on Column E's data, it does this for every cell then offsets to the next one (622*6) times. If there are any substitutions for vlookup that are an order of magnitude faster, that is probably the ideal solution.
I have about 622 rows of data to match acro... |
I'm a CS Student and I've coded a program to compute Grade Point Average (a metric used in the US for a student's performance across the curriculum). I'm looking for your suggestions and comments for my code.
I used sentinel controlled loop and for loop. Is there any way for improvement??
//Sentinel-Controlled GPA Calc... |
It is a practice assignment (optional). The question is asking to
"Write a program RandomWord.java that reads a sequence of words from
standard input and prints one of those words uniformly at random. Do
not store the words in an array or list. Instead, use Knuth’s method:
when reading the ith word, select it with pro... |
So, in this example I have to make these changes in my tables:
Select Product Data => SKU, QTY
Insert into shipping_back table
Update in shipping_back to current date
Update in customers to another status
Delete from barcode_shipping_back table
Delete from shipping table.
Here is my code:
$datetime = date('Y-m-... |
I have a pivot table called invite_riskarea which is designed as follows:
This table stores the permissions that have a specific user (through an invite id) to give access to specific riskfields. Each riskfield is associated with a riskarea which acts as the main container of specific riskfields.
Within the model Invi... |
I'm trying to implement some kind of command dispatcher.
I've already developed some code, but I'm not sure about a few things.
My dispatcher is a simple command dispatcher, so for each command, there can be only one handler registered. Let's skip considerations about multithreaded issues as I believe that code could b... |
I am new to coding and I have finished a code for a project I have given myself. Everything is functioning the way I want but I was wondering if maybe I could have done some things differently in a more concise way? I'd appreciate it if you could look at my code and help me re-code some elements that could be done in a... |
Been studying data structures in C to get more grasp on the fundamentals as a freshman at uni. This is a coding-challenge that I've given to myself to understand Linked Lists better.
Basically, my aim was to create 2 nodes, along with the node.header that i've written, which has the functions to add nodes to the head, ... |
I wanted to create a program that lists all prime numbers to a given upper bound and that will also provide the amount of primes in the set. After many hours of trial and error I was able to solve it.
I am sure this is not efficient and I want to learn how to look at code and see where improvements can be made. Or just... |
Rate my React dropdown that auto closes when the user clicks outside of it. This is an example in Typescript that I did for practice.
import React, {useEffect, useRef, useState} from "react";
import "./Dropdown.css";
import classNames from "classnames";
interface DropdownProps {
label: string;
}
const Dropdown: R... |
I'm new to programming, especially Python (started in python3) and I want to ask if this piece of code is good enough or not. This is part of my personal project, that is, to make a personal library on chemistry. Also, if this is allowed, I want to ask if, for the following code, lookup is better than calculation.
Thi... |
Introduction
I'm trying to get familiar with functional programming by implementing some functional concepts.
One of these concepts that I've attempted to implement below is a Union data type (or more specifically, a Union2, to indicate that it's a union of two values as a union data type can represent many values).
I ... |
I have a set of strings that all consist of one or two letters followed by one or two digits. I need to sort by the letters then by the numeric value of the digits.
My solution is quite inefficient in terms of performance; how is it possible to improve it?
import re
unsorted_list = ['A1', 'A11', 'A12', 'A2', 'A3', 'B... |
I have written a program that replaces a given c-string with another c-string. My code works well with small files but takes too much time while working with large files (50 Megabytes and larger).
Also, there's a fast_strncat() function which is much much faster than strcat() function.
Please don't get offended for rep... |
I have a data set.
public class EmployeeRepository
{
public static List<Employee> AllEmployees()
{
var loc1 = new List<Location> { new Location { City = "Gretna", State = "VA", ZipCode = "24587" }, new Location { City = "Charlotte", State = "NC", ZipCode = "28012" } };
var loc2 = new List<Locati... |
Motivation: without SaveDecorator, we would have to write:
void Person::save (std::ostream& os) const {
os << tag << '\n';
saveParticular(os);
}
void Worker::save (std::ostream& os) const {
os << tag << '\n';
Person::saveParticular(os);
saveParticular(os);
}
void Teacher::save (std::ostream& os) ... |
I've recently been assigned an assignment to create a word calculator, and given my knowledge in python is still quite lacking, I want to ask if anybody has any better ideas for any possible solutions.
The question is here:
Jimmy has invented a new kind of calculator that works with words
rather than numbers.
Input i... |
Background
The continuous knapsack problem is the following linear program:
$$
\begin{align}
\text{maximize} \quad & f(x) = \sum_{i=1}^n u_i x_i \\
\text{subject to} \quad & \sum_{i=1}^n w_i x_i \leq W \\
& 0 \leq x_i \leq 1, ~~ i = 1 \dots n
\end{align}
$$
As discussed ... |
I am interested in opinions of experienced C programmers about a certain approach to creating a "generic" dynamic array in C. The idea is to use macros to generate function declarations and definitions, and to avoid using void pointers (of course, this is nothing unheard of). For simplicity, I will only generate three ... |
To learn Rust I coded a clone of Mastermind.
Mastermind is a 2-player game, where a master chooses a combination of 4 pegs which are of 6 different colors (For example : Red Yellow Blue Red)
The other player has 12 turns to try to guess the master combination.
Each turn, the player does a guess of 4 pegs. (Exemple : Re... |
I recently implemented a thread pool using std::functions. I only supported functions taking no arguments on the assumption that there would be no need to have them - one could just bind the argument to the std::function or capture it in a lambda.
I quickly realised the limitation with this approach - std::function req... |
This is a follow-up to https://stackoverflow.com/questions/71194832/converting-json-based-log-into-column-format-i-e-one-file-per-column .
My task is to optimize this code whose function is to convert the content of this JSON-formatted log file to columnar-formatted .txt file for each column. An example for a log file ... |
I have been learning C++ for the past 2 weeks.
Following is a problem I solved from Hackerrank. I am somewhat unsure if it's the correct way to solve this, even though I got the desired output. How can I improve this?
Given an array of bird sightings where every element represents a bird type id, determine the id of t... |
stackexchange members. I'm just learning to write. I set myself a task a few days ago and today I completed its implementation. The task was to create a "backupper" (I was inspired just by my homework with "Byte of Python"): you specify from where and where the synchronization of all content will go. After that there i... |
This is going to include my original code, and also revisions I have made, so far I have gotten some help on my character creations portion, and have revised it.
I just would like input as to where I could simplify, and possibly fun features to play around with.
Original Code
Feel free to copy and paste it and run it,... |
I wrote a linked list implementation in C++ to learn the concepts about linked lists as well as C++(17). I decided to use std::unique_ptr to help me avoid leaks and also took a lot of inspiration from std::forward_list.
I am not so worried about bugs, because I wrote some tests and they seem to pass. I am interested in... |
I would like to model global warming from temperature records recorded daily from June 1920 to October 2019 in Montélimar on Python. To do this, I would first like to model these seasonal variations by a sinusoidal fit.
Here is the sinusoidal model that I have reproduced: $$T(t) = A \sin(\omega t + \phi) + B$$ where th... |
I have a DataTable with id, parent, label columns and want to populate a TreeView with it.
I'm new to c# and as far as I understand, there is no ready solution for it, unlike some other languages.
So I sorted the data hierarchically at DataTable level and wrote not a very pretty recursive method.
Is this a good solutio... |
I made a tool that would help in practicing and increasing the speed of Mental Arithmetic, below is the code that I wrote in java. Please suggest if there are any improvements that I can make or any blunders that I made in writing so many methods or the code. Also please do inform me if I had no need to write so many m... |
I am working on an embedded systems project, specifically a line follower car. It has an emitter, a left detector and a right detector. I am working on an algorithm to find the maximum white value, so when the detector gets down to that value it will trigger white, and a minimum black value that will trigger black when... |
I have written some Python code for creating an image made of lots of circles. It works, but I wonder if it could be made faster, shorter or more pythonic somehow.
Example image (took 28 seconds):
from PIL import Image
from random import randint
from datetime import datetime
def circle(data, center, radius, color, s... |
I have a private method in my class to update user experience.
First of all, I create giveExp based on contentLength (string.length)
In that method I had formula for count level from exp: (Math.sqrt(2 * user.xp - 175) + 25) / 10;
I also need to inform the player that they have leveled up.
Full code
private updateXp(
... |
I am going to run a session for a few other developers who are new to Junit, mocking, etc.
I have designed a very simple application with classes and tests to demonstrate how to do unit testing. Please review the code and tests. Any suggestions are welcome.
The problem is of a sample booking service.
BookingService ta... |
I'm trying to implement the game of Yahtzee in java.
This is for a project at my university so I tried to be as clean and to use the best code practices as possible. The part in particular that I would like some suggestion on is the one dedicated on keeping the scores (ScoreCategory, ScoreTable and their implementation... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.