Well IQfy? What's the most efficient way that you'd go about printing out this religious symbol in Python?
Shopping Cart Returner Shirt $21.68 |
Nothing Ever Happens Shirt $21.68 |
Shopping Cart Returner Shirt $21.68 |
Well IQfy? What's the most efficient way that you'd go about printing out this religious symbol in Python?
Shopping Cart Returner Shirt $21.68 |
Nothing Ever Happens Shirt $21.68 |
Shopping Cart Returner Shirt $21.68 |
>most efficient way
store it as string to be displayed
import timeTravel
timeTravel.toTheGoodOlDays()
scratch a liberal and fascist will bleed. one of the best sayings of all time and so accurate today with their financing of Azov
keyed
Rings true today with the Israel/Gaza stuff, really goes to show how easy it is to turn people into something they would never dream of being with the right amount of media and peer pressure.
fr fr
>you wouldn't want to be one of those virtue signaling liberals now would you goyim
>isn't it heckin based chungarino how we flat out genocide palestinian kids goy?
>you can be part of our club, we totally aren't cool with BLM like we were three years ago when they wanted to kill whitey
>in fact we hate them now because they won't let us put every palestinian into a giant blender
>no you still can't have your country back
>yes we will still destroy you if you deny the 6 gajillion
frick off
I said nothing Pro-Israel. All I said was that it's absolutely wild that a large portion of Americans became anti-Semitic as quickly as they did and how easily they became it, going from seeing Israel doing kinda fricked up shit in Gaza to declaring that israelites should be killed off for being israeli pigdogs.
they're not even antisemitic though. I'm antisemitic. normalgays are just experiencing a normal amount of non-positive semitism as a result of exposure to typical semitic actions via tiktok
two more weeks, comrade pidorenko
Good morning sir
52 more weeks, vatnik
Sorry. The new python filters block any codes that tries to print politically incorrect output.
Iterate line by line with a bunch of if checks.
d=7
def t(r):
r = [(0,1), (0, 2), (1, 1), (1,2), (2, 1), (2,2)]
for _ in range(6): yield r[_]
for _ in range(3*len(r)):
x,y = r.pop(0)
x,y = y, d-x-1
r.append((x, y))
yield x, y
for i in range(d):
print(''.join([' ' if (i,j) in [_ for _ in t(r)] else '*' for j in range(d)]))
frick
brainlet here, took me about 10< mins
def printSwastika(n):
nn = n-1
m = 2*nn + 1
tmp_start = '*' + (n-1)*' ' + (n+1)*'*'
tmp_fh = '*' + (n-1)*' ' + '*' + (n)*' '
tmp_mid =(2*n + 1)*'*'
tmp_sh = tmp_fh[::-1]
tmp_end = tmp_start[::-1]
print( tmp_start )
for i in range(m):
if i < nn: ## first half
print( tmp_fh )
elif i == nn: ## middle
print( tmp_mid )
else: ## second half
print( tmp_sh )
print( tmp_end )
for the figure, it corresponds to n equal 3
all of these implementations are worse than
because it literally takes less code and less memory to just stdout a static string
for i in b'yttx7fHHO':
print(''.join('*' if i >> x & 1 else ' ' for x in range(0, 7*~~
>for i in b'yttx7fHHO':
Wat
it's l33t for "b***h hoe"
print("""
* *****
* *
* *
********
* *
* *
**** *
""")
this is unironically the right solution. why would you mess with extra logical processing to make a very small, static string? could add newline characters to make it all fit on one line if you wanted, but that's just a personal taste thing. in terms of "efficiency", doing anything but this is just moronic
I'm not that good at codegolfing.
print("n".join(["".join([[" ","*"][ord(i)>>j&1]for j in range(7)])for i in"~AA~@A>"]))
Still the shortest non-meme solution.
T(1) S(1) implementation:
t = "* ****n* * n* * n*******n * *n * *n**** *n"
print(t)
Very nice anon. What if we want to generalize the solution, that user can specify the length of the swastika, that if I ask for length of 2, then i’ll get
* * *
* * *
* * *
and if I specify for length of 4 i’ll get the pattern in OP’s pic? Can you do it in linear time?
Although not the same
already kind of does it
>Can you do it in linear time?
welp just tried to do a simple check with a test but had to stop it midways since it took too long. Pretty sure that doing concatenations becomes the main bottleneck but right now is bedtime so I won't delve further into it.
You're printing out a square, dum-dum.
It's always going to be O(n^2).
This is what separates the college sophomores from the oldgay programmers
College sophomores will try all the heckin basederino coding challenge tricks they’ve earned to get it into as few characters as possible
Oldgay programmers will take one look, say “it’s explicitly O(n^2) and optimization’s a waste of time because IO completely mogs everything else” and will, at most, create a subroutine to generate an arbitrary size
Sure, but still the obvious jump near n~700 implies that my code is terrible, regardless of the O(n^2) complexity
I would just do something like this:
spacemode = 0
for(i...7)
spacemode = i < 2 ? i : i == 3 ? 2 : i == 6 ? 3 : 1;
switch spacemode
case 0: print("* ****")
case 1: print("* * ")
case 2: print("*******")
case 2: print("**** *")
Could easily be adjusted for different sizes and such
print(open('symbol.txt').read())
holy based. now do it with a url request
from selenium import webdriver as w
print(w.Chrome(options=w.ChromeOptions()).get('https://kek.com/symbol.txt').page_source)
hitting bloat levels that shouldn't even be possible
>bloat
I think you will find this is just the modern standard for that sort of thing.
def line(string, scale, times):
[a, b, c, d, e] = string
for _ in range(times):
print(a + b * scale + c + d * scale + e)
n = 2
line('* ***', n, 1)
line('* * ', n, n)
line('*****', n, 1)
line(' * *', n, n)
line('*** *', n, 1)
>half the thread is pyshitters
absolute state of IQfy-nazis
chuds can't code
What!?
Python code in a Python Challenge thread?
wtf
in RUST this is just:
use Char::*;
#[derive(Clone)]
enum Char {
Star(i32),
Blank(i32),
}
fn print_row(chars: &Vec<Char>) {
for c in chars {
match *c {
Star(i) => (0..i).for_each(|_| print!("*")),
Blank(i) => (0..i).for_each(|_| print!(" ")),
}
}
print!("n");
}
fn main() {
let rad = 10;
let top_row = vec![Star(1), Blank(rad - 2), Star(1), Star(rad - 2), Star(1)];
let mid_top_row = vec![Star(1), Blank(rad - 2), Star(1), Blank(rad - 2), Blank(1)];
let mid_row = vec![Star((rad * 2) - 1)];
let mid_bot_row = mid_top_row.iter().cloned().rev().collect();
let bot_row = top_row.iter().cloned().rev().collect();
print_row(&top_row);
(0..(rad - 2)).for_each(|_| print_row(&mid_top_row));
print_row(&mid_row);
(0..(rad - 2)).for_each(|_| print_row(&mid_bot_row));
print_row(&bot_row);
}
fn print_row(v: &Vec<(&str, usize)>) {
v.iter().for_each(|(c, i)| print!("{}", c.repeat(*i*~~;
println!("")
}
fn main() {
let n = 2;
let top = vec![("*", 1), (" ", n), ("*", 1), ("*", n), ("*", 1)];
let up1 = vec![("*", 1), (" ", n), ("*", 1), (" ", n), (" ", 1)];
let mid = vec![("*", 1), ("*", n), ("*", 1), ("*", n), ("*", 1)];
let up2 = vec![(" ", 1), (" ", n), ("*", 1), (" ", n), ("*", 1)];
let bot = vec![("*", 1), ("*", n), ("*", 1), (" ", n), ("*", 1)];
print_row(&top);
for _ in 1..=n { print_row(&up1) }
print_row(&mid);
for _ in 1..=n { print_row(&up2) }
print_row(&bot);
}
I don't understand why i is a reference in for_each
Just realised print_row can also be written as
fn print_row(v: &Vec<(&str, usize)>) {
println!("{}", v.iter().fold(String::new(), |acc, (c, i)| acc + &c.repeat(*i*~~
}
I also translated this in Haskell
print_row :: [(Char, Int)] -> IO ()
print_row = putStrLn . foldl (acc (i, c) -> acc ++ replicate c i) ""
main = do
let n = 2
let top = [('*', 1), (' ', n), ('*', 1), ('*', n), ('*', 1)]
let up1 = [('*', 1), (' ', n), ('*', 1), (' ', n), (' ', 1)]
let mid = [('*', 1), ('*', n), ('*', 1), ('*', n), ('*', 1)]
let up2 = [(' ', 1), (' ', n), ('*', 1), (' ', n), ('*', 1)]
let bot = [('*', 1), ('*', n), ('*', 1), (' ', n), ('*', 1)]
print_row top
mapM print_row $ replicate n up1
print_row mid
mapM print_row $ replicate n up2
print_row bot
Idk if there is a better way. Maybe zipping? I tried zipping in Rust and it sucked because of how many iterators it needed and then the type system fricked everything up
Good morning sirs!
fn main() {
println!(r#"
* ****
* *
* *
*******
* *
* *
**** *
"#);
}
I did it in J.
In J this is just
' *'{~|:(+.|.@|:)^:3(3&>+3=7&|)i.7 7
* ****
* *
* *
*******
* *
* *
**** *
Based. I am struggling to learn all this wizardry; if only I had known about (+.|.@|:)^:3...
I've extended the code to specify the radius:
' *'{~(+.|.@|:)^:3 {{(<:y,1)|.(0 0{(1-+:y)){.0=*./"1>{;~i.y}}7
* *******
* *
* *
* *
* *
* *
*************
* *
* *
* *
* *
* *
******* *
>python
Did a while ago in brainfrick. Press a number from 3 to 9 to choose a size (radius).
>>>++++++++[->++++>++++<<]>+++>>++++++++++<<<<<<+[-,.>>>>>>..<<<<<+++++[<---------->-]>>>.<<<<[->>+>+<<<]>>>[-<<<+>>>]<[>>>.<<<-]>>.<<<<[->>+>+<<<]>>>[-<<<+>>>]<[>>.<<-]>>.>>.<<<<<<[->+>+<<]>>[-<<+>>]<[>>>.<<<<[->>+>+<<<]>>>[-<<<+>>>]<[>>>.<<<-]>>.>>.<<<<<-]>>>...<<<<[->>++>+<<<]>>>[-<<<+>>>]<[>>.<<-]>>>>.<<<<<<[->+>+<<]>>[-<<+>>]<[>>>>.<<<<<[->>+>+<<<]>>>[-<<<+>>>]<[>>>.<<<-]>>.<<<<[->>+>+<<<]>>>[-<<<+>>>]<[>>>.<<<-]>>.>>.<<<<<-]>>>..<<<<[->>+>+<<<]>>>[-<<<+>>>]<[>>.<<-]<<[->>+>+<<<]>>>[-<<<+>>>]<[>>>.<<<-]>>.>>...<<<<<<[-]+]
rate
#include <stdio.h>
int main(void)
{
enum{N=7,R=N/2+1,K=N*N};
int v[K]={0},i,j,k;
for (i=0;j=i%R,k=i/R,i<R*R;++i)v[j+R-1+k*N]=!j|!k;
for (i=0;k=i%K,i<2*K;++i)v[k]|=v[N-1-k/N+k%N*N];
for (i=0;i<K;++i){printf("%c%c",v[i]?'*':' ',(i%N==N-1)*'n');}
}
They forgot to add in the dots in between
Reminder that pure languages mog shithon.
>jpg
nein
Wonder if someone could do something cool with Turtle to draw this
Post the hardest most complex way to achieve that
Implement it as a closed form function for a polar plot of complex numbers.
see
Inspired
r = 3
d = 2 * r + 1
points = set.union(
{(i, r) for i in range(d)},
{(r, j) for j in range(d)},
{(i, 0) for i in range(r)},
{(0, j) for j in range(r, d)},
{(i, d - 1) for i in range(r, d)},
{(d - 1, j) for j in range(r)},
)
print('n'.join(''.join('*' if (i, j) in points else ' ' for j in range(d)) for i in range(d*~~
Also
r = 3
d = 2 * r + 1
def point(i, j):
return (j == r and 0 <= i < d
or i == r and 0 <= j < d
or j == 0 and 0 <= i < r
or i == 0 and r < j < d
or j == d - 1 and r < i < d
or i == d - 1 and 0 <= j < r)
print('n'.join(''.join('*' if point(i, j) else ' ' for j in range(d)) for i in range(d*~~
prtin("卍)"
>tripgay
>passgay
>backwards swastika
It would be harder to implement it if the pattern was angled.
don't @ me
x = 7;
y = 7;
h = x/2;
for (let i=0; i<y; i++) {
let line = "";
for (let j=0; j<x; j++) {
let star = i === Math.floor(h) || j === Math.floor(h);
star = star || (j === 0 && i < h) || (i === 0 && j > h);
star = star || (j === x-1 && i > h) || (i === y-1 && j < h);
line += star ? "*" : " ";
}
console.log(line);
}
The final solution.
print('* ****','* *','* *','*'*7,' * *',' * *','**** *',sep='n')
x, i = 349939169379577, 1
while x:
print(" *"[x & 1], end="n "[i % 7])
x, i = x >> 1, i + 1
For general size
r = 3
d = 2 * r + 1
x = 1 + (1 << r) + ((1 << r) - 1 << r + 1)
x += sum(1 + (1 << r) << i*d for i in range(1, r))
x += ((1 << d) - 1 << r*d)
x += sum((1 << r) + (1 << d - 1) << i*d for i in range(r + 1, d - 1));
x += (1 << r) - 1 + (1 << r) + (1 << d - 1) << (d - 1)*d
i = 1
while x:
print(' *'[x & 1], end='' if i % d else 'n')
x, i = x >> 1, i + 1
(Using a gap in the first part of the if in end makes it more square)
scheiss hurensoehne
i wouldnt trust any code in this thread besides the pre-formated print() chads
now make it spin