All Questions

0
votes
0answers
12 views

Is this Pascal's Matrix?

In Pascal's triangle each number is the sum of the two numbers directly above it, treating empty spots as zero: By rotating the triangle, we can cut out square matrices of varying sizes and rotations ...
1
vote
0answers
67 views

Convert ASCII art numbers to integers

Inspired by this game Challenge: Given an ASCII art string representing a number, output that number. Example: ...
40
votes
18answers
899 views

Would this string work as string?

Write a program that takes a single line string that you can assume will only contain the characters /\_‾. (That's forward and backward slash, underline and ...
2
votes
0answers
68 views

Find all diagonal counts in only one direction [on hold]

If I need to get the number of diagonal squares in all directions: [ I do the following formula 2 N − 2 − |x − y| − |x + y − N − 1| The above example has 13 and ...
5
votes
1answer
161 views

Gotta Collect 'Em All

Your task here will be to write a very dumb AI capable of fetching all treasures on a map. Map The map is defined as follow: (artist-mode™-powered) Basic case: <...
-4
votes
0answers
53 views

Sort a list of integers using only keyboard shortcuts [on hold]

The challenge Sort a list of integers, result should be the sorted list. The catch is that you can only use keyboard shortcuts of a popular program. Details Sorting is in ascending order. Input is ...
0
votes
1answer
74 views
9
votes
46answers
1k views

Print last inputted byte

Challenge You have one string of input bytes, output the last byte in it. Rules Your submission may be a program or function outputting the last byte in the input which is either a string, stdin ...
-1
votes
1answer
89 views

Sort a list of Numbers as letters [on hold]

So, you have a random list (random meaning it doesn't matter what order it is in) of numbers with a length of n, where n is a positive integer smaller than 1000 and ...
8
votes
8answers
274 views

Pi Day: Determine if a list of words is correct Pilish

Background Though this is a bit late for Pi Day, I saw an article about Pilish and thought it would make a great challenge. Pilish is created by using a sequence of words where each word's length ...
35
votes
24answers
2k views

Print a physical multiplication table

Rectangles have this nice property - an \$n \times m\$ rectangle consists of exactly \$n \times m\$ characters! A.. more interesting property is that the rectangles can be aligned nicely in a ...
8
votes
2answers
312 views

ASCII Maze Compression

Challenge Design a compression algorithm specialized for compressing ASCII mazes. You will need to create both a compression algorithm and a decompression algorithm. Your score will be based on the ...
13
votes
2answers
326 views

Pólya urn flip and roll

Problem statement Pólya is playing about with his urn again and he wants you to help him calculate some probabilities. In this urn experiment Pólya has an urn which initially contains 1 red and 1 ...
-1
votes
2answers
242 views

A poly-moly-holy quine. (Well, it's not, but the title's cool.)

This is an answer chaining puzzle, where each answer must add on to the last. The nth submission must output its own source code in the nth language and the n-1 languages before it. A language can ...
-2
votes
0answers
101 views

Experiment Design [on hold]

Background I’ve had to make some of these by hand for a science experiment and was checking to see if anybody had any clever ways of achieving this. It feels like sudoku, but not quite. figuring ...
19
votes
22answers
4k views

It's a yearly task, alright

Given a number 1≤n≤365, output the nth day of the year in "Day-numberth Month" format. For example, given 1, you should output "1st January", without "of". The Gregorian calendar will be used and the ...
8
votes
27answers
5k views

Make a transparent 448*448 image

This is a simple challenge. The task is to write code that outputs a 448*448 square image with 100% transparency. The output should follow the standard image rules.
28
votes
43answers
8k views

Am I not good enough for you?

Background: The current Perfect Numbers challenge is rather flawed and complicated, since it asks you to output in a complex format involving the factors of the number. This is a purely decision-...
20
votes
22answers
2k views

They call me Inspector Morse

Your mission, should you choose to accept it, is to decide whether a given input string is Dot-heavy, or Dash-heavy. A string is dot-heavy when its morse representation contains more dots than dashes....
29
votes
23answers
7k views

Could you please stop shuffling the deck and play already?

Challenge: Input: A list of distinct positive integers within the range \$[1, \text{list-size}]\$. Output: An integer: the amount of times the list is riffle-shuffled. For a list, this means the ...
8
votes
7answers
321 views

New Order #1: How does this feel?

Introduction Putting all positive numbers in its regular order (1, 2, 3, ...) is a bit boring, isn't it? So here is a series of challenges around permutations (reshuffelings) of all positive numbers. ...
12
votes
9answers
740 views

Source permutation

A permutation of a set \$S = \{s_1, s_2, \dotsc, s_n\}\$ is a bijective function \$\pi: S \to S\$. For example, if \$S = \{1,2,3,4\}\$ then the function \$\pi: x \mapsto 1 + (x + 1 \mod 4)\$ is a ...
3
votes
4answers
213 views

Shift the weekday!

Employers love to see their employees working hard, while the employees would love to work less, especially those with a monthly rather than hourly payment. The laziest of employees are thinking ...
0
votes
0answers
48 views

A Program that loads a dynamic array and stops when user puts 0 [closed]

"6. Write a program, divided into functions with parameters, which will load a dynamic array of integers until the user enters the number 0. Initially, assume that the array will contain only 5 such ...
7
votes
6answers
501 views

Black Hole challenge from codewars

I came across this challenge from codewars. I wish to know how to solve this problem. The problem description is given below. Its elements are in range[1..n^2]. The matrix is filled by rings, from ...
0
votes
0answers
51 views

How to use bipartite matching on this codejam challenge? Fashion Show [closed]

In the solution analysis of the 4th question of qualification round of Codejam 2017, it is written that "You can use a bipartite matching algorithm to place the bishops optimally." I don't ...
20
votes
8answers
618 views

Cycles on the torus

Challenge This challenge will have you write a program that takes in two integers n and m and outputs the number non-...
7
votes
4answers
273 views

It's Halloween again!

Problem Description We all love a Twix (because it is the best candy), but this is the kids' first Halloween --- we gotta grab at least one of each type of candy for them. Each Halloween all the ...
56
votes
41answers
5k views

Is it a Cyclops number? “Nobody” knows!

Task: Given an integer input, figure out whether or not it is a Cyclops Number. What is a Cyclops number, you may ask? Well, it's a number whose binary representation only has one ...
29
votes
24answers
5k views

The (Easy) Road to Code

Input: An integer \$n\$, which is guaranteed to be \$\ge3\$. An integer \$d\$, which is one of \$[-1,0,1]\$. Output: A road of size \$n\$, which will be in a north-west direction if \$d=-1\$; a ...
-5
votes
0answers
55 views

Converting Strings Into Integers Using Javascript & Nodejs [duplicate]

Dave is learning about JavaScript. He just learnt an awesome function to convert a string into an integer. Six months ago, he had written a useless code, which produces a random string 'line' of ...
6
votes
24answers
512 views

Sum integers in a string

Input A string. Output The sum of all integers in the line. Constraints 1≤Length of line≤500 Sample test Case Input the 5is 108 seCONd4 a Output ...
15
votes
20answers
2k views

Deal the cards to the players

Tonight is card game night! You are the dealer and your task is to write a program to deal the cards to the players. Given an array of cards and the number of players, you need to split the array of ...
14
votes
4answers
281 views

Is it a valid penalty shoot-out prefix?

In association football (also known as soccer), a penalty shoot-out is the second tie-breaker measure that may be used in a match which can't end in a tie, after extra time (i.e. association football ...
18
votes
37answers
3k views

Create chunks from an array

Your task is to write a program which given an array and a number, you need to split the array into chunks with size is number. Rules Your program will receive an array ...
21
votes
1answer
1k views

Is it possible to make a clamp function shorter than a ternary in JS?

Imagine this short function to clamp a number between 0 and 255: c = n => n > 0 ? n < 255 ? n : 255 : 0 Is this the shortest possible version of a clamp ...
0
votes
13answers
466 views

Find how “smooth” a number is based on binary

I haven't been on PP&CG for a while, so I thought I would post something! Your task is to find how "smooth" a natural number is. Your method is to: 1: Convert the number to binary 2: Find the ...
25
votes
28answers
3k views

Make me a metasequence

Background For this challenge, a 'metasequence' will be defined as a sequence of numbers where not only the numbers themselves will increase, but also the increment, and the increment will increase ...
6
votes
2answers
266 views

Buy the most appropriate items

A store is having a big sale. If your price reaches $199 or more, you can reduce it by $100. You can buy each product only once. Here's an example list of products: (in order to simplify, the names of ...
6
votes
2answers
296 views

Check if all vowels exist in pairs of strings [closed]

Your program should find the number of string pairs (pairs of 2) that contain all vowels (a e i o u), when given an integer N and ...
8
votes
21answers
2k views

Compare four integers, return word based on maximum

This function should take four integer inputs (a,b,c,d) ...
1
vote
1answer
169 views

(bit)Wise Images [closed]

Given a truth table and two images, use the truth table as a bitwise operation to the two images. For example with the truth table: 1 0 1 0 0 0 1 0 (Note that ...
15
votes
16answers
599 views

Compound Interest… with Wizard Money

Gringotts isn't just a vault, but a reputable financial institution and wizards need loans too. Since you don't want to be screwed over by the Gringotts goblins, you decided it would be a good idea to ...
9
votes
13answers
571 views

Arrays Start at \$\pi\$

Your task is to take an array of numbers and a real number and return the value at that point in the array. Arrays start at \$\pi\$ and are counted in \$\pi\$ intervals. Thing is, we're actually going ...
-2
votes
5answers
249 views

45 degree quine [closed]

A very simple golf this time, but should be fun to do. Challenge Output your code, but rotated 45 (or -45) degrees. E.g: lorem ipsum dolor sit amet becomes <...
2
votes
5answers
224 views

Average Idle-Dice Rolling

So I ran into this progressive/idle game cleverly called Idle Dice. Has a variety of random effects applied to a pretty typical progression formula game. Warning, time sink! Play at your own risk. ...
13
votes
6answers
293 views

Unique Brick Tilings Within A Rectangle

I was browsing Stackoverflow and saw this question about tiling an MxN rectangle, and I thought it would be great for golfing. Here is the task. Given the dimension M and N, write a program that ...
12
votes
18answers
893 views

Jumping Numbers

A jumping number is defined as a positive number n which all pairs of consecutive decimal digits differ by 1. Also, all single digit numbers are considered jumping numbers. eg. 3, 45676, 212 are ...
10
votes
1answer
221 views

Implement MENACE

Background MENACE (Machine Educable Noughts And Crosses Engine) is a rudimentary shallow machine learning algorithm for the game Noughts and Crosses, created by British computer scientist Donald ...
32
votes
5answers
8k views

Historical difference between `/` and `÷` in mathematical expressions

Introduction: Inspired by a discussion that is already going on for many years regarding the expression \$6÷2(1+2)\$. With the expression \$6÷2(1+2)\$, mathematicians will quickly see that ...

15 30 50 per page