@Pavel When I was a young fool, I'd do things like arr[foo++] = foo or even have multiple ++ and -- within the same statement. Nowadays I'm a bit more restrictive when it comes to that, but if it's a single statement I prefer i++ (like in a for loop), otherwise I'll use whatever it suitable for the situation. The compiler usually creates the same machine code anyway, so having to use ++i is just an artifact of the past.
Seconds to human readable format
Not sure whether this has been done before (There are a couple related)
Given an integer input n seconds, output the time in human readable format.
Output must be a string of the format:
x Millennia/Millennium, x Centuries/Century, x Decades/Decade, x Years/Ye...
@JoKing It depends on how you use it. I recently wanted to try just that
#include <stdlib.h>
#include <stdio.h>
int main() {
int n = 10;
int *a = malloc(n*sizeof(int));
for (int i = 0; i < n;) {
i--[a++] = i++*i;
printf("%d\n", ++i++[--a]);
}
}
Convert to Suzhou numerals
Suzhou numerals (蘇州碼子; also 花碼) are Chinese decimal numerals:
0 〇
1 〡 一
2 〢 二
3 〣 三
4 〤
5 〥
6 〦
7 〧
8 〨
9 〩
They pretty much work like Arabic numerals, except that when there are consecutive digits belonging to the set {1, 2, 3}, the digits alternate between vertica...
I know that it's not that interesting of a challenge for golfing languages, but do we have a challenge to check if an input array is sorted or not? E.g. [0,1,2] => true but [2,1,3] => false. I have looked through the questions, but I couldn't find anything when it comes to code golf.
@Dennis I'll probably add a post in the sandbox, and if anyone has heard of such a challenge I just won't post it. It just feels like a very basic golfing challenge, that definitely should exist on the site in my opinion.
@Arnauld I recall having solved similar challenges myself, so I don't think it's very interesting for languages like 05AB1E and similar (MathGolf solves it with s=). But I'm more interested in solutions using more traditional languages.
Is the array sorted?
Inspired in part by Creative ways to determine of an array is sorted.
Given an array of integers, find out if the array is sorted. This challenge is as simple as it sounds. I'm surprised that I couldn't find a question like this on PPCG. I'm aware that a lot of golfing lang...
@Geobits That was the only "is it sorted" question I could find, but it's not a code-golf question which makes it substantially different from the one I'm proposing.
Was meant to post this during the WCC which ended November 28th, however
Chess ASCII Art, Knight
In honor of the world chess championship, in the shortest possible program, output the following ASCII art piece
,....,
,::::::<
,::/^\"``.
,::/, ` e`.
,::; | '.
,::| \___,-. ...
Solve TSP. You're given an oracle(blackbox function) that solves maximum independent set in \$O(\text{number of edges}^3)\$.
Fastest algorithm to (number of edges+sum of lengths of edges) win.
Note. Because TSP (decision version) is NP and maximum independent set is NP-hard, it's possible to ha...
given an arbitrary list of additions and subtractions, like the frequency challenge inputs. Is it always possible to eventually reach the same number twice by repeating the list over and over?
oh wait no of course it isn't. It'd fail for +274, -1
@Skidsdev take the differences between every pair of integers in the cumulative sum of the input (making sure to not have differences between the same integers), mod that by the sum of the input, and check if there is a 0
because every time you concatenate the list with itself, you start again the the sum as the starting number instead of 0, so the cumsum is added to the sum
Can someone please try running part 2 on my frequencies, I've had two different scripts run out of RAM before finishing, which nevertheless work on the test cases: paste.fedoraproject.org/paste/OhCkTxpfsv69ifALNFKE9g