The Powers That Be

Discussion of challenges you have already solved
FreeFull
Posts: 7
Joined: Fri Apr 22, 2011 6:26 pm

Post by FreeFull »

bc, cat and a terminal window that tells you how wide and tall it is when you resize. Probably the easiest solution.
Millennium
Posts: 17
Joined: Thu Apr 21, 2011 3:08 am

Calculation Was Easy

Post by Millennium »

I did the calculations on a bignum calc in C++ that I had made long ago. I actually had added the option to display every xth digit. I just made a slight edit so that now I can choose what digit to start off of.
BosseBL
Posts: 6
Joined: Tue Aug 09, 2011 10:47 am
Location: Stockholm

Post by BosseBL »

lol...envy you phyton programmers. Im not gonna post my messy c++ code here.
I had to find a way to calculate the value part by part and store the answere in smaller bits in a vector.
must make a c++ class based on this problem, so I never have to mess with large number coding ever again.
Taurath
Posts: 5
Joined: Mon Feb 06, 2012 7:15 pm

Post by Taurath »

First thing I've written in 5 years, and first time ever using ruby. I could clean this up, but this is what I did to solve:

Code: Select all

y = ((17**39)**11)
y = y.to_s
z = 0
x = y[z].chr

while x != nil do
	puts x
	z = z + 33
	x = y[z].chr
	end
Of course, it pops a new number out each line. I know how to clean it now, but hey, its okay for a first run.
Seplik
Posts: 2
Joined: Wed Jan 25, 2012 5:34 pm

Post by Seplik »

Hi all,

this is my solution in C# (.NET 4)

Code: Select all

using System;
using System.Numerics;

namespace ThePowerToBe
{
    class Program
    {
        static void Main(string[] args)
        {
            BigInteger ergebnis = BigInteger.Pow(17, 39 * 11);
            string tmp = ergebnis.ToString();

            for (int i = 0; i < tmp.Length; i++)
            {
                if (i % 33 == 0)
                {
                    Console.Write(tmp[i].ToString());
                }
            }

            Console.ReadLine();
        }
    }
}
Greets from Dresden

Seplik
the_austria
Posts: 5
Joined: Sun Mar 11, 2012 2:57 pm
Contact:

Post by the_austria »

I calculate all digits with wolframalpha.com and copy it in this JS code:

Code: Select all

var str="7287646047175693809181003658560624690001934249475037583383410966869968575
4467436227234724042627102964298841820516037233528475978459785414759364887185809727
4405592779889038847476635050174799866232012301434410796898542809249563904637123246
8838883439670635548482463420202788891164816364632521828315194205599067991807910869
8595734119712778333056577256424265140391245645531793341906275133082870098777864521
4725045780084668671936673752128478286140806951581228924388701768931419905595306419
093162717560756925359266275186144493274175697";

for (i=0;i<str.length;i+=33)
{
document.write(str.charAt(i));
}
space
Posts: 2
Joined: Mon Dec 27, 2010 4:55 pm

Post by space »

hobbist wrote:

Code: Select all

x = str(((17**39)**11)) 
x2 = ''
for i in range(0,len(x),33):
    x2 += x[i]
print 'powers that be ', x2

Gawd, I love python. Can't wait until I really start learning.
lol? :D
print str((17**39)**11)[::33]
pedromalta
Posts: 22
Joined: Wed Apr 13, 2011 12:00 am
Location: Vila Velha
Contact:

Java is easy enough

Post by pedromalta »

For the Math

Code: Select all

public BigInteger ThePowersThatBe(){
		
		BigInteger n17 = new BigInteger("17");
		return n17.pow(39).pow(11);
	}

And to concatenate each 33rd

Code: Select all

public String ThePowersThatBe(BigInteger result){
		String retorno = "";
		int pivot = 0;
		while (true){
			try{
				retorno += result.toString().substring(pivot, pivot+1);
				pivot+=33;
				
			}catch (StringIndexOutOfBoundsException e) {
				return retorno;
			}
			
		}
	}
sudo apt-get a life
fuxx
Posts: 3
Joined: Fri Aug 31, 2012 3:41 pm

Post by fuxx »

b:string((17^39)^11), for a : 1 thru slength(b) do (if mod(a, 33)=1 then printf(true, "~c", charat(b, a)))$
strongdrink
Posts: 4
Joined: Tue Jul 12, 2011 4:31 pm
Location: Floating Around

Post by strongdrink »

Vim FTW!!
Use bc to calculate the number, then in vim:
l32dl (Repeat 16 times) :D
pgrigoruta
Posts: 1
Joined: Tue Aug 07, 2012 8:00 pm

This is confusing

Post by pgrigoruta »

Hello, I easily understood what needs doing and implemented it with PHP bcmath. Yet after reading:

"Now take every 33rd digit of x, starting with the first (most significant), and stick them together."

I interpreted as "use digits 33, 66 etc", while it looks like the needed digits are 1, 34 etc. Luckily there are some hints in the not-done forum to clarify this, but since I look at hints as a last resort I ended up doing the calculation in multiple languages as I never suspected the issue was with correctly interpreting the challenge. I think a better challenge text would be:

"Take the first digit then every thirty-third digit after it, i.e. digit 1, digit 34, digit 67 etc, and stick them together."
th4wri
Posts: 8
Joined: Tue Mar 29, 2016 10:27 am
Location: TuNiSiA

Post by th4wri »

java :

Code: Select all

package hacker.org;

import java.math.BigInteger;

public class ThePowersThatBe {

	public static void main(String[] args) {

		
		BigInteger b = new BigInteger("17");
		b = b.pow(39);
		b = b.pow(11);
		String resOp = b.toString();
		String sol = "";
		for(int i=0;i<resOp.length();i=i+33)
			sol += resOp.charAt(i);
		System.out.println(sol);
		
		
	}

}

Balian_von_Ibelin
Posts: 1
Joined: Wed Jan 06, 2021 10:13 am

Post by Balian_von_Ibelin »

solved it in haskell

x = show ((17^39)^11)
getX :: [Char] -> [Char]
getX "" = ""
getX y = head y : getX (drop 33 y)


getX x = solution


first time i can use it for something after i had to learn it while studying
Post Reply