Rosetta Code:Village Pump/Suggest a programming task: Difference between revisions

(→‎Unsorted: operators polymorphism)
 
(61 intermediate revisions by 30 users not shown)
Line 9:
 
=Incomplete=
 
* c++ console command line app Name/fantasyname/itemname/etc generators, that takes input from the keyboard and appends them to text files, then all the text files are read and every combination of item is then dumped to a new text file.
 
 
==General==
Line 27 ⟶ 30:
** Display a date in various formats
** Something with [http://terrancalendar.com the Terran Computational Calendar] (and contribute to [https://github.com/terrancalendar/terrancalendar their Github project])
** Calculate yesterday's date
* Show creation, element insertion, element removal and enumeration of a "set" type that enforces constraints as described [[Talk:Symmetric difference#Set_type|here]]. (An invariant analog would be nice as well.)
* The [[:Category:Object oriented|Object oriented category]] is missing a lot of the basics like [[calling a method]].
Line 36 ⟶ 40:
* an encryption program
** What sort of encryption? We've already got tasks for using SSL connections (e.g., [[Client-Authenticated HTTPS Request]]) so maybe you're after message-level encryption? Perhaps a simple [[wp:Data Encryption Standard|DES]] implementation would be apt. (The advantage of that is that it is not particularly strong itself, and so doesn't run close to the legal issues in this area, but points the way towards real production encryption.) –[[User:Dkf|Donal Fellows]] 09:17, 20 January 2010 (UTC)
** See Playfair below --[[User:Brnikat|Brnikat]] ([[User talk:Brnikat|talk]]) 15:09, 10 July 2015 (UTC)
* Monads
* Coroutines/[[Generator]]s
Line 69 ⟶ 74:
* Zipping sequences (calculating their [[wp:Convolution (computer science)|convolution]]) and unzipping
 
* cat & tee: copy input to output, copy input to multiple outputs. I'm not sure of the best name for these tasks ("IO/cat" & "IO/tee"? "copy input to output"?). [[Input loop]] has some solutions that implement the first, but it doesn't explicitly say what should be done with input, and some solutions to `cat` and `tee` may not use loops (which is what's interesting about these tasks).
===Games===
 
* We should maybe double check whether we are missing any tasks corresponding to algorithms listed at http://algo-visualizer.jasonpark.me/
 
* Images: Reading, modifying, and writing either a .PNG/.JPG or other common image type. (Currently, there's bitmap and PPM stuff, but this task is for somethign more practical.)
 
* It would be good to have an implementation of the Nelder-Mead gradient descent algorithm. https://en.wikipedia.org/wiki/Nelder-Mead_method This would be a good candidate for a generic driver (eg:c++ template class) accepting a function and returning the parameter(s) that map to the functions (apparent) minimum. --[[User:Bitrat|Bitrat]] 14:10, 17 January 2019 (UTC)
 
 
*A program which prints out 'Rainbow' to the screen, with each character being one color of the rainbow.
==Games==
* Connect Four (or more) with variable and standard game board (6 rows, 7 columns)
*:- but watch for trade mark violations etc --[[User:Paddy3118|Paddy3118]] 17:33, 29 April 2009 (UTC)
Line 88 ⟶ 103:
::::You are both right, here is a link to a java implementation of pacman [http://zetcode.com/tutorials/javagamestutorial/pacman/]
* Implement a program that generates a random [[wp:Chess960 starting position|Chess960 starting position]]--[[User:Grondilu|Grondilu]] ([[User talk:Grondilu|talk]]) 23:56, 18 April 2014 (UTC)
* What about the [[wp:Nim|Nim]] game and the variations found on its wiki page?
:See [[User:DanBron/Game of Nim]] for history... --[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 05:57, 22 May 2015 (UTC)
* Annotate a crossword diagram given in the format
 
<pre>
......#......
.#.#.#.#.#.#.
.......#.....
.#.###.#.#.#.
.....#.......
##.#.#.#.###.
...#.....#...
.###.#.#.#.##
.......#.....
.#.#.#.###.#.
.....#.......
.#.#.#.#.#.#.
......#......
</pre>
 
and produce a diagram with the numbers in place and a skeleton set of clues in this format
 
<pre>
|--------------------------------------|
|1 | |2 | |3 | |##|4 |5 | |6 | |7 |
| | | | | | |##| | | | | | |
|--+--+--+--+--+--+--+--+--+--+--+--+--|
| |##| |##| |##|8 |##| |##| |##| |
| |##| |##| |##| |##| |##| |##| |
|--+--+--+--+--+--+--+--+--+--+--+--+--|
| |##| |##|##|##| |##| |##| |##| |
| |##| |##|##|##| |##| |##| |##| |
|--+--+--+--+--+--+--+--+--+--+--+--+--|
|11| | | |12|##|13| | | | | | |
| | | | | |##| | | | | | | |
|--+--+--+--+--+--+--+--+--+--+--+--+--|
|##|##| |##| |##| |##| |##|##|##| |
|##|##| |##| |##| |##| |##|##|##| |
|--+--+--+--+--+--+--+--+--+--+--+--+--|
|14| | |##|15| | | | |##|16| | |
| | | |##| | | | | |##| | | |
|--+--+--+--+--+--+--+--+--+--+--+--+--|
| |##|##|##| |##| |##| |##| |##|##|
| |##|##|##| |##| |##| |##| |##|##|
|--+--+--+--+--+--+--+--+--+--+--+--+--|
|17| |18| | | | |##|19| | | |20|
| | | | | | | |##| | | | | |
|--+--+--+--+--+--+--+--+--+--+--+--+--|
| |##| |##| |##| |##|##|##| |##| |
| |##| |##| |##| |##|##|##| |##| |
|--+--+--+--+--+--+--+--+--+--+--+--+--|
|21| | | | |##|22| |23| | | | |
| | | | | |##| | | | | | | |
|--+--+--+--+--+--+--+--+--+--+--+--+--|
| |##| |##| |##| |##| |##| |##| |
| |##| |##| |##| |##| |##| |##| |
|--+--+--+--+--+--+--+--+--+--+--+--+--|
|24| | | | | |##|25| | | | | |
| | | | | | |##| | | | | | |
|--------------------------------------|
 
Across
1 (6)
4 (6)
9 (7)
10 (5)
11 (5)
13 (7)
14 (3)
15 (5)
16 (3)
17 (7)
19 (5)
21 (5)
22 (7)
24 (6)
25 (6)
 
Down
1 (5)
2 (7)
3 (7)
5 (9)
6 (5)
7 (7)
8 (11)
12 (9)
14 (7)
16 (7)
18 (5)
20 (5)
23 (3)
</pre>
where the bracket numbers are the lengths of the corresponding solutions.
 
A much harder task would be, given a set of simple definition type clues and the language used, solve the crossword.
 
--[[User:Brnikat|Brnikat]] ([[User talk:Brnikat|talk]]) 15:03, 10 July 2015 (UTC)
* Implement a [[wp:Wa-Tor|Wa-Tor]] population dynamics simulator. --[[User:Cgibbons|Cgibbons]] 22:22, 3 Apr 2023 (UTC)
::Python implementation: [https://scipython.com/blog/wa-tor-world/]
 
===Database / Network===
Line 244 ⟶ 359:
 
==Implementation-specific==
* Show how your language supports separation of interface or specification from implementation.
 
==Language-specific==
Add a sample Makefile to demonstrate how to build a dummy executable for several programming languages (distinguish between several platforms: Linux,Windows,etc)
Line 327 ⟶ 444:
 
--[[User:Rabuf|Rabuf]] ([[User talk:Rabuf|talk]]) 20:47, 5 November 2013 (UTC)
 
 
==Unsorted==
I am trying to write the following instructions in Pharo or SmallTalk:
- a linked list with tests
- a simple program equivalent of javadoc system that generates a mini javadoc like html file for a class passed as argument.
 
 
Place new items here, if it's unclear where they belong.
 
=== Count Consonants ===
Create a program to count consonants in a string input by the user using the ASCII character set.
The program must only count the letters that are not vowels. It should not count white space, punctuation, control characters, or numeric digits.
For instance, and Ada solution is:
<lang Ada>
with Ada.Text_IO; use Ada.Text_IO;
 
procedure Main is
subtype letter is Character with
Static_Predicate => letter in 'A' .. 'Z' | 'a' .. 'z';
subtype Vowel is Character with
Static_Predicate => Vowel in 'A' | 'E' | 'I' | 'O' | 'U' |
'a' | 'e' | 'i' | 'o' | 'u';
subtype consonant is character with
dynamic_predicate => consonant in letter and then consonant not in vowel;
 
Input : String(1..1024);
length : natural;
consonant_count : Natural := 0;
begin
Put("Enter a string: ");
Get_Line(Item => Input, Last => length);
-- count consonants
for char of input(1..length) loop
if char in consonant then
consonant_count := consonant_count + 1;
end if;
end loop;
New_Line;
Put_Line(Input(1..Length));
Put_Line("contains" & consonant_count'image & " consonants.");
end Main;
</lang>
See also https://rosettacode.org/wiki/Count_how_many_vowels_and_consonants_occur_in_a_string.
[[user:wherrera|wherrera]]
 
=== Multiple Mice ===
If 2 or more USB mice (or trackballs / trackpads) are connected to the system, read the input of each separately (for multiple mouse pointers or for multiplayer game input).
 
=== Colorwheel ===
description
* [https://stackoverflow.com/questions/4235072/what-is-the-math-behind-the-colour-wheel SO]
 
Versions:
* [https://commons.wikimedia.org/wiki/File:HLSColorSpace.png continous]
* discrete: circle is divided into n sectors varying in hue. Each sector is divided into m levels along radial dimension varying in lightnes, like [https://theblog.adobe.com/the-power-of-the-palette-why-color-is-key-in-data-visualization-and-how-to-use-it/ here]
 
=== Operators polymorphism ===
For many OO programming languages we need simple examples of [http://en.wikipedia.org/wiki/Operator_overloading operator overloading] and (if applicable to language) examples how to create new operators.--[[User:Zmi007|Zmi007]] ([[User talk:Zmi007|talk]]) 10:31, 16 April 2015 (UTC)
 
Not only OO languages. Algol68 allows operator overloading and creation of new operators. For instance
<lang ALGOL68>
OP FACTORIAL = (INT n) INT :
IF n < 1 THEN 1 ELSE
INT fact:= 1;
FOR i FROM 2 TO n DO fact TIMESAB i OD;
fact
FI;
OP * = (CHAR c, INT n) []CHAR :
( [n]CHAR result := HEAP [n] CHAR;
FOR i TO n DO result[i]:=c OD;
result
);
print ((FACTORIAL 5, newline));
print (("X" * 6, newline))
</lang>
Output:
<lang>
+120
XXXXXX
</lang>
[[User:Brnikat|Brnikat]] ([[User talk:Brnikat|talk]]) 11:58, 10 July 2015 (UTC)
 
=== Simple OCR ===
Line 397 ⟶ 589:
: You have to remember though, that the aims of RC are ''very'' different to the authors of that paper and any task would have to be written for RC. If anyone has the number to a cold-calling firm, we could find the most appropriate phrase for their number ;-) or maybe not. --[[User:Paddy3118|Paddy3118]] 08:15, 7 May 2011 (UTC)
:: Here's an easy one. The phone number to the White House [http://www.whitehouse.gov/contact switch board]: 202-456-1414. Nothing specific or political intended here; it's just a published, public number. I do like the task idea, though. --[[User:Short Circuit|Michael Mol]] 13:15, 8 May 2011 (UTC)
 
===Weather Routing===
The weather routing problem has the following parts:
<ul>
<li> a predicted surface wind direction and speed, at increments of longitude, latitude, and time</li>
<li> an expected surface current direction and speed, at increments of longitude, latitude, and time</li>
<li> 'polar data' describing maximum speed of a sailboat at points of sail for a given speed of wind over water</li>
<li> regions for sailing (the open ocean) and not (the land, shallows, restricted areas, etc.)</li>
<li> a starting location and time, and a destination</li>
</ul>
 
Given the above information and a specific path, progress along path and therefore arrival time are determined. The weather routing problem, conversely, is to determine the path which results in the earliest arrival time.
[[User:JimTheriot|JimTheriot]] ([[User talk:JimTheriot|talk]]) 00:33, 8 July 2015 (UTC)
 
===Project Euler problems===
Line 556 ⟶ 761:
 
* Linear regression [[User:Wei2912|Wei2912]] ([[User talk:Wei2912|talk]]) 14:38, 6 June 2014 (UTC)
 
=== Playfair encryption and decryption ===
This is a specific example of the encryption problem mentioned in the general section. Playfair is a simple 25-character bigram alphabetic cipher which was still being used by the military in WW1. The task is to use a given keyword or phrase to generate a key which is used to encrypt a plain text and then to decrypt the corresponding cypher text. As only 25 different letters can be used, one must be chosen '''not''' to be used in the plaintext, substituting a valid character as needed to maintain unambiguity of the message. As adjacent identical letters can not be present in the plaintext before encryption, one or more dummy characters must be inserted between them. The plaintext must be padded to an even number of characters before encryption.
 
I don't yet have a suggested plaintext which trips all the above special conditions but will produce one, along with a pass phrase, the corresponding key and the cipher text.
 
[[User:Brnikat|Brnikat]] ([[User talk:Brnikat|talk]]) 11:16, 10 July 2015 (UTC)
 
:There is already a draft task [[Playfair_cipher]] --[[User:AndiPersti|Andreas Perstinger]] ([[User talk:AndiPersti|talk]]) 05:32, 11 July 2015 (UTC)
 
=== ICMP Ping ===
Send an ICMP ping to some local resource, such as the current default gateway or even just 127.0.0.1 or ::1, and display information about the response or the absence of the response.
 
=== Generate a Regular Expression for a Range of Integers ===
 
Write a function that, given the integers 0 <= ''min'' < = ''max'', returns a regular expression that will match the decimal representation of any integer in the range [''min'', ''max'']. You may assume there are no thousand-separators, leading 0's, or other problematic characters in the string to be processed. You may also assume the caller of your function will prepend/append appropriate anchors (e.g., ^, $, or \b) depending on need, so don't include them. Don't use \d as an alias for [0-9] since \d can match weird unicode characters on some systems.
 
'''Example''':
 
''min'' = 1
 
''max'' = 31
 
f(''min'', ''max'') = [1-9]|[1-2][0-9]|3[0-1] /* possible result */
 
f(''min'', ''max'') = [1-9]|[12][0-9]|3[01] /* equally-valid alternate result */
 
'''Example''':
 
''min'' = 91
 
''max'' = 417
 
f(''min'', ''max'') = 9[1-9]|[1-3][0-9]{2}|4(0[0-9]|1[0-7]) /* possible result */
 
f(''min'', ''max'') = 9[1-9]|[1-3][0-9][0-9]|4(0[0-9]|1[0-7]) /* equally-valid alternate result */
 
 
Hint: Use a recursive, divide-and-conquer approach. You will have to handle cases where max contains more digits than min.
 
Bonus: support ranges containing negative integers.
 
=== Weighted Random ===
Pick a random item from a list of dozen items, where each item has different weight (rarity). If the language permits, the list should be made in a way that makes it easy to add new items without having to adjust the weights of the other items.
 
Gaming example: random treasure generation in roguelikes. I've found that this is extremely awkward to do in some languages, and simple in others.
 
=== Partitioning ===
Task for "partition an integer into X primes". For example, partition 19 into 3 primes could return 3+5+11.
 
<br>
-----
<br>
 
This request was just created today.
 
 
See the Rosetta Code task:
 
:* &nbsp; [http://rosettacode.org/wiki/Partition_an_integer_X_into_N_primes '''Partition an integer X into N primes'''].
 
 
-- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 03:48, 3 March 2017 (UTC)
 
=== Bron-Kerbosch algorithm ===
Implement any of the variants of the [[wp:Bron-Kerbosch_algorithm|Bron-Kerbosch algorithm]] for finding maximal cliques (maximal complete subgraphs) in an undirected graph.
 
This should likely be sorted under 1.2.2.1, Graph algorithms.
 
=== Radix-50 encoding and decoding ===
 
[[wp:DEC_Radix-50|Radix-50]] is a method of encoding a restricted character set, used by DEC to store compiler labels and filenames. Each 16-bit word stores three characters encoded as char1*40*40 + char2*40 + char3. The name Radix-50 comes from 50(octal) = 40(decimal).
 
Challenge:
* encode up to three characters into a single word, indicate what you do with invalid characters
* decode a single word into three characters, indicate what you do with invalid data (word>=40*40*40)
* encode a string, indicate what you do with invalid characters
* decode to a string, indicate what you do with invalid data (word>=40*40*40)
 
 
The character set to be used is:
" ABCDEFGHIJKLMNOPQRSTUVWXYZ$?%0123456789"
[[User:Jgh|Jgh]] ([[User talk:Jgh|talk]]) 17:14, 15 May 2020 (UTC)
 
:That sounds like a good idea for a task which will particularly appeal to the 'old timers' amongst us. Why don't you create a draft task for it and add an implementation to start the ball rolling.
[[User:PureFox|PureFox]] ([[User talk:PureFox|talk]]) 08:14, 17 May 2020 (UTC)
 
 
=== Modulo operation ===
The table [[wp:Modulo_operation#In_programming_languages]] deserves to be somewhere on this site, with additional information and features.
 
In my own docs (for Phix) I have this (as a suggestion for the kind of info I think would be useful):
x,y: -9,-4 -9,+4 +9,-4 +9,+4
remainder(x,y): -1 -1 +1 +1
mod(x,y): -1 +3 -3 +1 -- (matches C's % operator)
 
I was thinking there could be checkboxes to filter the list to languages that can and cannot get the results you need/prefer, have an infix operator (or two), work on integers and floating point values or not, and probably something about precedence and associativity. Also the availability of a divmod function, and whether native/bigint/gmp wrappers all agree.
 
A table would clearly be better than a long list of individual entries, I know we can do sorting ([[Rosetta_Code/Count_examples/Full_list|eg]]), I don't know whether filtering is possible. --[[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]]) 08:06, 29 March 2021 (UTC)
 
=== Media files ===
Determine the duration of an audio or video file. Extract a thumbnail from a video file. --[[User:Petelomax|Petelomax]] ([[User talk:Petelomax|talk]]) 01:53, 1 August 2023 (UTC)
 
==Insufficient information==
7,795

edits