#Code Golf

0 Followers · 18 Posts

InterSystems IRIS edition of the code golf is a type of recreational computer programming competition in which participants strive to achieve the shortest possible source code that solves a certain problem using the ObjectScript language.

InterSystems staff + admins Hide everywhere
Hidden post for admin
Discussion Alex Woodhead · Apr 12

There is a list of numbers from 1 to 190.

AllList="1,2,3,4,5,6,7,8,9,.....,187,188,189,190"

There is a collection of sets of these values:

List(1)="3,5,6,7,9"
List(2)="1,2,6,9"
List(3)="5,8,9"
List(4)="2,4,6,8"
List(5)="4,7,9"

What is an elegant approach in Object Script to pick the least number of list items:

  • List(1)
  • List(5)
  • List(n)

That together would cover as many numbers as possible from the AllList.

Interested in best coverage over efficiency.

0
0 0
Discussion Eduard Lebedyuk · Feb 13

It's been a while (and everyone is well-rested after Advent Of Code!) so let's run another round of Code Golf.

Your task is navigating in a grid-like labyrinth in a clockwise spiral pattern. As it traverses the matrix, it collects characters, revealing a secret message. Your challenge: find the shortest, most elegant code to decode this spiral cipher. Input:

  1. A multidimensional string array with comma separated characters (n x n)
  2. Starting coordinates X and Y

Output: The decoded message as a single string

Constraints:

0
0 0
Discussion Eduard Lebedyuk · Aug 5, 2024

Today we have an unusual code golf: build a program (using only printable ASCII characters, tabs and newlines) that prints out exactly the characters in the printable ASCII space (characters 32 to 126) that don't appear in your program's source code (in any order, however many times you want).

As usual, the goal is to produce the shortest code to do this.

My (admittedly not very good, but does the job!) entry:

Classascii.ascii {

ClassMethodascii()
{
    setx="!#$%&'()*+,-./0123456789:;<>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdfghijklmnopqruvwyz{|}~"
}

}
0
0 0
Discussion Eduard Lebedyuk · Jan 26, 2024

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. Should consider letters from A to Z, doesn't distinguish between upper/lowercase characters. Numbers are allowed, and any punctuation should be ignored.

Input

"Example"

Output

"339926755533"

Note

18
1 499
Discussion Eduard Lebedyuk · Oct 20, 2023

Let's do a round of code golf! Last one was very popular!

The Chinese zodiac is a repeating cycle of 12 years, with each year being represented by an animal and an element that changes every 2 years.
The animals are: Rat, Ox, Tiger, Rabbit, Dragon, Snake, Horse, Goat, Monkey, Rooster, Dog and Pig.
The elements are: Wood, Fire, Earth, Metal and Water.
Your task is to write a function that receives a year, and returns the element and the animal that year represent.
Let's use the year 1924 as start point, in the Chinese zodiac the element was Wood and the animal was Rat.

Input

2023

Output

"Water Rabbit"
7
0 593
Discussion Eduard Lebedyuk · Jul 28, 2023

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.

37
0 718
Discussion Eduard Lebedyuk · Mar 2, 2023

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!

11
0 372
Article Eduard Lebedyuk · May 18, 2023 2m read

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.

Input

"hello", "llohe"

Output

3

  ​

Note

Rules

14
0 418
Discussion Eduard Lebedyuk · Nov 9, 2022

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

13
0 627
Discussion Eduard Lebedyuk · Jul 1, 2022

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

You'll have to translate a string into a LeetSpeak. As usual shortest solution wins.

##Input "Listen"

##Output 1|573n

##Note

8
0 590
Discussion Eduard Lebedyuk · Nov 17, 2021

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.

Task

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"

Note

8
2 634
Discussion Eduard Lebedyuk · May 3, 2022

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

You will receive two strings returning true if the two arguments given are anagrams of each other. As usual shortest solution wins.

##Input "Listen", "Silent"

##Output 1

##Note

33
0 662
Discussion Eduard Lebedyuk · Mar 4, 2022

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

##Note

Rules

  1. The signature of the contest entry MUST be:
4
1 364
Discussion Eduard Lebedyuk · Feb 2, 2022

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

##Note

Rules

  1. The signature of the contest entry MUST be:
34
0 780
Discussion Eduard Lebedyuk · 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.

Task

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:

11
0 493
Discussion Eduard Lebedyuk · Aug 16, 2021

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

Wikipedia.

How about a fun challenge?

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:

15
0 586