Groups | Search | Server Info | Login | Register
Groups > comp.lang.c > #391428
| From | Tim Rentsch <tr.17687@z991.linuxsc.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: OT: CSES Number Spiral algorithm |
| Date | 2025-03-20 11:38 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <861puro8dh.fsf@linuxsc.com> (permalink) |
| References | <vrhgqd$3ku1m$2@dont-email.me> |
DFS <nospam@dfs.com> writes: > I don't have a C question, but rather I'd like input about algorithmic > approaches. > > https://cses.fi/problemset/task/1071 > > It's an 'infinite grid'. You have to find the value at rows-columns > from 1 to 10^9. > > First thing you notice about the 5x5 grid is the values in > odd-numbered columns begin with the square of the column number, and > the values in even-numbered rows begin with the square of the row > number. > > I followed the number pattern and built a grid in Excel and expanded > it to 10x10 for more testing. > > https://imgur.com/x4VymmA > > Then coded 4 conditions solution > 1. row <= col and col odd (col * col) - row + 1 > 2. row <= col and col even ((col-1) * (col-1)) + row > 3. row > col and row odd ((row-1) * (row-1)) + col > 4. row > col and row even (row * row) - col + 1 > > My full C code submission was accepted the first time. > > How would you have done it? This posting is not appropriate for comp.lang.c. Putting "OT" in the subject line doesn't excuse its lack of suitability.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar
OT: CSES Number Spiral algorithm DFS <nospam@dfs.com> - 2025-03-20 12:47 -0400
Re: OT: CSES Number Spiral algorithm Richard Heathfield <rjh@cpax.org.uk> - 2025-03-20 18:02 +0000
Re: OT: CSES Number Spiral algorithm DFS <nospam@dfs.com> - 2025-03-23 12:30 -0400
Re: OT: CSES Number Spiral algorithm Richard Heathfield <rjh@cpax.org.uk> - 2025-03-24 04:15 +0000
Re: OT: CSES Number Spiral algorithm Kaz Kylheku <643-408-1753@kylheku.com> - 2025-03-20 18:32 +0000
Re: OT: CSES Number Spiral algorithm DFS <nospam@dfs.com> - 2025-03-21 16:54 -0400
Re: OT: CSES Number Spiral algorithm Kaz Kylheku <643-408-1753@kylheku.com> - 2025-03-22 01:55 +0000
Re: OT: CSES Number Spiral algorithm Tim Rentsch <tr.17687@z991.linuxsc.com> - 2025-03-20 11:38 -0700
Re: OT: CSES Number Spiral algorithm Richard Heathfield <rjh@cpax.org.uk> - 2025-03-20 20:07 +0000
Re: OT: CSES Number Spiral algorithm Tim Rentsch <tr.17687@z991.linuxsc.com> - 2025-03-20 13:10 -0700
Re: OT: CSES Number Spiral algorithm Richard Heathfield <rjh@cpax.org.uk> - 2025-03-21 03:40 +0000
Re: OT: CSES Number Spiral algorithm Tim Rentsch <tr.17687@z991.linuxsc.com> - 2025-03-20 23:52 -0700
Re: OT: CSES Number Spiral algorithm DFS <nospam@dfs.com> - 2025-03-20 16:54 -0400
Re: OT: CSES Number Spiral algorithm Tim Rentsch <tr.17687@z991.linuxsc.com> - 2025-03-20 16:52 -0700
Re: OT: CSES Number Spiral algorithm DFS <nospam@dfs.com> - 2025-03-20 20:26 -0400
Re: OT: CSES Number Spiral algorithm Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2025-03-20 18:49 -0700
Re: OT: CSES Number Spiral algorithm "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2025-03-21 14:18 -0700
Re: OT: CSES Number Spiral algorithm DFS <nospam@dfs.com> - 2025-03-20 20:45 -0400
csiph-web