Skip to main content
The National Cipher Challenge

Programming

A Tale of 2 Secrets Forums T.E.M.P.E.S.T. Programming

Tagged: 

Viewing 12 posts - 46 through 57 (of 57 total)
  • Author
    Posts
  • #113068
    F6EXB_the_frenchy
    Participant

    The problem with this forum is that validated messages do not appear on the pages in the chronological order in which they are posted.
    For example, I had an incorrect message #112180, which I corrected immediately by giving the correct answer in #112183.
    This leads to Harry’s comment in the same false message and to message #112850 from byteinbits.
    112180 is on page 3, while 112183 is placed before it on page 2.

    As mentioned in the FAQs Harry will neither confirm nor deny that he has a Time Machine. The Elves

    #113177
    Robb27
    Participant

    ByteInBits #113017
    Forgive my typo transcribing the starting number which is 102564. The Pari/GP is correct.

    #113189
    ByteInBits
    Participant

    @F6EXB_the_frenchy – correct answer 🙂

    Your ‘testing code’ #113080 is not that ugly!
    My codes (and I bet others too) are usually anything but good while trying
    for a solution and when found, a rewrite is done and presented.

    And so your code #113098 is good and clear and gives the correct answer

    #113191
    ByteInBits
    Participant

    @Robb27 ***WITH DUE RESPECT YOU POSTED A CORRECTION WHILE I WAS COMPOSING THIS REPLY***
    #113175
    You Gave Answer for W, X was asked for, but it implies that your answer is correct.

    I do like to see others code, there is always a different way to code to achieve an
    answer and sometimes I think why didn’t I think of that way, always learning.

    Anyway here is my code for A RATHER LONLY NUMBER:

    \\ PARI/GP Calculator Version 2.13.3 Code
    \\ CODE – WITH UPPERCASE VARIABLES USED AS IN DESCIPTION
    {
    for(X=102,999999, \\ the range of X to check
    d=digits(X); \\ change number to a vector of its digits
    Y=d[#d]; \\ get last digit as multiplier
    if(Y==0||Y==1,next); \\ if invalid end digit (0 or 1) goto next X
    Z=X*Y; \\ compute for Z
    W=vector(#d); \\ make W a vector (with places for all digits of X)
    for(i=2,#d,W[i]=d[i-1]);W[1]=Y; \\ move X’s end digit onto front of X forms W
    W=fromdigits(W); \\ convert W back to number
    if(W==Z, \\ if W = Z then use next line to show reesult
    print(“\nANSWER : “X”\nCheck : ” X” x “Y”\n = “W)))
    }

    ANSWER : 102564
    Check : 102564 x 4
    = 410256

    #113193
    ByteInBits
    Participant

    @F6EXB_the_frenchy, ***AGAIN (YOU MADE) A POST WILE I WAS COMPOSING THIS*** (frustrating! I try to check the #number but hard to sort through)

    @F6EXB_the_frenchy, @Robb27, and any one else (and Harry who seemed a little concerned about these primes)

    With regards to truncated primes:

    Here are the 11 known L/R truncated primes
    ==========================================
    \\ PARI/GP Calculator Version 2.13.3 Code
    {
    for(i=10,999999,
    v=digits(i);ok=0;
    for(t=1,#v,x=#v-#v+t;n=fromdigits(v[1..x]);if(isprime(n),ok++));
    forstep(t=#v,1,-1,n=fromdigits(v[t..#v]);if(isprime(n),ok++));
    if(ok==#v*2,print(i))
    );
    }
    23
    37
    53
    73
    313
    317
    373
    797
    3137
    3797
    739397

    #113766
    Scarlett
    Participant

    Hi,
    I really don’t know how to code, and it seems quite daunting to start. Do I need to know how to code to be able to complete the later challenges? I’m worried after reading today’s challenge that I may really struggle without that knowledge later on. If I do need to, is it possible to learn enough quickly without burning out? I know you can’t use other people’s codes so I’m not sure where to start. Any feedback would be appreciated.

    #113781
    Crackerjack_404
    Participant

    @Scarlett

    Hi, I’d say it depends on how much experience you already have with ciphers. For a lot of the challenge, you can genuinely get pretty far without much coding at all, it’ll be slow and a bit tedious, but absolutely doable. That said, just because we can solve everything by hand doesn’t mean we should.

    My first two of years doing the Cipher Challenge I barely knew how to code, so I relied on very simple tools like:
    – reading from a text file
    – finding and replacing characters
    – String manipulation
    – frequency analysis

    You can also use a spreadsheet or any text editor to do this. But the above are just a few lines of Python each, and you can learn them as you go.

    When dealing with any programming problem, the hard part is usually knowing what to do rather than how to do it. The ‘how’ comes with time and practice, but once you know what type of cipher/problem you’re dealing with, things become more manageable.

    For example, if you’re working with a transposing cipher, you can abstract the problem by thinking of it as just picking a key length, splitting the ciphertext into rows of that length, and ordering the columns and seeing if it looks more or less like English, and making small tweaks in your row/column layout as you go along. You can do all of that using a spreadsheet without writing a single line of code. But once you understand the process of solving that cipher, you can look up how to implement something like a hill-climbing attack to automate the tweaking and speed up the decryption process.

    It’s absolutely possible to learn quickly, but it depends on how much time/energy you have to expend. I wouldn’t suggest you spend all day everyday coding as that’s a quick way to burn out. But what you can do is pick one section, like learning how to write a script to calculate IoC for a text, and do that. Consistency > Intensity. Writing your own solvers is honestly a brilliant way to learn programming, and it’s also really satisfying to see them in action!

    My team and I just worked through Madness’ book over a few months which gave us a structured way to build from decrypting simple ciphers with known keyword to writing automated solvers. There are plenty of programming tasks in that book that you can play around with.

    Challenges will inevitably get harder, and they’re deliberately designed to stretch you, confuse you, make you question your life choices, and as I’m sure other people can attest to, send you spiralling into existential dread… But that’s all part of the fun of doing something challenging like this! So do enjoy the process!

    One other important thing – you don’t need to do everything at once. It may feel daunting, so just try and focus on implementing one concept, one solver, or learning one skill at a time. Everyone starts somewhere, so if you’re not sure where to start, just start with some basics Python tasks. In terms of resources, I’m sure there will be lots of people who can recommend their favourite programming book/website. I quite like Cracking codes with Python, which is like an online textbook you can work through.

    Hope this helps!

    #113841
    Scarlett
    Participant

    @Crackerjack thank you!

    #113780
    Gen_ruikt
    Participant

    @scarlett

    im not entirely sure if its allowed but a site i think is allowed is cryptool 2 to learn coding you are not allowed the templates on their but it is possible to make your own codes which i learnt from other challenges similar to this

    To confirm: you can use anything on the web to LEARN cryptography, but you MUST NOT use deciphering tools from any site other than this one unless you write them yourself. Doing that breaks the rules, but more importantly stops you from learning how to do these things for yourself, which is a lot more fun and worth the effort. Harry

    #113779
    _madness_
    Participant

    @Scarlett, sometimes you can’t get by on the kindness of strangers.
    Try pointing your google at “Python the hard way.”
    Python is a good language for ciphering, because of the way you can manipulate strings and arrays. Just sit down and force yourself to put together some scripts to decrypt (or even solve) the challenges so far.

    #113776
    upsidedown
    Participant

    Learning to code can be daunting but is also incredibly rewarding and fun! You don’t necessarily need to be able to code to complete the later challenges (if I recall correctly there was an account a few years ago of somebody who solved the final cipher with pen and paper), but it is extremely helpful.

    For the basics of Python (what it is, how to install it, how to run a program) see this page on the python.org website which caters to people who have never programmed before.

    I’d recommend taking a look at this topic (Programming) on this forum, where there are some relatively beginner-friendly programming problems you can have a go at (thanks to @ByteInBits). You can take a look at others’ solutions as well.

    Lots of people point to madness’ book (see the BOSS library) and I’ll do the same here. It assumes very little prior knowledge of the Python programming language, which is used throughout the book and, in my view, is a great resource for learning to program and for the cipher challenge in general. Don’t be put off by the large number of pages in madness’ book: the first two parts are most important, and then in part II you write programs for caesar and keyword substitution ciphers.

    I actually first learnt to program through the cipher challenge! I found that once I had a basic understanding of the Python language, writing little programs to decrypt caesar ciphers and count the frequency of each letter in a string (frequency analysis), and then increasingly more complex cipher-adjacent programs, greatly improved my skill and understanding of programming.

    #114038
    T
    Participant

    Has anyone else noticed that when doing statistical analysis of the text in the challenges that the letter percentages are a bit different to what you would expect in generic English text, I’ve copy and pasted all of the challenge text into one file and these are the results I get:

    Impressive table, but this is an excellent exercise and I think everyone else will benefit from trying it for themselves! Harry

Viewing 12 posts - 46 through 57 (of 57 total)
  • You must be logged in to reply to this topic.
Report a problem