Skip to main content

All Questions

Tagged with
9votes
2answers
1kviews

"Weird Algorithm" (Collatz) from CSES Problem Set

I had to solve the following problem: Consider an algorithm that takes as input a positive integer n. If n is even, the algorithm divides it by two, and if n is odd, the algorithm multiplies it by ...
user23259461's user avatar
8votes
3answers
2kviews

Is set of integers closed under the operation of subtraction?

I was working on a problem, but my solution did not pass the time limit test. Problem Let's say a set of integers is closed under the operation of subtraction if for two distinct elements of this set ...
user27571279's user avatar
4votes
3answers
1kviews

Coding exercise to represent an integer as words using python

Context: Convert a non-negative integer num to its English words representation. Example 1: Input: num = 123 Output: "One Hundred Twenty Three" Example 2: Input: num = 12345 Output: "...
Silah's user avatar
3votes
2answers
158views

Basic Linked List Implementation in JavaScript

Clarification of Intent Recursion here is used on purpose for practice - note that iteration is preferred in this case (I'll be more clear about where my intentions are!) Factory function was also ...
bdng's user avatar
7votes
3answers
201views

Euler - Largest Palindrome Product in Java

Having been going over the documentation, learning more of the subtleties of Java. I am now going over some basic Project-Euler solution code I wrote a little while back. Hoping I can pick up some ...
tijko's user avatar
8votes
3answers
2kviews

Sieve of Eratosthenes in C++ with wheel factorization

I have written a completely working C++ program for the first time, and I have managed to compile it. I have decided to learn C++ and I have written a C++ program to familiarize myself with C++, this ...
Ξένη Γήινος's user avatar
2votes
0answers
105views

Rust implementation of a BTree

I'm studying rust, and I decided to implement a BTree as a way of learning the language. Can anyone give me suggestions on the code? As the language has no inheritance, and we must replace it with ...
Lucas Paixão's user avatar
34votes
8answers
12kviews

Checking if a number is divisible by 9

I tried to develop a new way to check if a number is divisible by 9. I have written my code and it is working fine. I'm not allowed to use *,...
kapil.thakar's user avatar
2votes
1answer
662views

Find all permutations of string using recursion

Background: I am somewhat new to programming and only two weeks into learning Python. Currently trying to improve my understanding of recursion, which has been a tough concept for me to implement. ...
b-mitch's user avatar
2votes
1answer
35views

Simplify matching values while comparing two sorted sets

This is in Star Basic but most likely quite a few languages would have similar structure. I am comparing rows in two sorted sheets. I have a comparison function which returns -1 / 0 / 1 similarly to <...
chx's user avatar
  • 376
3votes
1answer
161views

String Permutation Implemention

The objective is simple: List all possible permutations for a given a String. I looked at some implementations from popular sources. I decided to build this to the flow: The Code for Review ...
Amal Krishnan's user avatar
0votes
1answer
187views

Getting three numbers input interactively and process them

I'm new to Python and programming in general. Let's imagine I have a simple task: Given 3 numbers from user input, I need to count negative ones and print the result. Considering what I know about ...
QLEDHDTV's user avatar
5votes
3answers
1kviews

Find all numbers that are factors of one array and factor into the second array, then print their count

I'm working on a solution to the Following problem on Hackerrank, and I seem to have found a function that works for the purpose. However, I feel as though this is a very overdesigned solution to a ...
fosstar's user avatar
0votes
1answer
414views

subsets in array. Algorithm (No Linq)

Task: A subset is a continuous segment of an array. Two integer arrays are given with elements from 1 to 100: of N and n (N > n). For every subset of the first array of n length find out the next ...
Sheeba334's user avatar
28votes
2answers
2kviews

Euler's Totient Function in x86 assembly (MASM)

My task was to implement Euler's totient function, and I'm looking for any and all criticism. ...
William's user avatar

153050per page
close