Resource

From Esolang
Jump to: navigation, search

Resource ([Re]stricted [source]) is a queue-based EPL created with restricted source challenges in mind and tries its best to make them trivial. It currently sucks at these challenges though.

Print 2014 without any numbers in your source code

['\x14', '\x0e']
Or the real program:
��

Explanation

��# Push the ord codes 14 and 20 onto the queue
# Output the resulting queue

For other years, just type in the ord code.

All characters that are not in the range 32-127 will be implicitly outputted as a number. However, you may change the outputting scheme by using .; if this character is implicitly outputted as a number, output as a character, and vice versa.

Useful Instructions (I am not sure whether they are useful in restricted source contests though)

<: Duplicate the front item of the queue and roll back.
>: Rollback the front of the queue to the back.
+: Pop two items (a&b) in the front and push a+b into the back of the queue.
-*/%: Like +, just supports the whole set of operations.
=== Definitely useful ===
:: Low-map the instructions. This does not affect +-*/% and <.
=: Has the queue changed in the most recent operation? Returns 0 or 1. (low-map: check equality of the front of the queue items)
(: Is the current queue's dictionary value larger than the previous value? Returns 0 or 1. (check less-than of the front of the queue items)
): Similar to (, but with reversed operands.
E: Map the next instruction to the whole queue.

Idea

  • Abstraction level 3 The history of the queue. The queue changed [1 2 3] -> [3 1 2]. Now apply +. [4 3 5]
  • Abstraction level 2 The whole queue. [1 2 3]. Apply +. The queue is now [6].
  • Abstraction level 1 2 items on the queue. [1 2 3]. Apply +. The queue is now [5 1].

The rollback abstraction is like this.

  • Abstraction level 3 The history of the queue. The queue changed [1 2 3] -> [3 1 2]. Now apply >. After rolling back, the whole history will be [3 1 2] [1 2 3] (assuming you haven't done anything else), and the queue will be [1 2 3].
  • Abstraction level 2 The whole queue. [1 2 3]. Apply >. The queue is now [3 1 2].
  • Abstraction level 1 2 items on the queue. [1 2 3]. Apply >. The queue is now [1 3 2].

The abstraction for all operations will be level 2 by default; they may be modified using specific operators. (More 2-byte commands.)

When you lift the abstraction level to 3, you use the abstraction operator. When you lower the abstraction level to 1, you use the distraction operator. (The language gets distracted from other items of the queue to the top 2 items of the queue. Get it?)

DISARM THE B.O.M.B.!

@R@ASSW@T@RDZ+@2@1~

Explanation:

@/): Reverse the keyboard.
@
 R@ASSW@T@RDZ+@2@1~
@                   Reverse the keyboad
 E                  Type P
  @                 Reverse the keyboard
   ASSW             Type ASSW
       @            Reverse the keyboard
        T           Type O
         @          Reverse the keyboard
          RD        Type RD
            Z       Left shift & push the next instruction
             +      Type _
              @     Reverse the keyboard
               2    Type 0
                @   Reverse the keyboard
                 1  Type 1
                  ~ Reverse the whole thing (queue) around
Implicit output (all are printable)

I am a palindrome. Are you?

<Input Here>~=~

Explanation

<Input Here> Push the input onto the queue
~  Reverse the queue
 = Equality check. Check the current state of the queue against the
   previous state of the queue and push the result to the
   back of the queue. In order to check two front items of the queue,
   you have to use the := command. : is an operator modifier that
   low-maps an instruction, making sure that the effect is smaller.
  ~  Reverse the queue. Since the result is either 0 or 1, the reverse
     does not affect the result of the queue.
 The queue is implicitly outputted.

Salary program

4 bytes → $353'553

š<$

Explanation:

š#   Push 353 onto queue.
 <#  duplicate & rollback.
  $# Push $ onto the queue(this is not an instruction)
# Resulting in the output $353353.

Proper Quine

4 bytes

Cheating quine: Q
Proper quine: (X#?
Explanation.
(X   Push constants to-be-converted onto queue.
  #  Output the whole queue
   ? Keyboard-convert the whole queue
Implicit output

Cat program

## [Resource](https://github.com/A-ee/res), 1 byte
You should really avoid solving questions like this unless this is very suitable for it.

You will need to escape all every command in the string. The procedure is simple: prepend every character with a \ and it will escape it automatically.
```
<input here>~
```
## Explanation
Since Resource does not have input instructions, the input is hard-coded into the source file. Then, the source file hard-codes the string to the queue. Then, the ```~``` instruction reverses the queue and hard-codes it to standard output. (The queue will reverse the string by default.)

Since I can't access TIO at the moment, I can't post a TIO link.

TODO! Add string syntax to Resource

Print And she said, 'But that's his.'
And she saidyc yaBut thatyas hisyxya

yayxsih syataht tuBya ycdias ehs dnA

I chose y because it is an unfrequent enough letter that is in the center of the keyboard.

https://codegolf.stackexchange.com/questions/179332/this-aint-it-chief

## [Resource](https://github.com/r-es/res/), 20 bytes
```
.feihC ti t'nia sihT
```
I currently don't have access to TIO. I will add a link as soon as possible later.

>[Draco18s](https://codegolf.stackexchange.com/questions/179332/this-aint-it-chief?rq=1#comment433131_179332): As for the challenge itself, I don't think any language can work with that instruction set except by sheer coincidence
This is another such coincidence; Resource's instruction set is so minimal that almost every ASCII character pushes itself onto the queue.

Version 1

After version 0, add support for radation-hardening challenges... I have never solved these kind of challenges before, therefore it might be a bit challenging to support.

Implementation