Programming
A Tale of 2 Secrets › Forums › T.E.M.P.E.S.T. › Programming
Tagged: #answer
- This topic has 56 replies, 12 voices, and was last updated 1 month, 2 weeks ago by T.
-
AuthorPosts
-
10th November 2025 at 7:09 pm #113068F6EXB_the_frenchyParticipant
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
10th November 2025 at 7:12 pm #113177Robb27ParticipantByteInBits #113017
Forgive my typo transcribing the starting number which is 102564. The Pari/GP is correct.10th November 2025 at 10:20 pm #113189ByteInBitsParticipant@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
10th November 2025 at 10:21 pm #113191ByteInBitsParticipant@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
= 41025610th November 2025 at 10:21 pm #113193ByteInBitsParticipant@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
73939720th November 2025 at 6:36 pm #113766ScarlettParticipantHi,
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.20th November 2025 at 11:16 pm #113781Crackerjack_404Participant@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 analysisYou 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!
23rd November 2025 at 3:12 pm #113841ScarlettParticipant@Crackerjack thank you!
26th November 2025 at 11:48 am #113780Gen_ruiktParticipant@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
26th November 2025 at 11:48 am #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.26th November 2025 at 11:48 am #113776upsidedownParticipantLearning 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.
1st December 2025 at 10:51 pm #114038TParticipantHas 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
-
AuthorPosts
- You must be logged in to reply to this topic.