Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 10 9 8 7 6 5 4 3 2 1
- 0 1 2 3 1 5 4 3 2 1
- 8 18 6 11 14 3 15 10 6 19 12 3 7 5 5 19 12 12 14 5
- 0 0 0 3 4 3 1 2 6 9 1 3 7 5 5 3 12 12 14 5
- 1
- 0
- 1 1
- 0 1
- f={l=_this;r=[];i=0;while{i<count l}do{r=r+[(l select i)%(i+1)];i=i+1};r}
- numList = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1];
- hint format["%1n%2", numList, numList call f];
- %J
- %J
- J List 1 .. len(input). This is results in a list of the indexes.
- % Modulo.
- pryr::f(x%%seq(x))
- function (x)
- x%%seq(x)
- ;ww.1I!@s%Ow;)Sow.$
- ; w
- w .
- 1 I ! @ s % O w
- ; ) S o w . $ .
- . .
- . .
- ā%
- ā # Push the range(1, len(a) + 1)
- % # Mod each element in the input by the same one in this list
- #&@@@Mod~MapIndexed~#&
- tn:
- +` , + + * + + + +* + * . + + .'
- + Push 1. This is the initial value of the counter
- ` Mark label
- , Read number from input and push it. Gives 0 if no more input
- + Duplicate top of the stack
- + Duplicate top of the stack
- * Pop two numbers and push their division. Error if divisor is 0
- + Pop (discard) top of the stack
- + Swap top two numbers
- + Duplicate top of the stack
- + Push 1
- * Pop two numbers and push their sum. This increases the counter
- + Rotate stack down, to move increased counter to bottom
- * Pop two numbers and push their modulus
- . Pop a number and print it as a number
- + Push 10
- + Duplicate top of the stack
- . Pop a number (10) and print it as ASCII character (newline)
- ' If top of the stack is non-zero (it is, namely 10) go to label
- l⟦₁;?↔z%ᵐ
- l⟦₁ [1, ..., length(Input)]
- ;?↔z Zip the Input with that range
- %ᵐ Map mod
- ®%°T
- :Implicit input of array U
- ® :Map over the array
- % :Modulo of the current element
- °T :T (0, initially) incremented by 1
- pryr::f(x%%1:sum(x|1))
- zipWith(flip mod)[1..]
- #~Mod~Range@Length@#&
- #~Mod~Range@Tr[1^#]&
- {_,,:).%}
- { } e# Define block
- _ e# Duplicate
- , e# Length
- , e# Range, 0-based
- :) e# Add 1 to each entry
- .% e# Vectorized modulus
- >:@i.@#|[
- a=>a.map((x,y)=>x%++y)
- {print $1%NR}
- lmap l $L {puts [expr $l%[incr i]]}
- (⍳⍴R)|R←⎕
- a->[a[n]%n|n<-[1..#a]]
- .e%bh
- hk # 1-based index of (implicit) lambda variable
- b # element
- % # element mod (1-based index)
- .e Q # enumerated map over (implicit) input
- V1R&,{v.m1+v%}&,=;
- V1R&,{v.m1+v%}&,=; Implicit input from commandline args
- V1R Create stack2, push 1 to it, and return to stack1
- &, Reverse stack1
- {.......} Foreach loop, runs for each item in stack1
- v Switch to stack2
- .m Duplicate last item on stack and move duplicate to stack1
- 1+ Increment last item on stack
- v% Return to stack1, pop last 2 items and push modulus result
- &, Reverse stack1
- = Output stack1
- ; Suppress implicit output
- a->{for(int i=0;i<a.length;a[i]%=++i);}
- a=>{for(int i=0;i<a.Length;a[i]%=++i);}
- a->{ // Method with integer-array parameter and no return-type
- for(int i=0;i<a.length; // Loop over the indexes of the array (0-indexed)
- a[i]%=++i // And replace every integer with itself mod (1+i)
- ); // End of loop
- } // End of method
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement