﻿ Code Golf | InterSystems Developer Community
By update

Multi-tap or multi-press is the name given to the historic technique of writing SMS on the first mobile phones with a keyboard of 10-12 numeric keys.
For example, to type `LOL` you need to press `5` three times, `6` three times and `5` three times again.
Your task is to write a function that takes a string as input and returns the repeated digits associated with each character according to the multi-tap system.

5
1 309
Discussion
· Jul 28, 2023
Code Golf: Parenthesis

Our previous code golf ended with an overwhelming win, so now it's time for another one.
Parenthesis Hell is a Lisp-like esoteric programming language(esolang).
As a Lisp-like language, the code consists only of nested matched pairs of opened and closed parenthesis.
Your task is to write a method that receives a string of parenthesis and returns `1` if the order of the parenthesis is valid. For example, the string of parenthesis `(())()` is valid because it contains a matched pair of opened and closed parenthesis at each position. The string `()((())))` is not valid because it contains one unmatched parenthesis.

5
0 604
Discussion
· Mar 2, 2023
Code Golf: Isogram

It's time for a Code Golf round!

Isogram

A word or phrase that has no repeating letters, consecutive or non-consecutive.

Implement a method that checks if the received string is an isogram or not.
Assume the empty string is an isogram.
Ignore the letter case.

Allowed inputs: A-Z, a-z.

As usual, the shortest solution wins!

4
0 297
Article
· May 18, 2023 2m read
Code Golf: String Rotations

Let's have a round of Code Golf!

String rotation is when you take a word and move some of its letters to the end of the word, so the first letter becomes the second letter, the second letter becomes the third, and so on. Last letter becomes first. Rotation can happen only in one direction →.
Your task is to write a method that will receive two strings. It then must return an integer value of how many times needed to rotate the strings to be equal.
As usual shortest solution wins.

4
0 314
Discussion
· Jan 20, 2023
Code Golf: Pyramid

New Year, new Code Golf!

You will receive a positive integer for the `number of floors`. Your challenge will build a pyramid with a `"#"` character. As usual, the shortest solution wins.

`3`

## Output

``````  #
###
#####
``````

also a valid output

``````  #
###
#####
``````
4
1 406
Discussion
· Nov 9, 2022
Code Golf: Word Order

We're back with a code golf!

You will receive a string. Each word in the string will contain a number.
This number is the position that word should have in the sentence.
If the input string is empty, return an empty string.
The output can only be in words, without the given numbers.

## Input

`"i2s T1his Te4st a3"`

## Output

`This is a Test`

2
0 563

Leet (or "1337"), also known as eleet or leetspeak, is a system of modified spellings used primarily on the Internet. It often uses character replacements in ways that play on the similarity of their glyphs via reflection or other resemblance. Additionally, it modifies certain words based on a system of suffixes and alternate meanings. There are many dialects or linguistic varieties in different online communities. Wikipedia

3
0 493
Discussion
· Nov 17, 2021
Code Golf - Encoder

We need to send some coordinates to a spaceship through a laser beam.
To do that we have to encode it, and beam it out into space.
Your mission is to implement the encoder with a compression standard.
As usual shortest solution wins.

You will receive a string of comma-separated integers and you will return a new string of comma-separated integers and sequence descriptors.

## Input

`"0,2,4,5,5,5,5,5,3,4,5"`

## Output

`"0-4/2,5*5,3-5"`

4
2 559
Discussion
· May 3, 2022
Code Golf: Anagram Detector

An anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.
For example, the word anagram itself can be rearranged into nag a ram, also the word binary into brainy and the word adobe into abode. Wikipedia

4
0 549
Discussion
· Mar 4, 2022
Code Golf: Label Validation

New month, new code golf!

You will receive a string with a label code with numbers and letters.
Our challenge is to check if this code begins with 1, 2, or 3 and ends with A, B, C, S, or R.
It should return true(1) if so or return false(0) otherwise.
As usual shortest solution wins.

## Input

`"198739A79D9R"`

## Output

`1`

6
1 300
Discussion
· Feb 2, 2022
Code Golf: Paired Opposites

You will receive a string of comma-separated integers whose elements have both a negative and a positive value, except for one integer that is either only negative or only positive, our challenge will be to find that integer.
As usual shortest solution wins.

## Input

`"1,-1,2,-2,3"`

## Output

`3`

`3` has no matching negative appearance

4
0 673
Discussion
· Oct 8, 2021

Have you ever seen those vaccum compressed towels, that look like a pill and after you add water became a towel?

That's our challenge for today. As usual shortest solution wins.

You will receive an integer number and you will return a new number where each digit is repeated a number of times equals to its value.

Input:

`42`

Output:

`444422`

Note:

3
0 416

A quine is a computer program which takes no input and produces a copy of its own source code as its only output.

The task is to write a quine in InterSystems ObjectScript. It can be a class, or a method, or a routine, or just a line to be executed in a terminal. You decide!

Here's some resources you might consider useful:

Hard mode: do not use source code access functions.

Here's my (extremely uninspired, I know) attempt:

``````Class User.Quine
{

/// do ##class(User.Quine).Test()
ClassMethod Test()
{
set sc = ##class(%Compiler.UDL.TextServices).GetTextAsString(\$namespace, \$classname(), .str)
write str
}

}``````

It produces this output:

How many different ways of producing a quine are there in ObjectScript?

9
0 484