instruction
stringlengths
71
95.1k
Problem statement for better understanding: Let's say we assign a unique number to each alphabet, a=1, b=2, c=3...z=26 then find the frequency of the sum of each word for all possible three letter words (with or without meaning). E.g. abc has sum of 6, yzx has a sum of 75, zzz has the sum of 78, cat has a sum of 24 ...
I am wondering if this is correct: VAR <- c("City") data %>% select(salary, age, VAR) melt(id.vars = c("Salary2", "Age2","City")) -> finalData I get the message: Note: Using an external vector in selections is ambiguous. ℹ Use `all_of(VAR)` instead of `VAR` to silence this message. ℹ See <https://tidyselect.r-lib...
I have a list of n cities and hourly weather prediction for each one of them for h hours. I'm writing a script to find a pair of cities which has the most similar weather. And to represent the similarity in terms of a percentage scale. An example dataset with 5 hour forecast for 3 cities are as follows: city ...
There are some Kiosk machines for people to take a survey. The survey is running by a 3rd party, so no way to get the data from them. To measure how much machines are in use I wrote a script to pull Edge-Chromium browsing history from a remote machine function Copy-FileRemotely { [CmdletBinding()] param ( ...
I am attempting to perform Median Filter with size 3 x 3 in C language. The function MedianFilter33 has been implemented as follows. The experimental implementation The basic structures: typedef struct RGB { unsigned char R, G, B; } RGB; typedef struct BMPIMAGE { char FILENAME[MAX_PATH]; unsigned int XSI...
A follow-up for this previous question. I took into account previous reviews, and tried to make a simple API. I had never done anything non-trivial with C++20 concepts and ranges until now, so I am sure I have a lot of things to fix. I added many helper concepts. Interestingly, while there are various iterator and rang...
I've tried to implement multithreaded pathfinding in an attempt to increase performance, but if anything, performance seems to actually decrease when I enable multithreading. Is there anything I should do differently in order to see a performance gain from multithreading? using System; using System.Collections; using S...
I have a 200 line fully functional flappy bird code but I was told it's suppose to be 250 lines. I don't know what more I can add to the js of the game to improve it and make it longer. I was told I can maybe add a pause button but I only know how to do it through css and not through JS. any suggestions? I also thought...
I tested this algorithm on 9x9 boards and on average, if the board passed to the function is a (valid) solution, it takes 0.13-0.14 seconds for 1 million executions on my machine. I ran my code in Release mode in Visual Studio and timed it using Stopwatch. I found the idea to use summing of all digits in rows, columns ...
As a hobby project (and to learn the language), I'm working on a crypto library in Rust. The following is a component thereof, which implements encryption with and the cracking of the Caesar cipher. My primary interest is whether the code follows best practices, with a secondary concern regarding its efficiency. I'm no...
In learning haskell, I'm writing a fuzzy menu. At the moment, my executable reads in a 'dictionary' from stdin, and ranks each word according to how well it fuzzily matches a search pattern given in the first CLI arg. The idea of the fuzzy matching algorithm is to split a pattern by its delimiters, and then match each ...
Dear coding black belts, My code is working but seems clunky. Take a random number from 1 to 99,999 Display it in 3D in a modified version of the Cistercian numerals from 13th century monks (adding one sagittal dimension) Ask for user input and check if the answer is correct. I breakdown the random number to its digi...
I have written the following code. It checks to see if the object contains the key where the key is present in the map. const myMap = new Map(); myMap.set(2, 'test1'); myMap.set(3, 'test1'); let cellToHighLight = []; let contanins = false; for (let a = 2; a <= 5; a++) cellToHighLight.push({ 'rowId': a, 'colum...
Just wrote this small ring buffer system for an embedded device using C++98. Looking for cc, advice and bugs. Please check it out! https://github.com/Bambofy/EmbeddedRingBuffer /* Changelog ------------------------------------------------------------------ * 06/06/2021 Initial version * -------------------------...
I have the following working code for a generic WebSocket component: import json import aiohttp import asyncio import gzip import asyncio from threading import Thread class WebSocket: KEEPALIVE_INTERVAL_S = 10 def __init__(self, url, on_connect, on_msg): self.url = url self.on_connect = on_co...
I'm using PHP/Laravel and I have two controllers. Controllers/PaymentController Controllers/PaymentExpressControler They both create an request which is exactly the same, but it has some differences. Let's say, they both use createRequest(Request $Request) which is a POST request to a third-party api. I'm wondering h...
This is the simplest implementation of the 'DataGridBehavior' Class for column Filtering I could come up with: public static List<ColumnItem> GetColumnsFilter(DependencyObject obj) { ...} public static void SetColumnsFilter(DependencyObject obj, List<ColumnItem> value) { ...} public static readonly Depend...
I have several Dao classes, including a UserDao, below. The DAOs have many methods, but I'm focussing on deleteUser: @Override public boolean deleteUser(Connection connection,String login) throws MySQLEXContainer.MySQLDBExecutionException, SQLException { int rowNum = 0; Connection con; Prep...
Background I am teaching a course at university level, and have lately been working on creating a home exam for my students. However, the institute has given clear instructions that collaboration is not allowed. In order to comply with this, I saw no other way than to give each student their own variant of the exam (mi...
I am running an IoT fleet, and the need for checking the empty disk usage space has increased. So I am using the following python code. In addition to best practices, efficiency, readability, pythonic, etc. I would love you to share your thoughts about: Is it compliance with: "Robert Martin Single Responsibility Princi...
A while back, I answered this question on Stack Overflow that involved deserializing a binary tree breadth-first using functional programming (the question itself isn't relevant). I'd like to make sure that I'm following functional programming principles and whether or not this is stack-safe. I'd also like to know if I...
I want to sort object list named schedules according to arrivalT. if arrivalT is equal, I want to sort according to burst, if arrivalT and bursT both equal I want to sort according to id. Is my custom comparitor implementaion correct? from functools import cmp_to_key class Pair: def __init__(self, id, arrivalT, bur...
I have turned a "classic" Bootstrap form into a "floating labels" form. For this purpose, I had to move the labels below the form controls. .form-control:focus { box-shadow: none !important; border-color: #c4c4c4 !important; } .with-floating-label { position: relative; } .with-floating-label label { positio...
first post here. I'm looking for some general input as to the correctness of what I'm trying to do here. Is this a good idea, bad idea, what could be plus points or negative aspects to this design? If this is not the right forum for this question please advise where is best, thanks :) What I'm envisioning is using the ...
I've just written this to facilitate my Wget downloads and I was wondering if anyone can review it for me. @ECHO off CLS IF [%1] == [] GOTO missing_arg IF [%2] == [] GOTO missing_arg IF NOT EXIST %2% GOTO bad_dir ECHO About to download %1 to %2 ECHO. PAUSE CLS CD /d "%2" wget64 --execute robots=off --mirror --reject-...
(Previous question) I've created a server file, that keeps waiting for clients. When someone connects to the server, he can send messages to the server, and from the server it is broadcasted to all clients. Can you criticize my simple chat? Any possible improvements and changes are welcome. I have 2 classes and 2 objec...
This is meant to go in a vulkan.hpp-like strongly-typed wrapper for a pure C library. A wrapped enum provides back and forth implicit conversion between itself and the enum, while otherwise behaving as an enum class would. Wrapper utility: #include <type_traits> template <typename EnumT> struct enum_wrapper { using ...
I am rather new to JavaScript and never really worked with promises before. My code works but I would like to learn if there is a better approach? I want to implement the following functionality: Query DB to check if user is in a team if yes, query DB for items belonging to that team Both functions return promises. T...
Started learning C# second time. I have written a console program to calculate sum and count of even and odd numbers. Provided code : using System; namespace Studying_ { class Program { static void Main(string[] args) { uint evenNumbersCount = 0; uint oddNumbersCount = 0...
A very easily stated problem that has a surprising number of gotchas - return a value that's midway between the two supplied values. Depending on the types given, we need to be aware of arithmetic overflow and underflow infinities NaNs rounding For pointers and iterators, the mean only makes sense if the values point...
I was looking into Python 3.10's Structural Pattern Matching syntax, and I want to refactor one of my code that uses if-else, using structural pattern matching. My code works, but I'm trying to find out if there's a better way to deal with a particular section. Let's consider this simple example problem, let's say I ha...
Hello developers i have a got a code which is compares two txt files find their differences and notes them but i am wanting to add a feature which creates two txt files first one is for changed records and other one is for unchanged records what should i do here? Here is my code: import java.io.*; import java.util.*; ...
Scraping tables from the web get complicated when there are 2 or more values in a cell. In order to preserve the table structure, I have devised a way to count the row-number index of its xpath, implementing a nested list when the row number stays the same. def get_structured_elements(name): """For target d...
https://codesandbox.io/s/react-quiz-kb1xb I was wondering what could be improved upon it. I am looking at how it's using Redux and how it's also using hooks and I don't really see anything wrong with it, but I am wondering if it could be improved upon. import React, { Component } from 'react'; import { connect } from '...
EDIT: code snippet added, check the output in JS console I wrote the following binary search algorithm in JS, for the first time in my experience. The variable sampleObj is a random object array in the form of: [{index: 5, sample: 3}, {index: 8, sample: 1}, ...], the final console.log(sampleObj) should log target value...
My code works just fine but it seems like I have too many variables which could confuse people from what the code does. Any ideas? Or does this look fine. Feel free to add any other tips to make my code more efficient. This subroutine is for a button which when clicked rotates a players position. (The overall program i...
What it does Calculates the mean difference for a list of any combination of ints (I think). What I want to know The only other way I can think of doing this is using recursion. I’d like to know if there are other better ways to do this. Also the reason I done this is because I wanted to calculate the mean difference b...
(This is follow-up question). I updated my console program code to calculate sum and count of even and odd numbers. Provided code : using System; namespace Studying_ { class Program { static void Main(string[] args) { uint evenNumbersCount = 0; uint oddNumbersCount = 0; ...
(See the previous version here.) (See the next version here.) This time, I have incorporated all the suggestions made by Roman; my new version follows. package com.github.coderodde.codereview.notepad; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import...
(See the previous version here.) What's new get_last_err_msg renamed to MyGetLastErrorMessage The caller to MyGetLastErrorMessage is responsible for freeing the string The error messages are set to NULL after freeing Instead of char*, a WinAPI type LPCSTR is used Code #include <stdio.h> #include <windows.h> #include ...
I put this together for a task and thought some feedback would be useful. class Matrix<T : Ring<T>>(val size: Size, init: (x: Int, y: Int) -> T) : Ring<Matrix<T>> { init { require(size.x > 0 && size.y > 0) { "Zero size Matrix is invalid." } } // Use a list of lists for the data private val a: L...
I was looking at a dataset with a year column. I wanted all the years with matching a particular event. I then get a list of years which is not easy to read: 2010, 2011, 2012, 2013, 2015, 2017, 2018, 2019, 2020 It would be much better to display them as: 2010-2013, 2015, 2017-2020 I was looking for a builtin function...
I want to implement a client storage mechanism that is as persistent as a session cookie but with more storage capacity. I am doing this by encrypting the data before storing it and saving the keys in a session cookie, when this session cookie is gone the data can not be restored. Data is stored in a permanent webStora...
I have developed a game that allows you to play a full game of Tetris. I haven't really been getting the runs and plays. So I have a request for your reading... Can you possibly give me ideas and or make the code a little simpler. Here's the code that I made: #!/usr/bin/python """ Python implementation of text-mode ve...
I have a method where I fetch user input, check if certain values exist, and based on that build my own custom input object that I would use to search in a database. The code for the search method is as follows. public SearchDocumentResult searchData(EmployeeInput employeeInput) { EmployeeInput getEmployeeInputForS...
I have a daemon which I am able to interact with through a cli-client. The daemon will perform some tasks in future e.g. monitoring the rate at which files are added to a directory. Right now when I add a new function I need to write The function I would like to trigger A message format which the client can send to th...
This is a follow-up to my question over here. Having worked through most of the issues highlighted by @Reinderien in his detailed answer, I somehow got the code to work... Some quick observations: elements.py and the SearchTextElement class from page.py seem to be obsolete to me, after revising the submit_search() fun...
Sorted List value using algorithm selection sort. Can you please review and let me know where I can improve. months = {"January": 1, "February": 2, "March": 3, "April": 4, "May": 5, "June": 6, "July": 7, "August": 8, "September": 9, "October": 10, "November": 11, "December": 12} L = ["March", "January", "December"] #...
I have just written a hangman game in Python for a school project. It reads in a list of words from a text file, and graphics from another text file. For each word, the program asks keeps asking for the user's guess, and prints out either the updated word or incorrect letters, until either the number of attempts reache...
So I've got a Discord bot that will load information about a user's personal charts and display it to them, and one of the commands is to get their leaderboard and show them the most successful songs on their charts. It does this by creating different pages in the embed, and the user can press the reactions to change p...
Often end up using a Scanner to grab some simple input and often when dealing with Number input it can result in a lot of little bits just to check for valid input. In an effort to reduce this, I tried making it more generic with a Functional Interface and a self contained class to hold the Scanner. The following is th...
I implemented the freq(1) program from Plan 9 in go. /* print histogram of character frequencies */ package main import ( "bufio" "flag" "fmt" "io" "log" "os" "sort" "unicode" ) var dflag = flag.Bool("d", false, "print decimal value") var xflag = flag.Bool("x", false, "print hex value"...
I have created an angular BaseService that aims to simplify calling API endpoints I would like to know if you see any code smells, bad patterns or architecture issues. What disadvantages could this have. The idea is to decouple the api configuration from the implementation The configuration is made in the api-config.ts...
I made a very simple user account registration program that works in the terminal using no external libraries other than java.util.Scanner. I want to know what improvements I can make to this code to make it more efficient and more readable: private static void newAccount(){ boolean next = false; System.out.pri...
For academic purposes I want to reinvent Blue Green Red to Grayscale function in Python. I am new to Python so I believe my code below can still be optimized. import cv2 import numpy as np data = np.array([[[255, 0, 0], [0, 255, 0], [0, 0, 255]], [ [0, 0, 0], [128, 128, 128], [255, 255, 255], ]], dtype=np.uint8)...
The function processFus() takes : Two lists of pulses (200 000 in each), as an input Two lists of pulse, empty, pulseValid and invalid. The function must fill them at the end of the process. The function check for each pulse in listPulseA if it matches with one pulse in listPulseB. To check for the match the pulse in...
This is my first attempt at scripting with bash. I am running Ubuntu server, so I don't get to use all the gui back ups out there. Besides, tar works fine for personal use. Please let me know of any improvements and why. #!/bin/bash # PURPOSE: # TO BACK UP ALL FILES AND FOLDERS FROM A GIVEN DIRECTORY # Directory to ba...
I am an AP CS A teacher but as the syllabus does not include Graphics this is really my first time in using Java graphics. I am looking to produce a project not far above the realms of the AP CS A syllabus (classes, inheritance, interfaces, abstract) that will give students an insight into how to produce their own simp...
I started writing a cyrptocoin from scratch, and then got sidetracked writing the database portion which I eventually turned it into its own project. Data is written to the database and then retrieved through an index, similar to a memory-mapped vector. The data are stored in "segments" that can have a configurable siz...
This is my first time using commit and rollback. I just need to know if this is a proper execution of the functions for this particular situation: <?php include("../include/sessions.php"); if(isset($_POST['addcriteria'])) { $value = $_POST['addcriteria']; $addname = isset($value['addname ']) ? $value['add...
I am working on a CSV data Sheet and want to parse and filter the data out it, While working on a code I found a similar code someone has asked on SO POST there and the author having almost the same H/W data as I see that related to HPE H/W where I have some data and columns are different. I've Just raised this questio...
I have created a simple Tic-Tac-Toe program. Can someone please review it and let me know where I can improve. Here we can play against computer. Program start by putting 'X' at the center that is at the position 5. Then ask user to enter number from available position and then assign 'O' on selected position. There ar...
I built a function that should greatly simplify working with long HTML forms, that save data to MySQL using PHP. My forms usually have several hundred input elements that are added / altered / removed frequently from the form. Goal of this function is to only write frontend HTML form markup, MySQL structure gets update...
First of all, I am playing around with python for about a week tops. Absolute beginner here. My story: I work as an IT administrator so I am familiar with eg. PS on a very basic level. I actually got into python due to the fact that I am plotting/farming chia. Now a rather long holiday is coming up, so I thought to mys...
This is my generalisation of std::midpoint incorporating advice received for Find the mean of two values. As well as supporting arithmetic types and pointers, as std::midpoint does, it also supports iterators, complex numbers and user-defined types such as bignums, rationals and fixed-point numbers. As well as advice ...
This is a follow-up of my question over here. I adopted @Reinderien's suggested script to a second website below: fudan.py from contextlib import contextmanager from dataclasses import dataclass from datetime import datetime, date from pathlib import Path from typing import Iterable, Optional, ContextManager # pip ins...
So, I am interested, what is the proper way to submit a highsocre (such as of a Pacman game) in PHP? Here is what I tried: <?php if (array_key_exists("HTTP_USER_AGENT", $_SERVER)) { $browser = $_SERVER['HTTP_USER_AGENT']; } else { $browser = "none"; } if (substr($browser, 0, strlen("Opera")) !== "Opera" && ...
I'm practicing oop concepts these days. To figure it out I tried the below problem. There is a sensor monitoring system. It is a simple system that prints a value, whenever a sensor has picked a value. I tried to solve this problem according to oop and SOLID principals. So I created an interface SensorListener interfac...
Example String creditCardNumber1 = "4561261212345467"; int sum = IntStream.range(0, creditCardNumber1.length()).filter(i -> i % 2 != 0).map(i -> Character.getNumericValue(creditCardNumber1.charAt(i))).sum() + IntStream.range(0, creditCardNumber1.length()).filter(i -> i % 2 == 0).map(i -> Character.getNumericVal...
I have a JSON structure in the following example format: [ {date: '01-01-2021', name: 'House 1', value: '500'}, {date: '01-01-2021', name: 'House 2', value: '600'}, {date: '01-01-2021', name: 'House 3', value: '700'}, {date: '01-01-2021', name: 'House 4', value: '800'}, {date: '01-02-2021', name: 'House 1', v...
This code can woocommerce order change status. But as you can see, this code is hard to read. How can I make it cleaner? <?php $tarih = explode('T', $order->get_date_completed()); $now = date("Y-m-d"); $origin = date_create($tarih[0]); $target = date_create($now); $interval = date_diff($origin, $target); $iade_hakki=$...
This is a follow-up question for Image Processing Median Filter in C. Under the same tiny bmp image read / write framework, a sobel edge detection function has been performed. The experimental implementation The basic structures: typedef struct RGB { unsigned char R, G, B; } RGB; typedef struct BMPIMAGE { cha...
I developed a python Connect 4 game that only uses sys & numpy everything else is regular python! All I'm requesting is a stronger code. This is what I made: import sys import numpy BOARD_SIZE_X = 7 BOARD_SIZE_Y = 6 SEARCH_DEPTH = 4 COMPUTER_PLAYER = 1 HUMAN_PLAYER = -1 # # Method that runs the minimax algorithm and...
I have implemented suggestion and created new draft of the Tic Tac Toe program. Please review and let me know where I can improve. import random def update_board(): """Play game""" board = [[3 * row + col for col in range(1, 4)] for row in range(3)] total_count = 0 UserTurn = False while total_co...
This is a small script to update my project's README file. Notes on improvements from any aspect are welcome! Here is the document it updates. readme.sh (Executed like so: ./readme.sh) #!/usr/bin/env bash export LANG=en_US.UTF-8 export LANGUAGE=en:el set -eu domain_linecount=$(cat black_domain.txt | wc -l) ipv4_line...
I'm not asking for help solving a problem but rather asking for help for possible ways to improve the speed of my program. Essentially what this does is: Tracks market data by pulling the data from the public API provided by the devs. Compares the data with a pre-determined price I input, if its a good deal it does a P...
I got tasked to develop an accordion-like function for a webpage. The header will always be visible, while the main content (and footer) be styled as display: none; At the end of the header, there's a button. Clicking on it will trigger my jQuery code. The code should set <main> as display: block; and slowly scroll th...
register(name, version, ip, port) { this.cleanup(); const key = name + version + ip + port; if (!this.services[key]) { this.services[key] = {}; this.services[key].timestamp = Math.floor(new Date() / 1000); this.services[key].ip = ip; this.services[key].port = port; this.serv...
I was working on the problem to check if the parenthesis are balanced using Scala. Examples: balance("(Hello (my) name is (StackOverflow))") -> True balance("(Hello (my) name is StackOverflow))(((((((") -> False The following implementation is working, however I'm wondering: What would you suggest to change in this i...
(See the previous version here.) This time, I have encorporated all the suggestions made by Marc. Also, I changed the type of points from Double to Number. My newest version follows: com.github.coderodde.codereview.notepad.ClusternessMeasure package com.github.coderodde.codereview.notepad; import java.util.ArrayList; ...
I am dealing with a string draw_result that can be in one of the following formats: "03-23-27-34-37, Mega Ball: 13" "01-12 + 08-20" "04-15-17-25-41" I always start with draw_result where the value is one from the above values. I want to get to: [3, 23, 27, 34, 37] [1, 12, 8, 20] [4, 15, 17, 25, 41] I have created thi...
I have to deal with raw memory manipulation. For that I wrote a function which stores data one after another, and another function which reads this data and stores it into variables. More precisely: /** * - `void * pack( dest, src1, ..., srcn )` * `void * pack( void * dest, src1, ..., srcn )` * Copies the bytes...
This script simply installs the chosen packages if they're not present on a Linux system using the apt package manager. Notes on improvements of any aspect are welcome! setup_env.sh #!/usr/bin/env bash set -euo pipefail install_if_not_exist() { if dpkg -s "$1" &>/dev/null; then PKG_EXIST=$(dpkg -s "$1" | grep "i...
I am in need of a "debiased" clamp function, to generate a uniformly-distributed random number from a good PRNG. Let's assume that RNG in the below code is a field containing an instance of a good (or good enough) PRNG such as PCG, Xoshiro, or MT, which produced a reasonably-uniform distribution of random integers. pub...
I am implementing a function that computes the angle between two vectors when given two n-dimensional arrays and an axis along which to operate. I want to do this with as few copies as possible, and as numerically stable as possible. (The latter gets problematic for small angles (see here)). What I would like reviewed ...
This method is supposed to make a custom requests and then get its response. Sometimes, the response is a string, and most the time the response is in JSON format. As far as I know I can't have a function which returns either a string or a json format. So because of that I have the same method twice but one returns a s...
So I have been learning more about binary numbers lately, particularly in related to describing a gamestate. While perhaps chess is the most natural candidate I wanted to start of with something simpler. So I choose tic tac toe. For reference I used the following source, bit it not required to understand my post. To c...
I'm using this kind of data binding in PHP, is it safe? $sql = "CALL registerUsers(?, ?, ?, ?, ?, ?, ?)"; $stmt = $conn->prepare($sql); $stmt->bind_param("sssssss", $_usr_code, $_usr_eml, $_usr_name, $_usr_pass, $_fileName, $_usr_type, $_usr_role); $stmt->execute();
I have written a small program that swallows windows. It works in X.org using the xcb library. This is my first rust program but I have lots of other programming experience. Any general improvements are great, but a specific problem I've been having is that if the program exits too quickly (child process is short) ther...
I have tried to code a genetic algorithm to guess the coefficients of a degree 4 polynomial. The information initially provided is values of y = f(x) for different x using the original polynomial. I then generate 100 polynomials with randomly selected coefficients. These polynomials are then ranked based on the least s...
I got this two subjects that both have a delay and I need the second one to be subscribed when the first one is completed, asynchronously. Both subjects only emit once (http requests) and I'm trying to avoid nested subscriptions but I can't figure out an optimal solution. What I've got so far: Stackblitz const order = ...
I'm wrote Asynchronous Lock provider for reducing lock that breaks async keyword. All tasks with async and await keywords are chained by GetAwaiter().OnCompleted(Callback) on I know. But some cases are not, for example: lock keyword, EventObject.Wait(), Mutex like objects... etc. So, I think that if asynchronous chaina...
I have a C# program to check if a hard coded host is available and if not, waits then checks again (this is a loop in form of recursion). How can it be enhanced? using System; using System.Net.NetworkInformation; using System.Windows.Forms; namespace trial17 { public partial class Form5 : Form { public...
I'm new to coding in general and I am working in flutter right now. I've successfully been able to add single string objects into a list but I'm having issues adding an object with multiple strings into a list. I'd love some guidance if anyone's able to help! This is my model import 'dart:convert'; import 'package:jso...
I have a simple chat system. I have built this to scale so I would appreciate optimisation tips or alternative table structures too. This does not include the pub/ sub queue system. Users | id | name | createdAt Conversations - 1 Conversation has many messages & many participants | id | lastMessage | updatedAt Partic...
I am trying to create a function which can visualize(compare) two items of 'Platform', 'Genre' and 'Publisher' according to the 'Global_Sales' in different 'Year'. The DataFarame looks like: Code: def compare_two(by, first, second): """ by: Genre or Platform or Publisher first: first item from 'by' ...
I wrote a simple multitthreading program which does particle swarm optimization. Optimization itself and some corresponding functions were taken from https://nathanrooy.github.io/posts/2016-08-17/simple-particle-swarm-optimization-with-python/. This is my first attempt to write multithread Python code :) Code has 4 fil...
I am attempting to learn the Nim language by making a small and simplistic register machine. It is intended to interpret some basic instructions. The entire parsing lexing process consists of splitting the inputted code by spaces (not whitespace in general), which newlines are counted as. Is this reasonable code style ...
I started learning OOP programming style in PHP. After end of the course, I wrote a simple calculator in OOP style. Can some one check my code and give me feedback? //Calculator Class <?php use lib\calculator\classes as classes; spl_autoload_register(function ($className) { require_once $className . ".php"; }); ...
I want to create a hierarchy of Typescript interfaces because I think classes would be an overkill in my case. The main obstacle is checking if an object has a specific type. I solved it this way: enum AnimalId { Mammal = 1, Fish = 3, } interface BaseAnimal { id: number categoryId: AnimalId name: string } i...