Board Logo
« Hiding in plain sight »

Welcome Guest. Please Login or Register.
Oct 17th, 2017, 3:14pm


Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Please use the forums Search feature before asking.
Please post code using the code box described in Format Your Messages.
This will keep indentation, separate it better form the message and prevent gibberish.
If the code is too long for one post or additional files are needed, upload a ZIP archive to the Just BASIC Files Archive Site.

« Previous Topic | Next Topic »
Pages: 1 2  Notify Send Topic Print
 veryhotthread  Author  Topic: Hiding in plain sight  (Read 559 times)
bplus
Senior Member
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1180
xx Hiding in plain sight
« Thread started on: Jul 17th, 2017, 09:01am »

Code:
done



                                ?
                                sG IN PLAIN SIG
                                iNa dream abouH
                                hI of hiding tT
                                tDd John T ts
                                 Iat threadotdC
                                oHhcd  Bas uuoa
                                d  engeInibcfin
                                 !Ijanht cohfn
                                os b idoc te ga
                                ti.u37hst hdi n
                                 hts eht no nsy
                                ethgis nialp oo
                                d ekil gnihtemn
                                oc etirw esle e



 
User IP Logged

B+
tsh73
JB-Supporter


member is online

Avatar




PM

Gender: Male
Posts: 3558
xx Re: Hiding in plain sight
« Reply #1 on: Jul 17th, 2017, 3:36pm »

I didn't read that yet but I have something to say:
Code:
 ne is a long an
 ig to Alice, ad
 Mn certainly,n
 “i,n with wo'da
  nlw tail; n
  riosou ca'dsss
  uad'yad?lbeaia
  tt e s ”lurigd
    gso ti t dh
  ,gnud yhw a it
  enioM eht tAna
  sokool ,ecilgl
  ul a si tI' .e
  oM eht dias '!
 

Code:
a$="”?das ti llac uoy od yhw tub' ;liat s'esuoM eht ta rednow htiw nwod gnikool ,ecilA dias ',ylniatrec ,liat gnol a si tI' .gnihgis dna ,ecilA ot gninrut ,esuoM eht dias '!elat das a dna gnol a si eniM“"
L=len(a$)

cx=10:cy = 10
x=cx:y=cy
'directions
'up left down right
dim dx(4), dy(4)
for i =1 to 4
    dx(i)=val(word$("0 1 0 -1",i))
    dy(i)=val(word$("-1 0 1 0",i))
next
dir = 1

maxL=1
ll=0
for i = 1 to L
    c$=mid$(a$,i,1)
    locate x, y: print c$: ll=ll+1
    call pause 100
    x=x+dx(dir)
    y=y+dy(dir)
    if ll>=maxL then
        dir=dir-1
        ll=0
        maxL=maxL+.5    '??
        if dir <1 then dir = 4
    end if
next

sub pause mil
    t0=time$("ms")
    while time$("ms")-t0<mil
        scan
    wend
end sub
 
« Last Edit: Jul 17th, 2017, 3:39pm by tsh73 » User IP Logged

Q: "And if I took your codes and compile them, and sell them for a profit"?
A: Go ahead. I had my share of good then I coded it for fun, if you can make better use of it - please do.
(enjoying JB 1.01 on WinXP, netbook and desktop)
bplus
Senior Member
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1180
xx Re: Hiding in plain sight
« Reply #2 on: Jul 17th, 2017, 4:37pm »

I wondered if something like this was done before.

But no wonder who replied first! wink

(Edited typos)
« Last Edit: Jul 17th, 2017, 4:40pm by bplus » User IP Logged

B+
tenochtitlanuk ( John F)
Full Member
ImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 421
xx Re: Hiding in plain sight
« Reply #3 on: Jul 17th, 2017, 5:41pm »

Modified a few lines of my ( Rosetta Code) spiral number matrix program.

Writing in spirals makes a kind of sense to those of us who grew up with 45's and LP's.
User Image
Easily modified to spiral anti-clockwise or clockwise, and in or outward...
User IP Logged

Visit my LB/JB pages at http://www.diga.me.uk/index.html
I use XP and Ubuntu Linux on old machines!
bplus
Senior Member
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1180
xx Re: Hiding in plain sight
« Reply #4 on: Jul 17th, 2017, 6:33pm »

Hi John,

Have you adopted a sin and cos method typically used with spiral writing?

My code is like tsh73 working in lines for a distance and then methodically switching directions, not quite as elegant.



To all,

I am now considering how to reverse the code, to take a block of letters and print out a normal text string from it.

Maybe you guys have worked that out already as well? I always feel like I arrived late for the party here. wink

I don't know how to search the forum for that, what would you call it? But yeah, I can ask you all. wink
User IP Logged

B+
tenochtitlanuk ( John F)
Full Member
ImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 421
xx Re: Hiding in plain sight
« Reply #5 on: Jul 18th, 2017, 05:13am »

For this one I added half a dozen lines to my solution of Rosetta Code which uses the change-of-direction method.

Also relevant are... Going in circles and Wavy text which include sin/cos method.

Don't feel bad or that you are 'coming late to the 'party'. In some ways I've come to enjoy that feeling- eg I try to solve tasks in LB but if I get into difficulty I search hard first in LB/JB for 'prior work', and then in other languages i have some familiarity with. That's part of why several of us recommend trying Rosetta Code tasks, and why I haven't always posted my solutions- leave them for others to have the fun I had!

Searching the forums tends to be better done in a general search engine like Google, but specifying site: as the conforum. The forum's own serch engine is not very good.

re code for unravelling -for this kind of sequenced text it is straightforward IF you know the pattern used- spiral, zigzag or w.h.y. Doing it programmatically I guess you'd have to try to find words by comparing with say the SOWPODS Scrabble dictionary, but then each word may bend round a corner or back under itself. Don't think I or the computer have time for it.
User IP Logged

Visit my LB/JB pages at http://www.diga.me.uk/index.html
I use XP and Ubuntu Linux on old machines!
bplus
Senior Member
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1180
xx Re: Hiding in plain sight
« Reply #6 on: Jul 18th, 2017, 10:54am »

Thanks John,

So Rosetta calls these examples of the Spiral Matrix. But it appears they only start on the outside and work inward.
That would be easy to reverse, I think, specially if always start at top left corner.

"Going in circles" does look exactly like what I started this thread with, but I see why I missed it, posted at Liberty which I look into from time to time but not thoroughly. Great minds think alike! I have heard stories of simultaneous invention, Calculus a famous one.

"Wavy text" from here, I did check out and that was sin / cos stuff.

Thanks for the searching tip, I am not experienced in advanced searches, you can do them by site?! very interesting. I think it OK to reinvent wheel, but less OK to post stuff already talked about, unless maybe it's been years and years.

What is w.h.y, pattern?

My thinking for generic string straightener was for spiral matrix both inside out or outside in, clockwise or counterclock wise, backwards and forwards..

tsh73, I think started the sequence differently, y up then x right then y down then x left. I did x right, y down, x left, y up.

So brute force general solver for inside out has 8 variations? I think. 4 choices for first direction and then 2 directions on 2nd step.

Outside in, also 8, which outside edge to start and then which direction to go.

General straightener for Spiral Matrix patterns is doable, I think. A computer could whip up 16 alternates to choose almost as easily as one. But coding it would be fun if you like that sort of thing. wink

User IP Logged

B+
tenochtitlanuk ( John F)
Full Member
ImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 421
xx Re: Hiding in plain sight
« Reply #7 on: Jul 18th, 2017, 11:24am »

w.h.y. means 'what have you', ie any other variations the reader may be aware of. In UK at any rate...
User IP Logged

Visit my LB/JB pages at http://www.diga.me.uk/index.html
I use XP and Ubuntu Linux on old machines!
bplus
Senior Member
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1180
xx Re: Hiding in plain sight
« Reply #8 on: Jul 18th, 2017, 11:29am »

Hi,

Some further thinking about general Spiral Matrix straightener:

Finding the center for inside out can be tricky, so why not use just outside in and reverse the string found for inside out?
Eliminates finding center and 8 alternate courses from there.
User IP Logged

B+
tsh73
JB-Supporter


member is online

Avatar




PM

Gender: Male
Posts: 3558
xx Re: Hiding in plain sight
« Reply #9 on: Jul 19th, 2017, 09:41am »

Attempt to read stuff
You click on black letter, it starts reading up-left-down-right-up until it can, painting letters red, printing a line in a mainwin.
Then you click another black letter
(really needs an UNDO)
Anyway.
I've got
Code:
HIDING IN PLAIN SIGHT Can anyone else write code to do this
I had a dream about doing something like this!
of hiding stuff in plain sight.
 John T touched on the subject
 thread both tsh73 and
  Basic coding
In the
 


EDIT obviously line order is wrong.

with this program
Code:
'15x14
W=15:H=14
data "sG IN PLAIN SIG"
data "iNa dream abouH"
data "hI of hiding tT"
data "tDd John T ts  "
data " Iat threadotdC"
data "oHhcd  Bas uuoa"
data "d  engeInibcfin"
data " !Ijanht cohfn "
data "os b idoc te ga"
data "ti.u37hst hdi n"
data " hts eht no nsy"
data "ethgis nialp oo"
data "d ekil gnihtemn"
data "oc etirw esle e"

'directions
'up left down right
dim dx(3), dy(3)
for i =0 to 3   'from 0 to use MOD
    dx(i)=val(word$("0 1 0 -1",i+1))
    dy(i)=val(word$("-1 0 1 0",i+1))
next

'read data
dim c$(W,H), u(W+1,H+1) 'so 0 is "not awailable"
'set "used" bit
for j = 1 to H
    read a$
    for i = 1 to W
        c$(i,j)=mid$(a$,i,1)
        u(i,j)=1
    next
next

for j = 1 to H
    for i = 1 to W
        print c$(i,j);
    next
    print
next

open  "test" for graphics_nsb_nf as #gr
#gr "down"
#gr "trapclose [quit]"
#gr "font courier_new 10"
cw=8: ch=16 'character size
restore
#gr "\"
for j = 1 to H
    read a$
    #gr "\";a$
next
#gr "flush"

#gr "when leftButtonDown [click]"
#gr "color red"

wait

[click]
    x = int(MouseX/cw)+1
    y = int(MouseY/ch)+1
    dir = 0 'starts up
    secondTime = 0
    'print x, y, c$(x, y)
    while 1
        print c$(x, y);
if x= 14 and y = 14 then
    breakpoint = 1
end if
        #gr "place ";(x-1)*cw; " "; y*ch
        #gr "\";c$(x, y);
        u(x,y)=0
        'tryAgain = 4
        'print x, y, dir, x+dx(dir), y+dy(dir), u(x+dx(dir), y+dy(dir))
        if u(x+dx(dir), y+dy(dir))=0 then
            dir = (dir+1)mod 4
        'while u(x+dx(dir), y+dy(dir))=0 and tryAgain > 0
            tryAgain = tryAgain - 1
            if dir=1 then
                if secondTime = 1 then
                    exit while 'end path
                else
                    secondTime = 1
                end if
            end if
        'wend
        end if
        'if tryAgain <= 0 then exit while 'end path
        x=x+dx(dir)
        y=y+dy(dir)
    wend
    print
wait

[quit]
    close #gr
end
 
« Last Edit: Jul 19th, 2017, 12:29pm by tsh73 » User IP Logged

Q: "And if I took your codes and compile them, and sell them for a profit"?
A: Go ahead. I had my share of good then I coded it for fun, if you can make better use of it - please do.
(enjoying JB 1.01 on WinXP, netbook and desktop)
bplus
Senior Member
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1180
xx Re: Hiding in plain sight
« Reply #10 on: Jul 19th, 2017, 11:17am »

Hi tsh73,

Of course! Put the text in data statements!
That! is where I went wrong in my first attempts trying to read from a notepad file.

Matrix is actually 15 x 15 because the first data statement should have a lonely question mark.

Code:
'm$ is for message to hide
m$ = "In the Basic coding thread both tsh73 and John T touched on the subject of hiding stuff"
m$ = m$ + " in plain sight. I had a dream about doing something like this! HIDING IN PLAIN SIGHT"
m$ = m$ + " Can anyone else write code to do this?"
 



I have an idea to a mod of your first code for doing all 16 variations of spiral matrix, clockwise, counterclockwise, inside/out, outside/in starting the reading from each corner.

Now that I've outlined it, who will code it faster?

Maybe John will want to change his Rosetta submission with a much more versatile Spiral Matrix coder, 16 ways!
4 corners X 2 directions X 2 inside/out or outside/in.
User IP Logged

B+
tsh73
JB-Supporter


member is online

Avatar




PM

Gender: Male
Posts: 3558
xx Re: Hiding in plain sight
« Reply #11 on: Jul 19th, 2017, 1:01pm »

Ha!
So it was actually written outwards?
No wonder I started inwards - outer parts of words are clearly visible.
Though if I guessed that lonely "?" was part of message I probably guessed it's a tail ;)

Here code that unwinds it inside out (I still not sure how "+.5" thing actually works)
Code:
'15x14
W=15:H=14
data "sG IN PLAIN SIG"
data "iNa dream abouH"
data "hI of hiding tT"
data "tDd John T ts  "
data " Iat threadotdC"
data "oHhcd  Bas uuoa"
data "d  engeInibcfin"
data " !Ijanht cohfn "
data "os b idoc te ga"
data "ti.u37hst hdi n"
data " hts eht no nsy"
data "ethgis nialp oo"
data "d ekil gnihtemn"
data "oc etirw esle e"

'directions
'up left down right
dim dx(3), dy(3)
for i =0 to 3   'from 0 to use MOD
    dx(i)=val(word$("0 1 0 -1",i+1))
    dy(i)=val(word$("-1 0 1 0",i+1))
next

'read data
dim c$(W,H)
for j = 1 to H
    read a$
    for i = 1 to W
        c$(i,j)=mid$(a$,i,1)
    next
next

for j = 1 to H
    for i = 1 to W
        print c$(i,j);
    next
    print
next
print

'-------------
maxL=0.5    'trial an error
ll=0
tl=0
x = 8: y = 7
dir=1
while 1
    SCAN
    c$=c$(x,y)
    print c$;
    ll=ll+1
    tl=tl+1
    if tl mod 60 = 0 then print
    call pause 100
    x=x+dx(dir)
    y=y+dy(dir)
    if ll>=maxL then
        dir=(dir+1) mod 4
        ll=0
        maxL=maxL+.5    '?? still not sure how it works
    end if
wend
end

sub pause mil
    t0=time$("ms")
    while time$("ms")-t0<mil
        scan
    wend
end sub
 


EDIT it just dies with "Subscript out of range" then text ends.
Consider it "by design" - it really should end here ;)
« Last Edit: Jul 19th, 2017, 1:08pm by tsh73 » User IP Logged

Q: "And if I took your codes and compile them, and sell them for a profit"?
A: Go ahead. I had my share of good then I coded it for fun, if you can make better use of it - please do.
(enjoying JB 1.01 on WinXP, netbook and desktop)
bplus
Senior Member
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1180
xx Re: Hiding in plain sight
« Reply #12 on: Jul 19th, 2017, 2:57pm »

Hi tsh73,

Sorry I can't leave my lonely question mark alone.

A little fix:
Code:
'15 x 15 << now
W=15:H=15:maxLimit = W * H '<< added maxLimit and adjusted H
data "?              "   '<<<<<<<< 
data "sG IN PLAIN SIG"
data "iNa dream abouH"
data "hI of hiding tT"
data "tDd John T ts  "
data " Iat threadotdC"
data "oHhcd  Bas uuoa"
data "d  engeInibcfin"
data " !Ijanht cohfn "
data "os b idoc te ga"
data "ti.u37hst hdi n"
data " hts eht no nsy"
data "ethgis nialp oo"
data "d ekil gnihtemn"
data "oc etirw esle e"

'directions
'up left down right
dim dx(3), dy(3)
for i =0 to 3   'from 0 to use MOD
    dx(i)=val(word$("0 1 0 -1",i+1))
    dy(i)=val(word$("-1 0 1 0",i+1))
next

'read data
dim c$(W,H)
for j = 1 to H
    read a$
    for i = 1 to W
        c$(i,j)=mid$(a$,i,1)
    next
next

for j = 1 to H
    for i = 1 to W
        print c$(i,j);
    next
    print
next
print

'-------------
maxL=0.5    'trial an error
ll=0
tl=0
x = 8: y = 8  '<<< y to 8 from 7
dir=1
while 1
    SCAN
    c$=c$(x,y)
    print c$;
    ll=ll+1
    tl=tl+1
    if tl >= maxLimit then end  '<<<<<< STOP IT
    if tl mod 60 = 0 then print
    call pause 100
    x=x+dx(dir)
    y=y+dy(dir)
    if ll>=maxL then
        dir=(dir+1) mod 4
        ll=0
        maxL=maxL+.5    '?? still not sure how it works
    end if
wend
end

sub pause mil
    t0=time$("ms")
    while time$("ms")-t0<mil
        scan
    wend
end sub


 


"?? still not sure how it works"

Didn't you write this? I suspect it works thanks to rounding indexes to arrays down to integer.
« Last Edit: Jul 19th, 2017, 3:03pm by bplus » User IP Logged

B+
tsh73
JB-Supporter


member is online

Avatar




PM

Gender: Male
Posts: 3558
xx Re: Hiding in plain sight
« Reply #13 on: Jul 19th, 2017, 3:07pm »

Quote:
Didn't you write this?

I wrote "+1", it made a spiral with 1-character gap.
So I tweaked it until it run - and it ends up with 0.5
Now I tried unwind - it spew wery weird texts indeed - tweaked again initial direction, initial LL - end up with initial LL=0.5.

But do I know why it works? No!

EDIT
Nice touch with maxLimit.
« Last Edit: Jul 19th, 2017, 3:12pm by tsh73 » User IP Logged

Q: "And if I took your codes and compile them, and sell them for a profit"?
A: Go ahead. I had my share of good then I coded it for fun, if you can make better use of it - please do.
(enjoying JB 1.01 on WinXP, netbook and desktop)
tsh73
JB-Supporter


member is online

Avatar




PM

Gender: Male
Posts: 3558
xx Re: Hiding in plain sight
« Reply #14 on: Jul 19th, 2017, 3:15pm »

Quote:
I suspect it works thanks to rounding indexes to arrays down to integer.


Me too.
But to *know* I should sit down and see when index adds to next integer and then not. And probably try another way, without implicit rounding.

But I'm just too lazy ^)
User IP Logged

Q: "And if I took your codes and compile them, and sell them for a profit"?
A: Go ahead. I had my share of good then I coded it for fun, if you can make better use of it - please do.
(enjoying JB 1.01 on WinXP, netbook and desktop)
Pages: 1 2  Notify Send Topic Print
« Previous Topic | Next Topic »

Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls