https://codegolf.codidact.com/categories/46/tags/4274.rssNew Posts Tagged 'code-golf' - Code GolfCode Golf - Codidact2024-03-18T17:04:48Zhttps://codegolf.codidact.com/posts/291048The 50 substrings that validate any string of Roman numeralstrichoplaxhttps://codegolf.codidact.com/users/538902024-03-11T17:54:24Z2024-03-18T17:04:48Z<p>Given a string of Roman numerals, decide whether it forms a valid Roman number. If not, output the substring that proves this, from the list of 50 strings described below.</p>
<h2>Relevant fact...https://codegolf.codidact.com/posts/289542Word suggestingtrichoplaxhttps://codegolf.codidact.com/users/538902023-08-28T16:10:23Z2024-03-11T23:16:09Z<p>Suggest a word from a word list, given a string.</p>
<h2>Motivation</h2>
<p>Imagine typing a word one letter at a time, and seeing a suggested word after each letter is typed. At first the sug...https://codegolf.codidact.com/posts/291002The 50 substrings that validate any string of Roman numerals [FINALIZED]trichoplaxhttps://codegolf.codidact.com/users/538902024-03-06T00:11:16Z2024-03-11T17:56:14Z<h3>Now posted: <a href="https://codegolf.codidact.com/posts/291048">The 50 substrings that validate any string of Roman numerals</a></h3>
<hr>
<p>Given a string of Roman numerals, decide whether...https://codegolf.codidact.com/posts/29100512-hour time is weird [finalized]honnzahttps://codegolf.codidact.com/users/532222024-03-06T11:03:13Z2024-03-08T13:34:53Z<p>Posted: <a href="https://codegolf.codidact.com/posts/291018">https://codegolf.codidact.com/posts/291018</a></p>
<p>Your mission for today, should you choose to accept it, is to write a simple <...https://codegolf.codidact.com/posts/29101812-hour time is weirdhonnzahttps://codegolf.codidact.com/users/532222024-03-08T13:31:49Z2024-03-08T13:31:49Z<p>Your mission for today, should you choose to accept it, is to write a simple <a href="https://en.m.wikipedia.org/wiki/12-hour_clock">12-hour clock</a> calculator. Your input will always be in th...https://codegolf.codidact.com/posts/290870Fibonacci without consecutive digitstrichoplaxhttps://codegolf.codidact.com/users/538902024-02-19T15:02:58Z2024-03-03T14:43:07Z<p>Output the Nth number in the list of <a href="https://en.wikipedia.org/wiki/Fibonacci_sequence">Fibonacci numbers</a> that have no consecutive digits.</p>
<h2>Input</h2>
<ul>
<li>A non-negati...https://codegolf.codidact.com/posts/283770Make $2 + 2 = 5$General Sebast1anhttps://codegolf.codidact.com/users/541142021-08-27T10:46:44Z2024-03-03T04:48:13Z<p>In this challenge, add 2 integers, but if both the integers are <code>2</code>, output <code>5</code>. Shortest code in each language wins!</p>
<h1>Example ungolfed program in <a href="https://...https://codegolf.codidact.com/posts/290437Is it stuck in a counting loop?WheatWizardhttps://codegolf.codidact.com/users/543162023-12-14T14:56:41Z2024-03-03T01:51:05Z<p>Given a list of non-negative integers the function $f$ replaces every integer with the number of identical integers preceding it (not necessarily contiguously). So</p>
<pre><code>f [1,1,2,2,1,3...https://codegolf.codidact.com/posts/290974Can I follow this recipe?WheatWizardhttps://codegolf.codidact.com/users/543162024-03-02T17:18:45Z2024-03-02T18:03:11Z<p>You work in a kitchen which has a peculiar rule. When you mix something into a pot you must always add at least one new ingredient.</p>
<p>So you can add pasta, oil, salt then pesto, but not pa...https://codegolf.codidact.com/posts/290667Print the modular multiplicative inverse / virtual fractionsH_Hhttps://codegolf.codidact.com/users/646282024-01-30T08:53:44Z2024-03-01T20:53:14Z<h2>Goal</h2>
<p>Print the <a href="https://en.wikipedia.org/wiki/Modular_multiplicative_inverse">modular multiplicative inverse</a> with a modulus of 65536 (or a higher exponent of 2) for odd num...https://codegolf.codidact.com/posts/290852Fibonacci numbers with no consecutive digits [FINALIZED]trichoplaxhttps://codegolf.codidact.com/users/538902024-02-17T23:00:46Z2024-02-19T15:06:51Z<h1>Now posted: <a href="https://codegolf.codidact.com/posts/290870">Fibonacci without consecutive digits</a></h1>
<hr>
<p>Output the Nth number in the list of <a href="https://en.wikipedia.org/w...https://codegolf.codidact.com/posts/290612Print virtual fractions / 2-adic fractions / Modular multiplicative inverse [FINALIZED]H_Hhttps://codegolf.codidact.com/users/646282024-01-22T18:16:00Z2024-02-02T18:31:35Z<h2>Now posted: <a href="https://codegolf.codidact.com/posts/290667">Print virtual fractions / 2-adic fractions / Modular multiplicative inverse</a></h2>
<hr>
<h3>TL;DR</h3>
<p>Print this values...https://codegolf.codidact.com/posts/290589Plain black webpagetrichoplaxhttps://codegolf.codidact.com/users/538902024-01-18T13:50:35Z2024-01-25T08:07:57Z<p>This is a language specific challenge, for HTML only.</p>
<p>Your answer is the content of a self contained HTML file, that when opened in a web browser gives a plain black page.</p>
<h2>Requi...https://codegolf.codidact.com/posts/289921Borromean coprimestrichoplaxhttps://codegolf.codidact.com/users/538902023-10-07T23:06:49Z2023-11-30T23:02:15Z<p>Given 3 positive integers, indicate whether they are Borromean coprimes.</p>
<h2>Definition</h2>
<p>3 positive integers are called <em><strong>Borromean coprimes</strong></em> if both of the f...https://codegolf.codidact.com/posts/290000Shortest representation in generalised Roman numeralstrichoplaxhttps://codegolf.codidact.com/users/538902023-10-13T12:37:48Z2023-11-30T09:34:43Z<p>Find the shortest representation of an integer in generalised Roman numerals. Since there is more than one way to generalise, only the following definition applies to this challenge.</p>
<h2>De...https://codegolf.codidact.com/posts/290027How many umbrellas to cover the beach?WheatWizardhttps://codegolf.codidact.com/users/543162023-10-16T19:23:32Z2023-11-23T06:26:48Z<p>You work at a beach. In the afternoon, the sun gets quite hot and beachgoers want to be shaded. So you put out umbrellas. When you put out umbrellas you want to shade the entire beach, with as f...https://codegolf.codidact.com/posts/289681Is it part of the mandelbrot set?H_Hhttps://codegolf.codidact.com/users/646282023-09-12T16:01:52Z2023-11-13T02:02:39Z<p>Input is a number, you have to decide if it is part of the mandelbrot set or not, after at least 16 iterations.</p>
<p>This is done by applying this formula: $z_n = z_{n-1}^2 + c$ repeatedly. $...https://codegolf.codidact.com/posts/289996Single digit Roman numeraltrichoplaxhttps://codegolf.codidact.com/users/538902023-10-13T03:26:40Z2023-11-07T09:59:45Z<p>Given a single character, which is a valid Roman numeral, output its value.</p>
<h2>Values</h2>
<p>There are 7 valid single character Roman numerals, with the following values:</p>
<table>
<...https://codegolf.codidact.com/posts/290065Is it a valid hidden word?WheatWizardhttps://codegolf.codidact.com/users/543162023-10-20T18:26:52Z2023-11-05T12:39:46Z<p><a href="https://www.puzzlesociety.com/crosswords">The Universal Crossword</a> has a set of <a href="https://docs.google.com/document/d/1ORNpKwGG7RedypfnYwgOfkTUc0jNZ7FKRRTVWDmTfl8/edit">guideli...https://codegolf.codidact.com/posts/287238Arbitrary angle wrapping wordsearchtrichoplaxhttps://codegolf.codidact.com/users/538902022-10-12T02:56:33Z2023-10-29T11:08:16Z<h1>Sandbox</h1>
<ul>
<li>
<p>Would you change anything about the test case format?</p>
</li>
<li>
<p>Are there any more edge cases to add to the test cases?</p>
</li>
<li>
<p>Should words...https://codegolf.codidact.com/posts/287403Shortest representation in generalised Roman numerals [FINALIZED]trichoplaxhttps://codegolf.codidact.com/users/538902022-11-15T00:32:35Z2023-10-13T12:43:52Z<h1><a href="https://codegolf.codidact.com/posts/290000">Posted</a></h1>
<p>Given an integer, find its shortest representation in generalised Roman numerals. Since there is more than one way to ge...https://codegolf.codidact.com/posts/289956Single character Roman numeral [FINALIZED]trichoplaxhttps://codegolf.codidact.com/users/538902023-10-11T19:23:05Z2023-10-13T03:28:52Z<h2>Now posted: <a href="https://codegolf.codidact.com/posts/289996">Single digit Roman numeral</a></h2>
<p>Given a single character, which is a valid Roman numeral, output its value.</p>
<h2>Val...https://codegolf.codidact.com/posts/284068Digit Sum Integer Sequence (working title)Shaggyhttps://codegolf.codidact.com/users/535882021-09-08T13:47:21Z2023-10-09T10:37:20Z<p>Inspired by <a href="https://codegolf.stackexchange.com/q/233870/58974">this challenge</a>. If anyone has any suggestions for a song title I could use for the challenge title then please leave a...https://codegolf.codidact.com/posts/289866Borromean coprimes [FINALIZED]trichoplaxhttps://codegolf.codidact.com/users/538902023-10-01T23:08:21Z2023-10-07T23:08:03Z<h1>Now posted: <a href="https://codegolf.codidact.com/posts/289921">Borromean coprimes</a></h1>
<hr>
<p>Given 3 positive integers, indicate whether they are Borromean coprimes.</p>
<h2>Definiti...https://codegolf.codidact.com/posts/28708855 fruit salad: choose your own Kolmogorov complexitytrichoplaxhttps://codegolf.codidact.com/users/538902022-09-27T22:03:39Z2023-09-25T22:39:11Z<p>This is a fixed output challenge. It is similar to a standard Kolmogorov complexity challenge, except you get to choose your own fixed output. Given no input, output 55 fruits. You may choose an...https://codegolf.codidact.com/posts/2870823D compass point from 3D coordinatestrichoplaxhttps://codegolf.codidact.com/users/538902022-09-26T21:42:06Z2023-09-16T08:20:02Z<p>Given 3 dimensional (3D) Cartesian coordinates (x, y, z), output the 3D compass point that comes nearest to describing the direction from the origin.</p>
<h2>Definitions</h2>
<h3>Directions</h...https://codegolf.codidact.com/posts/289678Is it part of the mandelbrot set? [FINALIZED]H_Hhttps://codegolf.codidact.com/users/646282023-09-12T12:32:47Z2023-09-13T10:20:30Z<h2>Now <a href="https://codegolf.codidact.com/posts/289681">posted</a></h2>
<hr>
<p>Input is a number, you have to decide if it is part of the mandelbrot set or not, after at least 16 iterations...https://codegolf.codidact.com/posts/289436Reverse the bits in a ByteH_Hhttps://codegolf.codidact.com/users/646282023-08-18T11:41:17Z2023-09-08T23:52:22Z<p>Simple challenge: Read a byte, swap bit 7 with 0, 6 with 1, 5 with 2 and 4 with 3 and then output the byte. For example the byte <code>0b1001'1100</code> would turn into <code>0b0011'1001</code>...https://codegolf.codidact.com/posts/286280Looping counterceltschkhttps://codegolf.codidact.com/users/80562022-04-21T18:19:56Z2023-09-08T15:07:09Z<h1>Looping counter</h1>
<p>Create an infinite loop that outputs lines of asterisks, with each line containing one more asterisk. Instead of the asterisk, any printable, non-whitespace character c...https://codegolf.codidact.com/posts/287131Knight safe squarestrichoplaxhttps://codegolf.codidact.com/users/538902022-09-30T21:30:04Z2023-09-06T00:11:58Z<p>Given a chess board with some knights on it, say how many squares are neither attacked by a knight nor containing a knight.</p>
<h2>Input</h2>
<ul>
<li>An 8 by 8 grid where each square is eit...https://codegolf.codidact.com/posts/288755A word suggester [FINALIZED]trichoplaxhttps://codegolf.codidact.com/users/538902023-06-28T11:53:03Z2023-08-28T16:11:47Z<h1>Now posted: <a href="https://codegolf.codidact.com/posts/289542">Word suggesting</a></h1>
<hr>
<p>Suggest a word from a word list, given a string.</p>
<h2>Motivation</h2>
<p>Imagine typing ...https://codegolf.codidact.com/posts/289447Give the fool's fibonacci sequenceWheatWizardhttps://codegolf.codidact.com/users/543162023-08-19T13:42:17Z2023-08-19T22:54:46Z<p>Recently <a href="https://codegolf.stackexchange.com/q/264316/56656">I asked</a> for tips on improving some code-golf of mine. The code was <em>supposed</em> to output every third value of the ...https://codegolf.codidact.com/posts/285821Keyword golfingLundinhttps://codegolf.codidact.com/users/81762022-02-04T12:19:10Z2023-08-09T15:15:07Z<p>Many programming languages have the concept of <em>keywords</em>, special syntax items that are not just identifiers reserved by some library, but words reserved by the language itself.</p>
<p>...https://codegolf.codidact.com/posts/287207Lowercase, but not just the letterstrichoplaxhttps://codegolf.codidact.com/users/538902022-10-10T10:26:16Z2023-08-09T11:03:26Z<p>Given a string of printable ASCII characters, convert them all to lowercase, except not just the letters.</p>
<p>ASCII characters that are letters have a bit in their binary representation that...https://codegolf.codidact.com/posts/279639Reverse an ASCII stringmoonyhttps://codegolf.codidact.com/users/535042020-11-30T21:09:09Z2023-08-01T19:52:27Z<p>Your goal is to reverse an ascii string.
Given a (optionally newline or null terminated) input, output your input in reverse order, optionally followed by a newline. Terminate afterward.
Funct...https://codegolf.codidact.com/posts/289152Reverse engineer the colors for a layout.WheatWizardhttps://codegolf.codidact.com/users/543162023-07-30T14:33:08Z2023-07-30T14:33:08Z<p>At my job we have to sometimes lay out materials. Materials come in large long rolls and are cut into smaller pieces when being laid out.</p>
<p>When we order the rolls we draw up a layout docu...https://codegolf.codidact.com/posts/287324Sort letters by heighttrichoplaxhttps://codegolf.codidact.com/users/538902022-10-30T16:52:20Z2023-07-17T20:37:10Z<p>Given a sequence of lower case letters, sort them into order of height.</p>
<h2>Heights</h2>
<p>The heights of letters are dependent on font, so for this challenge the height order to be used ...https://codegolf.codidact.com/posts/288502Label a hinged tetrominotrichoplaxhttps://codegolf.codidact.com/users/538902023-06-17T17:18:49Z2023-07-17T13:27:48Z<p>Given a hinged tetromino, give it a unique, consistent label independent of location, rotation, and reflection.</p>
<h2>Tetrominoes</h2>
<p>A <em><strong><a title="Wikipedia article on Tetromi...https://codegolf.codidact.com/posts/288943Find near miss prime multiples.WheatWizardhttps://codegolf.codidact.com/users/543162023-07-09T17:44:10Z2023-07-09T19:31:44Z<p>Given a number $n \geq 3$ as input output the smallest number $k$ such that the modular residues of $k$ by the first $n$ primes is exactly $\{-1,0,1\}$.</p>
<p>That is there is a prime in the f...https://codegolf.codidact.com/posts/288917Probability of rolling all 6 dice facestrichoplaxhttps://codegolf.codidact.com/users/538902023-07-08T14:52:07Z2023-07-09T18:41:04Z<p>The probability of rolling every number from 1 to 6 with $N$ six-sided dice.</p>
<h2>Input</h2>
<ul>
<li>A positive integer $N$.</li>
<li>Your code must work for inputs up to and including 1...https://codegolf.codidact.com/posts/288885Expected value of highest dice rolledtrichoplaxhttps://codegolf.codidact.com/users/538902023-07-06T21:12:46Z2023-07-09T11:34:15Z<p>You roll $N$ six-sided dice simultaneously. Your score is the highest number rolled. If you play this game many times, what is the expected value (mean) of your score?</p>
<h2>Input</h2>
<ul>
...https://codegolf.codidact.com/posts/288848Probability of rolling all 6 dice faces [FINALIZED]trichoplaxhttps://codegolf.codidact.com/users/538902023-07-03T21:55:16Z2023-07-08T14:55:09Z<h2>Now posted: <a href="https://codegolf.codidact.com/posts/288917">Probability of rolling all 6 dice faces</a></h2>
<hr>
<p>The probability of rolling every number from 1 to 6 with $N$ six-side...https://codegolf.codidact.com/posts/283730Roll n fair diceMoshihttps://codegolf.codidact.com/users/531962021-08-26T02:21:18Z2023-07-07T13:30:12Z<h1>Challenge</h1>
<p>This is a simple randomness challenge: Given a non-negative integer $n$, and positive integer $m$, simulate rolling and summing the results of $n$ fair dice, each of which ha...https://codegolf.codidact.com/posts/288805Expected value of highest dice rolled [FINALIZED]trichoplaxhttps://codegolf.codidact.com/users/538902023-07-01T18:31:26Z2023-07-06T21:14:17Z<h2>Now posted: <a href="https://codegolf.codidact.com/posts/288885">Expected value of highest dice rolled</a></h2>
<hr>
<p>You roll $N$ dice simultaneously. Your score is the highest number roll...https://codegolf.codidact.com/posts/282804Caesar shift cipher [released]General Sebast1anhttps://codegolf.codidact.com/users/541142021-07-25T03:07:51Z2023-07-06T13:38:21Z<h1>Introduction</h1>
<p>What is ROT13? It's basically a cipher sequence that changes a letter's value from the number chosen. If we use ROT1 on "games", we get "hbnft". The basic interpretation o...https://codegolf.codidact.com/posts/28288199 Shortened Bottles of Beer [released]General Sebast1anhttps://codegolf.codidact.com/users/541142021-07-27T06:48:42Z2023-07-06T13:38:03Z<h1>Disclaimer</h1>
<p>This challenge also exists in <a href="https://codegolf.stackexchange.com/questions/64198/99-bottles-of-beer">CGCC</a>, but if you want to compete here (too), then hop in!</...https://codegolf.codidact.com/posts/283231A chunk of symbols is a calculation [released]General Sebast1anhttps://codegolf.codidact.com/users/541142021-08-08T21:33:40Z2023-07-06T13:36:16Z<h1>Challenge</h1>
<p>Create a program that takes input of a string and outputs an integer using the following calculation system:</p>
<ul>
<li>The string can only contain <code>+</code>, <code>...https://codegolf.codidact.com/posts/283620My house is destroyed! Can you make me one? [released]General Sebast1anhttps://codegolf.codidact.com/users/541142021-08-20T06:34:24Z2023-07-06T13:33:43Z<h1>Background</h1>
<p>I went on an adventure<br>
Grabbed resources and making deeds<br>
Like start to work on the materials<br>
To build the shelter I need</p>
<p>It was a marvelous one<br>
...https://codegolf.codidact.com/posts/283649Make my value binary [released]General Sebast1anhttps://codegolf.codidact.com/users/541142021-08-23T06:35:41Z2023-07-06T13:33:05Z<h1>Challenge</h1>
<p>What do computers understand? That's right, binary. All files are turned into binary digits when you run them, but what if I suggest giving you an <code>int</code> then turn ...https://codegolf.codidact.com/posts/283858Stairs? Stairs! Stairs. [released]General Sebast1anhttps://codegolf.codidact.com/users/541142021-08-31T07:20:29Z2023-07-06T13:32:37Z<h1>Challenge</h1>
<ul>
<li>Make a program that takes input of an integer that's $n > 1$ and print out a staircase using a specific character for stair basing (hashes (<code>#</code>) for demo...