[Community Puzzle] 1D Spreadsheet

You can send it to me in PM, I’ll have a look.

2 Likes

ummm I hope you see this but Im having trouble understanding exactly whats included in each arg for example in test case 1 I placed each individual letter of arg2 int an array when I printed it instead of seeing $0_4 which is what the example says instead all it prints is _4
any advice or mistakes Im making in basic understandiong?

You said you cannot print “$0” after reading it from input? It depends on what language you are using and how you are printing. You can paste your very brief code involving only reading input and echoing the data, for the community to better understand what’s wrong.

1 Like

Apparently my codes instead go to reference, for example ADD $27 $83, it add directly 27 + 83. It’s weird that I got the all tests including the final test “Birecursion” correct except the two “Accounting is hard”. Can anyone please help to look at my codes? (I’ll send you a link)
Thanks a lot!!!

@BouteBoute I’ll have a look if you send it to me in PM.

1 Like

Attempt #1: Using loops I hit the processing time exceeded on 11,12,13.

Attempt #2: Super fast with recursion, hit Maximum call stack size exceeded.

:persevere:

@HexaDonut The solution to your problems is already mentioned many times in this forum.

I solved all the tests, but my code can’t pass the validator 13 and i get 92%.
I have no idea why. Maybe someone had the same problem? Maybe someone knows what is the difference between test 13 and validatror 13? (Deep Birecursion)

MY Code work for all Cases Except Last Case it gives me time out

that is my code
Even i can’t open solutions that people done before
that is very bad from website

using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;

/**
 * Auto-generated code below aims at helping you parse
 * the standard input according to the problem statement.
 **/
class Solution
{
    static string[] inputs;
    static void Main(string[] args)
    {
      
        int N = int.Parse(Console.ReadLine());
      inputs = new  string[N]; 
        for (int i = 0; i < N; i++)
        {
     inputs[i]= Console.ReadLine();
            
          
        }
        
        for (int i = 0; i < inputs.Length; i++)
        {
          Console.WriteLine(  OperationBehaviour(inputs[i].Split(' ')[0], inputs[i].Split(' ')[1], inputs[i].Split(' ')[2]));
        }

    }

    static int OperationBehaviour (string Operator , string arg1 , string arg2)
    {
        string arg1b = string.Empty;
        string arg2b = string.Empty;
        
        if (arg1.Contains("$") )
        {
            for (int i = 0; i < arg1.Length; i++)
            {
                if (char.IsDigit(arg1[i]))
                    arg1b += arg1[i];
            }

            arg1 =       ResultOfSpecificCell(int.Parse(arg1b)).ToString();
           

        }
         if (arg2.Contains("$"))
        {
            for (int i = 0; i < arg2.Length; i++)
            {
                if (char.IsDigit(arg2[i]))
                    arg2b += arg2[i];
            }
            arg2 = ResultOfSpecificCell(int.Parse(arg2b)).ToString();

        }
        switch (Operator)
        {
            case "VALUE":
                return int.Parse(arg1);
            case "ADD":
                return int.Parse(arg1) + int.Parse( arg2);
            case "SUB":
                return int.Parse(arg1) - int.Parse( arg2);
            case "MULT":
                return int.Parse(arg1) * int.Parse(arg2);
            default:
                return 0;
        }
     
    }
   static int ResultOfSpecificCell (int CellIndex)
    {
        

        return OperationBehaviour(inputs[CellIndex].Split(' ')[0], inputs[CellIndex].Split(' ')[1], inputs[CellIndex].Split(' ')[2]);
        
    }
}

Reference $ref: If an argument starts with a dollar sign, it is a interpreted as a reference and its value is equal to the value of the cell by that number ref, 0-indexed.
For example, “$0” will have the value of the result of the first cell.

i don’t understand what is the meaning ??

$X is equal to the value of the cell number X (The first cell has number 0, the second number 1, the third number 2, the fourth number 3…)

Example: If the value of the first cell is 4, the value of the second cell is 27 and the value of the third is -3. Then:
$0 = 4
$1 = 27
$2 = -3

The first Testcase is:

2
VALUE 3 _
ADD $0 4

That means:

The value of the first cell is 3.
$0 = the value of the first cell = 3
ADD $0 4 = ADD the value of the first cell 4 = ADD 3 4 = 7

Do you understand it now?

1 Like

thx :pray:

I agree, I have 9 passed, I can do extra loop with if statment to check missing values, but later is even harder, I think that this test should go to medium games.

The puzzles categories are indicative, since the same thing will not appear to be of the same difficulty to different persons. So don’t take it too seriously.
If you want some help, can you expose your exact problem ?

1 Like

Now I rewrite whole program and I use struct to use ass the cell.
I figure out everything, and I passed 12 test.
Now I have problem with last 13, where I have 10 digits and i get some error with calculations because:
Found: 2130706304
Expected: 2130706432
last 3 digits are not equal. I check some data and that smaller ones are correct, only when I get to 10 digits, there are happening something strange.
Maybe I mist something?

YES! I have right, before I was using float, assuming that numbers will be with floating piont, but answares wass alll the time ass integers.
In my function I forget change float to long.
Hurra, I passed all test! :smiley:

I did use

struct Cell{ 
    bool answareON = 0;
    int answare = 0;

    string operation;

    bool reference1 = 0;
    int arg1 = 0;

    bool reference2 = 0;
    int arg2 = 0;
};

ass representation of a cell. When answare was 0, it go to the next row. If arg1 and arg2 find answare = 1, then next calculation was made.

Hi! I worked on it with Java… it took me nearly 5h and 300 lines to resolve it xDD Well it’s fast and don’t have problems, but I’m not sure it’s very optimized… Is there a solution somwhere that I can look at to compare with my code?

Thanks by the way, it was very entertaining to solve it =)

Hey !
When you solve a puzzle in a language, you can see others solutions in this language.
There’s a “solutions” tab on the puzzle’s page, and you can also access them from the IDE in the “results” tab.

2 Likes