Create a spiral output from a .txt file

Create a spiral output from a .txt file
0

#1

Hi free code camp please help solving this problem

I have a sample text file name spiral.txt and the sample contents is
3
124
567
098
4
1234
5678
9012
2
12
4


Thats is the sample input on the text file and when i open it the sample output will be
Output 1: 124789056
Output 2: 123482109567
Output 3: 124

Thats the output spiral order on the input provided in the text file
Please help with this thanks a lot i hope i can i have a positive feed back.


#2

Firstly, welcome to the forums.

While we are primarily here to help people with their Free Code Camp progress, we are open to people on other paths, too. Some of what you are asking is pretty trivial in the Free Code Camp context, so you might find that if you’re not getting the instruction and material you need in your current studies, the FCC curriculum will really help you get started. At a modest guess I’d say investing a 4-5 hours working through the curriculum here will really pay off. You can find the curriculum at https://freecodecamp.org.

With your current questions, we don’t have enough context to know what you already know or don’t know, so it is impossible to guide you without just telling you the answer (which we won’t do).

It is pretty typical on here for people to share a codepen / jsfiddle example of what they have tried so that anyone helping has more of an idea of what help is actually helpful.

Please provide some example of what you’ve tried and I’m sure you’ll get more help.

Happy coding :slight_smile:


#3

I first assumed the 3 (first row), 4 (5th row), and the 2 (9th row) indicated the number of digits of the following numbers, but the last two rows contain a two digit number (10th row) and a 1 digit number (4). Is there anything else you can tell us about those numbers and what they are supposed to indicate?


#4

The 3 4 and 2 i gues its indicate as the number of rows per line the 2 represent two lines …
For example i want to run it in php code the output would be spiral order like spiral matrix but the inputs are coming from the spiral.txt

Like for example i open the i dont realy sure if its the right syntax

$filecontents = fopen(“spiral.txt”,“r”);
And then when the file contents got extracted i will createva function that would output in spiral order
Example:

sample output will be
Output 1: 124789056
Output 2: 123482109567
Output 3: 124


#5

The number 4 only has 3 lines after it, so that does fit your explanation. You said “I guess”. Where did this problem originate? Is this a homework assignment?


#6

Oh im sory it should 4 any just put down any number that 4 digits on to make it 4 lines


#7

I am trying to figure out this one on how to make a program the run that output from a spirtal.txt


#8

I hope can help me with this thanks alot man