instruction stringlengths 71 95.1k |
|---|
I'm writing a small game and I use Kotlin for that. I want to model my buildings with the following class:
class Building (
val name: String,
val inputs: Array<Resource>,
val outputs: Array<Resource>
) {}
I want to create multiple instances of this class for the map but I don't want to fill the constructor... |
I'm simply using Slim PHP MVC framework in my API project. PDO::FETCH_ASSOC is used in the database calls. So no data objects. The router handles requests and pass to the controller. controller calls the necessary model to do database operations and response is delivered.
This is the scenario that I want to handle diff... |
LeetCode Problems 3. Longest substring without repeating characters
Given a string, find the length of the longest substring without repeating characters.
Examples:
Given "abcabcbb", the answer is "abc", length 3.
Given "bbbbb", the answer is "b", length 1.
Given "pwwkew", the answer is "wke", length 3. Note that ... |
I have following code but wonder if I can loop it instead of copy-pasting.
calculator.ts
data: function() {
return {
calcInput: 'user types some value in input with v-model'
}
},
template: `
<span
class="calc-button-control"
@click="evaluate()"
@keyup.enter="evaluate()"
>calc</span>
<span
... |
I am a C++ beginner and am working on a bit of code which calculates the pairwise cosine similarities between vectors. The vectors are TF-IDF vectors and the similarities are used to determine similarity between texts (documents).
My code and approach outlined below work as expected, but runs into performance issues wh... |
I needed a way to get URL parameters and put them and their values into a query set's .filter() if they exist. After a day of piecing together information from the Interwebs, I have a working solution to my problem. However, is it the best way to do this? I feel it can be improved or streamlined, but my tiny brain is f... |
This is pretty straightforward, it takes requests from the frontend, checking if it is present on the request, if it does, an action is taken for that if statement.
I wonder if there is a way to remove some if statements or make it less complicated.
private function applyFiltering($query, $request)
{
if ($request->... |
I made a system monitor on Linux which gives you all this information:
The full project can be found in my repo:
https://github.com/sandro4912/System-Monitor
In short it works as following:
I read the data from various folders in the Linux file system
This Data gathering is organized in the classes:
Memory -> reads M... |
So I've attempted this project from hyperskills where you're asked to make a calculator script that can calculate annuity and differentiated payments given that 3 of 4 values are known. I think i went with a real hardcoding way of doing this, as such I would like some advice on making my code more compact and efficient... |
I have an outer div with...
Width
Number of slots the outer div represents
The intent is to add a child div, but position the child div based on the start and end slot in the parent div.
To achieve this behavior, I am calculating the width per slot and the width of child div, plus the margin left of child div.
impor... |
I made some code to get RTTI information of a polymorphic object, it works both if you pass it directly or a pointer to it(the pointer will get dereferenced until null or the object is found), it's going to be used only for debugging log, can this solution be improved in some way?
#include <cstdint>
#include <string>
#... |
extern crate serde;
use serde::{Deserialize, Serialize};
use serde_json::json;
use std::error::Error;
use std::fs::File;
use std::io::prelude::*;
use std::io::{BufReader};
use std::time::Duration;
const NER_SERVER: &'static str = "http://127.0.0.1:5000/parse";
#[derive(Serialize, Deserialize)]
struct Article {
... |
Can someone please review the code and suggest any improvements / changes? Note that this method works but wanted to see if there is a better way to reset the currentYearMeetingCount to -1. I just want to print the data if there is data for that year and for the past 3 years.
class Program
{
static void Ma... |
So, I am trying to create a PNG compression library, and to do that I need to use the DEFLATE algorithm; DEFLATE consists of two parts, the LZ77 compression, and the Huffman Compression. Currently, my LZ77 algorithm has a pretty good compression rate, although I think it could be better, the problem is that is really s... |
Hi I am creating a website for my chiropractor and I am creating the API for data access.
I am creating a HttpPatch Method and want to know if this is the right approach so would be grateful if you could look over my code and let me know if I am doing it right, or if I need to change some things.
Patient Controller
[... |
I've recently started teaching myself basic C++ and decided to implement a simple stack with pointers.
#include <iostream>
using namespace std;
struct StackElement {
char value;
StackElement* next;
StackElement(char value, StackElement* next) : value(value), next(next) {}
};
struct Stack {
StackElem... |
Doing this Rustlings I find I'm unhappy with the code I wrote,
let person: Person = args.next()
.unwrap_or_default()
.parse::<usize>()
.map_or_else( |age| Person{ age, name }, || Person::default() );
What I want is something like
let person: Person = args.next()
.unwrap_or_default()
.parse::<usize>()
.unwr... |
The Cantor Pairing function is a mathematical function which takes two integers and combines them into a single integer that is unique to that pair. This single integer can later be "unpaired" back into the two original, separate integers. Further information on this function can be found here and here.
The Cantor pair... |
TA.ServiceProxy.RoleManagement.GetSubPrivilagesResponses subPrivilagesResponses = GetSubPrivilagesFromPrivilageCodeStatic("Authoring01");
if (subPrivilagesResponses != null && subPrivilagesResponses.SubprivilagesList != null)
{
for (int j = 0; j < subPrivilagesResponses.SubprivilagesList.Length; j++)
{
i... |
Here is a Java Spring web application built as an educational project that fetches and displays data returned from NASA's Mars Weather Service API. The project is essentially an attempt to reverse engineer this page: https://mars.nasa.gov/insight/weather/.
GitHub repository: https://github.com/jkey774/mars-insight-weat... |
I have the following code, made in C language, which reproduces the functionality of the mv (move) command from linux. The problem is that the code is very inefficient. How I can optimize or make the code more efficient without changing the structure too much?
#include <limits.h>
#include <fcntl.h>
#include "o... |
I have the following code that creates a directory in C. I tested it multiple times, reviewed it a few times and it looks fine at the moment.
What I really wanna know is what bugs does it have and how can I fix them ? (comparing it with the mkdir command from linux)
#include "ourhdr.h"
#include <sys/stat.h>
#include <l... |
I've written a function to get the smallest date from an date[ ] and check for null.
If null == infinity
/**
* @param DateTimeInterface|null ...$dates
* @return DateTime|null
*/
public static function minDateTime(?DateTimeInterface ...$dates)
{
$dateList = [];
$dates = array_f... |
I am experimenting with the ServiceLocator pattern. I'd like to support lazy loading of items.
protocol Resolver {
func resolve<T> () -> T
}
protocol Register {
func register<T>(instance: T)
func register<T>(reference: @escaping () -> T)
}
final class LazyServiceLocator {
enum ObjectRegistry {
case insta... |
I was reading about private variables and functions in Python and I managed to get almost everything except one thing.
Is it recommended to write underscore before variables defined inside a function?
Here is the code so it can be more clear:
Version 1:
class House():
def __init__(self):
self.color = "RED... |
I started to learn C++ after programming for some years in Java, and this is my first (header-only) library. When switching from another language, it is always difficult not to project the old habits into the new medium, and thus I wonder how idiomatic my C++ code is, so it would be awesome if someone reviewed this pie... |
Because C# .NET does not come with a MultiDictionary, I implemented one based on this StackOverflow answer.
The MultiDictionary should be able to hold multiple values for one key and remove the key, if no value is assigned to the key anymore.
I wanted to implement nearly all methods, which the standard Dictionary provi... |
I'm new to Rust and would like to know if my code is using the language well, if there are big improvements and if the code in general is rust-like. At the moment it feels very C. I haven't yet developed good feeling on how to incorporate the match function or how to check in a range of chars. The flushing and input pa... |
I was working on Leet code design a Linked List problem. My solution with a @tail pointer, althought it added complexity it made adding to tail O(1), also having a variable size @size made it easier to counter edge cases. Here are some of the stats:
Success Details Runtime: 100 ms, faster than 84.62% of Ruby online
... |
I recently (Yesterday) started working with python and my goal is to not use any tutorials etc where I have to follow along and make a small project. My first project I was recommended to do was a simple game of Rock, Paper, Scissors. I made it in about thirty minutes and it works fine. It goes up to 3 points for each ... |
Context
The original idea is to create an efficient grid structure for a Sudoku like board but this can be applied to many such grid structures (like wavelet transform on images, JPEG2000 etc). This particular one is basically a 9x9 Board which is made up of 3x3 Blocks where each Block is made up of 3 x Axis a a a type... |
I am learning the xlib library and I made a xmenu utility in order to practice it.
It receives as input a menu specification where each line is a menu entry.
Each line can be indented with tabs to represent nested menus.
Each line is made of a label and a command separated by tab.
When you select an entry in the menu, ... |
I am new to this community; I have tried my best to respect the policy of the community. I have written the Monte Carlo metropolis algorithm for the ising model. I want to optimize the code. I have tried my best. I want to optimize it further. The following is the code:
(I have used tricks like finding exponential only... |
I have a Bash script that resides on Remote Server A and transfers files from Remote Server 1 to Remote Server 2. Remote Server 2 is a Dropbox folder so in this script, I call another script (that's not mine) to interface with the Dropbox API.
This is one of my 1st forays into the Bash-scripting world (I'm mostly a des... |
My CS teacher sent me the following code for implementing the stack. I've been programming for a few years in higher-level languages, but have rather weak experience with C++. I mean, this code just doesn't seem right to me. What is done in a bad way here and what would you improve?
#include <iostream>
using namespace... |
I'm writing driver code for the SPI peripheral (as part of a tutorial) on a Nucleo64 (STM32F446RE). The instructor recommends writing this code:
// General macros
#define EnableStatus uint8_t
#define DISABLE 0
#define ENABLE !DISABLE
void SPI_EnablePeripheralClock(SPI_RegDef_t *pSPIx, EnableStatus status)
{... |
So, I've implemented Huffman Encoding in JavaScript, you can see it live here. Here is the code:
var letters,maxX,maxY,minX,maximumDepth,inputString;
if (typeof Math.log2=="undefined") //Internet Explorer 11
Math.log2=function(x){
return Math.log(x)/Math.log(2);
}
function onButtonClick() {
inputStr... |
The method list_all() is the code I am starting with. It just lists all files in "c:\windows".
I want to adjust it to list only the first 10 files (if there are as many files as that there).
I can see that Directory.GetFiles(sDir) returns an array of string. The original method list_all(), takes all of them. I want m... |
The following method works. I am looking for advice to make it more readable.
To see if I could avoid any unneccesary checks / casting and the instance of check.
Also not a fan of having to recreate the initial String with every loop but not sure if there is a way around it.
Things to note.
I am using Java 8 and S... |
I wanted to get some thread support on windows with very simple headers for a library that I'm working on but it had to work on both Windows and Linux. Since C11 threads are not widely supported, this was a great opportunity to learn more about the Windows API and POSIX threads. I decided to post this here because I'm ... |
I just started learning to code during quarantine and whilst learning python, I created this program for a binary search. This is really basic so I assume that there is a way easier method. If anyone knows how I can make this way simpler, your help would be appreciated.
list = [1,15,37,53,29,22,31,90,14,6,37,40]
finis... |
I'm a computer-science hobbyist and found an NP-complete problem that is similar to both subset-product and Exact Cover by 3-sets.
Here is a Reduction of Exact-Cover into my problem. I am multiplying all integers in sets of C.
Input prior to reduction
s: [1, 2, 3, 4, 5, 6]
c: [[5, 2, 1], [6, 4, 3]]
Output after reduc... |
$scope.selectAllProctoringUser = function(checked) {
try {
for (var k = 0; k < $scope.scheduleUsers.lstOnlineProctoring.length; k++) {
$scope.scheduleUsers.lstOnlineProctoring[k].selected = checked;
if (checked) {
let flag = 0;
if($scope.selectedUserLi... |
Here is my code, however, I am unsure whether it is the fastest way to achieve this objective.
import random
add_to = int(input("2 numbers must add to: "))
multiply_to = int(input("2 numbers must multiyply to: "))
solved = False
while solved == False:
nums = random.sample(range(-100, 150), 2)
if (nums[0] + n... |
I haven't done C in a while.
This looks like a simple problem to start.
Leetcode problem 415
Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2.
…
Note: [1. … 2. … 3. … ] 4. You must not use any built-in BigInteger library or convert the inputs to integer directl... |
I have a task wrapper which stores tasks, their CancellationTokens and of course their names (botName). botName is important, because when I want to stop a bot/cancel task, I will have to find it in the collection.
I wonder if there is a better collection to do that, because it looks ugly, especially the CancellationTo... |
Ive written this code over the course of the last days and it seems to work. However I'm not an experienced Coder so I don't know if my code is efficient enough. Any advice for improvements or nez approaches to this challenge would be very welcome.
def lex(task):
def isOperator(c):
return c in "+-*/^"
... |
This is my naive approach on implementing a Sudoku solver, which is okay for simple Sudokus like this:
puzzle = [[5,3,0,0,7,0,0,0,0],
[6,0,0,1,9,5,0,0,0],
[0,9,8,0,0,0,0,6,0],
[8,0,0,0,6,0,0,0,3],
[4,0,0,8,0,3,0,0,1],
[7,0,0,0,2,0,0,0,6],
[0,6,0,0,0,0,2,8,0],
[0,0... |
I am trying to solve the Challenging Palindromes problem from HackerRank. The code that I have got so far fails only for large inputs due to timeout, every other test it passes successfully.
The problem in a nutshell is that a function is to be written, which will take two string arguments, and return the largest palin... |
I'm starting with Kotlin recently and am hoping to improve.
I wrote a small app to parse the list of free Springer books and download the books into your chosen local folder.
Comments around obvious mistakes, unidiomatic Kotlin, any other points of improvements will be greatly appreciated. Thank you.
Gradle dependencie... |
I am adding below code for review as i am bit new to boto3. This Script adds tags (key and value) to All Volumes of EC2 listed in Excel. Is there any more effective way i could have written this? Also I am using AWS temporary credentials by editing ~/aws/config and making profiles. Is there any other way i can use w.r.... |
I currently have a singleton that holds the translation objects in my app. View controllers can subscribe to its delegate so they can update their views if new translation objects have been added. This is what the class looks like
class TranslationItems {
var delegate: TranslationItemsDelegate?
static let shar... |
I want to upload files from my Javascript client to my WebAPI.
With this I want to have a progress bar. My Idea was to cut the files up in chunks and then stream them via SingalR since we are using SingalR anyway.
This is my code:
API:
public async Task UploadStream(IAsyncEnumerable<string> stream)
{
string buffe... |
This component is meant to take in an array of available options and provide the user an easy way to choose multiple options and filter on the available options. Each time the selected options are changed/updated, those options are console logged.
I'm hoping that someone could provide any criticism on my current code. ... |
I'm writing an assistant for the tabletop RPG Pathfinder in Java. I intend to use the MVVM pattern using JavaFX, possibly through mvvmFX. Before I go into the V-VM phase, I have built a first iteration of the model, and would like some comments on it. The full code is on GitHub, I only include in this question the rele... |
I designed a simple timeout thrower for a bluetooth protocol I am writing. If the packet is not received in a certain amount of time, then timeout is thrown. I made it to be as plug and play as possible.
timeout.hpp:
#ifndef __timeout_h__
#define __timeout_h__
#include <thread>
struct Timeoutthread{
private:
... |
I've created my first gem in Profitwell API wrapper https://github.com/eebasadre20/profitwell. I love to get some feedback, comment, or suggestion on the code structure, method implementations, and so on.
I am more concerned in my code structure like how I structured to handle the module and class, the request-response... |
My mentor says to reproduce the system() function of Linux exactly as given in the man pages. I have written the below code. Could someone review this code and provide me any suggestions for improvising. I am a beginner. Thanks :).
#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/wait.h>
#includ... |
Here's my attempt at trying to understand synchronized() blocks using an Object lock, using wait() and notify():
import java.util.Scanner;
public class SyncTest {
private Scanner scanner;
private Object lock;
private volatile String string;
public SyncTest() {
scanner = new Scanner(System.in... |
This code is meant to retry the db operation when a DB connection breaks: OperationalError.
A transaction can fail for example when a db is being restarted and a commit fails. Or when a network error causes error in the DB transaction. (Variables-Names have been adjusted for demo).
My current method forcefully closes t... |
More than once I claimed that using binary search doesn't improve performance of the insertion sort. For example, see answer here and comments here). Now I have time to substantiate my claim.
The only practical application of the insertion sort, where we actually do care about performance, is sorting almost sorted data... |
package labodeva;
import java.util.Scanner;
public class odev5dene {
static int[] quick(int kucuk,int buyuk,int[] arr,int pivot) {
int bos[] = new int[100];
int t=0;
while(kucuk<=buyuk) { // buyuk is big kucuk is small
if(arr[kucuk]<=arr[pivot]) {
kucuk++;
}
else if(arr[buyuk... |
Goal: apply fn to every element of an arbitrarily nested iterable (tuple, list, dict, np.ndarray), including to iterables. Ex:
def fn1(x, key): # ignore `key` for now
return str(x) if not isinstance(x, Iterable) else x
def fn2(x, key):
return x ** 2 if isinstance(x, (int, float, np.generic)) else x
arr = np.r... |
Doubts in logic to generate the output file according to the example
I need that even if he reaches the total_min <720 condition he continues to travel the lines. 720 is the total number of minutes before lunch, when reached, it should separate the activities that should be performed after lunch (lunch must be inserted... |
The powers of 2 are trivial to factor because all powers of 2 have one 1-bit and the rest 0-bits. Just iterate minus one 0-bit as follows: 10000,1000,100,10,1. And then convert the binary strings into base-10 and you got the factors for powers of 2.
Example
import operator
from operator import mul
from functools import... |
I am creating a 2D text-based Drawing Application which can draw basic shapes like Line, Rectangle, Triangle, Circle, Oval. The Line can be drawn in eight directions on a 2D plane and can be moved by a user in Left, Right, Up and Down directions.
The Lines(or any other Shape) are contained within a Boundary. Lines(or ... |
I first thought of the idea when looking at c style multidimensional arrays and realized that there is not really a modern c++ version of that.other than having an std::array of std::array which is not very convenient, so I decided to essentially make a copy of std::array and modify it so would act like a multidimensio... |
Motivation
In the standard Python library enum, a subclass of Enum would create all its members upon class creation. This can be a huge waste of time and memory, especially if the class contains lots of members but only a fraction of them would ever get called.
As a practice project on metaclasses, I decided to impleme... |
I wrote a simple Makefile to build .expected files and compare them. It works as expected and I was wondering it would be great if I could get some feedback. More specifically if I followed all conventions and if it can be improved upon. This is my first Makefile.
# Relative path
RELATIVE_PATH=..
APSSCHED=$(RELATIVE_PA... |
I am developing applications for android. In my application, the user can add information about his weight and watch the progress of weight change. I decided to add filtering of the elements according to the following criteria: the presence of a comment, the absence of a comment, weight gain, weight reduction. For this... |
Currently, I'm working on a legacy application written in .NET that does not contain any unit tests.
This application, when executed produces a very large directory tree with roughly 20.000 files in total in different folders.
The application is currently being used heavily in production thus any mistakes during the re... |
I trying to convert this C code for calculating distance from RSSI to Swift code. I try to do it by myself, but considering I'm beginner, I need help in how to do it.
Here is C code:
#define QUEUE_SIZE 16
#define INCREASE_INDEX(x) ({x++; if(x >= QUEUE_SIZE) x = 0;})
int rssi_array[QUEUE_SIZE] = {0};
int sort_rssi[QUEUE... |
Motivation
I have been trying to work on my first bigger scale Python project, however I am struggling to create pythonic solutions. Instead some of the functions (and especially the naming) I've done so far seems like more of a hacky solution, than a best coding practice. Hope someone can clear up some confusions and ... |
I'm a newbie PABX tech with a hobby for programming so when I learnt most of the telephone system programming can be completed with scripts I got curious.
With a bit of trial and error to work out the seemingly undocumented syntax of the script I decided once I'd cracked it, to create a spreadsheet where the user ente... |
I have been working on a beginner project, learning React and Typescript. The project is an expense manager application and I have tried splitting most of my applications into simple short components.
For the EditExpensePage component I have connected it to the Redux store for the app, in order to be able to access th... |
I am new to programming and "programming thinking" as well. I have created a simple program that calculates future earnings from investing. It seems to be working correctly, but I want to be sure and ask some smarter guy out here, whether the program is really working as it should or whether it could be written in a be... |
I have over 2500 files in a directory tree- some of them are numbered, some of them aren't. eg.
1. That night it rained.epub
The sparrow returns at dawn.epub
001. Tomorrow is a new day.epub
000.1. We are the children.epub
I created my C# code to iterate through all the directories and rename the numbered files to loo... |
I am currently working in a project based on a microservices architecture pattern.
Services are wired up by HTTP calls. They eventually call each others for fetching or putting some data.
I am working on the web page which envelops the whole microservices. I mean, the web page actually needs to send and retrieve data f... |
I have made a clone of the mobile game Ballz, and it works quite well. However, there are a few problems:
Performance. When I have more than 50 balls in the game, the FPS dips from 60. I am unsure how to (A) improve the performance of the game and (B) adapt to a low frame rate such that the game physics continues to w... |
I have to find the position (array index) of a number in an array, the number can lie in between any other two numbers in the array. I have written code for this but I want some alternative way to do this.
example: let the array be given as
float arr[]={1.5, 3.65, 4.9, 8.4, 10.6, 17.5, 19.45, 21.86, 25.67, 30.65};
No... |
I am 12 days old into Python and web scraping and managed to write my first ever automation script. Please review my code and point out blunders If any.
What do I want to achieve?
I want to scrape all chapters of each Novel in each category and post it on a WordPress blog to test. Please point out anything that I miss... |
The basic idea of the code is that agents come into the world, they age and then die. I want to keep track of who is dead and who is alive. Eventually, they will do more things but I think there should be a lot of things I am not doing best practice on. I assume I'm doing something wrong with "Global" as well.
# Classe... |
I haven't found a good code example for a reactive retry operator with a retry strategy that was good enough for my needs. So I tried to make my own. It seems to work in my tests but I would really appreciate some feedback. (C# 8.0)
using System;
using System.Linq;
using System.Reactive;
using System.Reactive.Concurren... |
So this is a pretty simple code, I think it was?
It asks for the user's birth day and month, and gives it back with the day a discount reminder email will be sent (the day before their birthday)
Now I tried to optimize as much as I could, possible wrong inputs and if the user's birthday is the first of a month
Even tho... |
In order to improve my C++ skills I started doing some toy projects, one of them being my own std::string_view implementation. This was my first time implementing a std library. I'm pasting the code inline, but you can check it out at https://github.com/david89/cpp-library/tree/master/types if you want (there are some ... |
I just stated learning Rust (again...), here is a short bit of code I wrote:
#![allow(non_snake_case)]
/**
* takes a 2D Vec and returns a 90° rotated version
*/
pub fn createRotated90(arr: &Vec<Vec<bool>>) -> Vec<Vec<bool>> {
let newWidth = arr[0].len();
let newHeight = arr.len();
let mut newRetArr = cr... |
My gut tells me this is poor practice, so, I thought I would ask for some feedback.
The goal here is to fake a fluent API design for any class without using reflection while keeping it as pretty as possible. If I were to use reflection, I would just use jOOR.
No need to comment on null-checks. I have omitted them in th... |
The idea
At my work, I'm tasked with retrieving logs for a list of online orders from a total of 12 servers. To do this, I SSH into them (with a jump host in between) one by one, run the script for every order, then parse the output. Overall, a very tedious process that I'm sure can be automated.
W -> J -> S
W = My Win... |
I'm implementing the matrix multiply function using Java's multithreading. Below is my code:
So I first tried the normal single threaded approach, then tried the ExecutorService approach, I don't know why the first approach is actually faster than the multithreading approach, based on the start time and the end time, i... |
This would be for a MUD client, which has elements of a sort of telnet bot.
Here, there's string parsing for a logged file for each line -- starting with the most recent. Once a "trigger" is invoked the parser and actions should, for the sake of simplicity, stop.
I'm considering a records class for the triggers, but f... |
The assumption is that k is quite large as compared to no. of elements in the array and division by 2 returns ceiling of the result.
Request for your review and suggestions for further improvements or simplifications.
Example : Array: { 10, 15, 7, 23, 5}
k = 6
Solution: {5, 4, 4, 6, 5} = 24
How Code Works?
Basically we... |
I tried solve this easy leetcode challenge in java. Challenge link
Here is my solution
class Solution {
public int romanToInt(String s) {
Map<String, Integer> data
= new HashMap<String, Integer>() {
{
put("I", 1);
put("V", 5);
put("X", 10);
put("L",... |
I wrote rock paper scissors game using what I have learnt yet.It is while,for statements,list,tuple,dictionary and such simple things only.So I am interested how can I simplify this code using only what I have learnt(simple things)
Here is code
k = input("Hello guys what are you names: ")
j = input("and yours? ... |
I am new to programming and I have tried to recreate below lines into OOP's code. Please review and provide comments.
House has Rooms.Rooms are drawing room, bed room, bathroom etc.Each room has walls, ceiling,floor. Each room have different objects in it like drawing room has sofa, table , TV etc. , bedroom has TV etc... |
So this is the code I wrote for hangman in python. I want to know of can shorten this code more further and make it look more professional
# importing random function
import random, hanged
from word_meaning import meanings
# Dictionary of random words
word_dict = '''whistle,
park,
picayune,
attach,
grubby,
gusty,
neck... |
I've started learning JavaScript last week. Today I ran into a JS exercise available at this link
codewars exercise and decided to give it a try. I've used very basic JS because I know only a small number of JS methods. Could you please review and rate my code?
challenge text :
Your task is to write a function named ... |
I wrote a script that connects to World Bank API, gathers some data (indicators) for a number of countries, creates pd.DataFrame, and saves the result as xlsx file.
What I had in mind when I was writing the code:
I wanted to avoid constructing pd.DataFrame within the function or using the append method to store data ... |
This is one of my mini project of dice rolling and I want to improve it further with more advanced Python. Maybe you have any ideas to improve the code itself?
This code will ask the minimum and maximum number for the dice from the user and the number of times it will roll them, giving random numbers.
import random
#Si... |
I've implemented an algorithm that generates all variations of a matrix of size \$M*N\$. My approach is that I see a matrix as a list where the position of elements can be calculated from the position in the matrix. By doing that I can reduce the problem into generating all variations of a list of length \$M*N\$.
The a... |
Below is my entire program. You can read what it does thanks to the comments and specifications in particular.
My question is: can it be improved? Would it be possible, for example, to avoid writing a fwrite() inside each if? Is there a good pattern that can be implemented somewhere in this code?
The entire program is... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.